It is hard to imagine what could go wrong with Microsoft these days. With current expectations where they are, not much would need to.

The software giant’s fiscal first-quarter results late Tuesday continued a strong run, with revenue exceeding Wall Street’s consensus forecast for the 11th consecutive quarter, according to FactSet.

All of...

It is hard to imagine what could go wrong with Microsoft these days. With current expectations where they are, not much would need to.

The software giant’s fiscal first-quarter results late Tuesday continued a strong run, with revenue exceeding Wall Street’s consensus forecast for the 11th consecutive quarter, according to FactSet.

All of the company’s segments outperformed—even the one closely associated with personal-computer sales that have been slowing remarkably of late. The results gave Microsoft’s stock a lift of more than 5% on Wednesday afternoon after already picking up more than 40% for the year.

At its current level, Microsoft is just shy of overtaking Apple as the world’s most valuable company, with both carrying market values a little over $2.4 trillion.

Microsoft’s last extended run as the world’s most valuable enterprise took place in the early 2000s, when its business mostly consisted of the Windows Operating system and its suite of Office software applications.

But the company’s most recent success building a booming cloud-computing operation harks back to that period in some interesting ways. Microsoft’s fiscal year that ended in June was its fourth straight of double-digit revenue growth—a feat not seen since fiscal 2004. And its annual operating margin passed the 40% mark for the first time since fiscal 2001.

SHARE YOUR THOUGHTS

What did you find most interesting about Microsoft’s quarterly earnings? Join the conversation below.

Another similarity that may be a little less soothing: Microsoft’s shares are now trading at 35 times forward earnings. The last extended stay around that level was in 2002, before the stock went into a decadelong slump thanks to a host of factors, including the lingering effects of a government-sponsored antitrust crackdown and strategic blunders that included missing the smartphone revolution. Case in point: In 2002, Microsoft’s market value was 40 times the size of Apple’s. The iPhone maker surpassed Microsoft just eight years later.

Microsoft is no doubt in a much better position now. Its sharp pivot to the cloud may have been a bit behind that of Amazon.com, but it is catching up quickly.

Microsoft’s Azure cloud-computing service is now 61% the size of Amazon’s AWS segment on the basis of trailing 12-month revenue—compared with 30% just five years ago.

And Azure only represents a portion of Microsoft’s cloud operations; its

Microsoft Cloud division that includes Azure and applications like Office 365, Dynamics 365 and portions of LinkedIn now generates nearly $75 billion in trailing 12-month revenue compared with an estimated $56.6 billion for AWS. Microsoft Cloud has also averaged 34% on-year growth over the last eight quarters compared with a 32% average for AWS.

One advantage Microsoft lacks relative to its arch-cloud rival is a license to spend. Amazon, which has a current market value of $1.7 trillion, has long conditioned its shareholders to roll with the company’s frequent “investment modes,” where billions are spent to build up data centers, delivery systems and even Hollywood movies.

As a result, Amazon’s operating margins have long floated in the low single-digit range even with some improvements over the years. By contrast, Wall Street expects Microsoft’s operating margin to remain above 40% for at least the next three years, despite the company’s need to keep up in the costly cloud race.

A $2.4 trillion value doesn’t come cheap.

Write to Dan Gallagher at dan.gallagher@wsj.com