Shares rose 3.1 percent to $44.70 in after-hours trading.
"The company beat across the board," said FBR Capital markets analyst Daniel Ives. "The Street will cheer these results as it appears Microsoft is back on the right track after a head-scratching performance last quarter."
Sales of Windows to computer manufacturers to install on new PCs fell 19 percent in the quarter, reflecting a sharp dip from a year ago when Windows got a brief boost from consumers rushing to buy new machines after Microsoft stopped support for the 14-year-old XP operating system.
The company said its commercial cloud-related revenue for the quarter more than doubled, and was now running at $6.3 billion a year. Amazon said on Thursday its quarterly cloud revenue rose almost 50 percent to $1.57 billion, suggesting a similar annual number.
Microsoft's overall revenue rose 6 percent to $21.7 billion, above Wall Street's average forecast of $21.1 billion, according to Thomson Reuters I/B/E/S.
Taking out the effects of the strong U.S. dollar on currency rates, Microsoft said revenue would have risen 9 percent.
Earnings per share declined to 61 cents per share from 68 cents in the year-ago quarter. Analysts had expected 51 cents, on average.
© Thomson Reuters 2015