Microsoft has reported stronger than expected earnings in the June quarter, helped by substantial growth in its cloud computing division.

The software giant reported a net profit of $3.1bn (£2.4bn, €2.8bn) in the three months to 30 June, with earnings rising 2% year-on-year to $22.6bn.

Analysts had expected revenue to come in at $22.1bn.

Earnings were helped by a 107% jump in revenue for Azure – the company's cloud computing platform – that helped drive a 7% increase in total cloud earnings.

Microsoft shares closed 4% higher in New York following the news.

Amy Hood, chief financial officer, said the strong quarterly results were helped by the company's decision to invest in key product areas and geographies.

Satya Nadella, CEO of Microsoft, added: "This past year was pivotal in both our own transformation and in partnering with our customers who are navigating their own digital transformations.

"The Microsoft Cloud is seeing significant customer momentum and we're well positioned to reach new opportunities in the year ahead."

Hardware sales hit

The earnings are a significant improvement on the company's results in the same period last year, when it posted its largest ever quarterly loss of $3.2bn due to a write-down on its failed Nokia mobile business.

Microsoft's hardware business took a 35% hit to its revenue, driven mainly by a 71% plunge in phone sales.

Gaming revenue dropped 9% due to sales of Xbox hardware dropping by a third.

Microsoft has written off nearly all the money it spent to acquire Nokia Reuters

"This fiscal year we invested in innovation and expanded our market presence in key product areas and geographies," Hood said.

"I am pleased with the execution from our sales teams and partners this quarter who delivered a strong finish to the fiscal year."

Microsoft last month agreed a deal to buy professional networking website LinkedIn for $26bn – by far the biggest acquisition in the company's history.

Nadella has bet on cloud computing to drive future growth at Microsoft amid slowing sales of PC and the Windows operating system.

The Redmond-based firm said earlier this week that it would miss its target of getting Windows 10 running on more than one billion machines by 2018.