Shares of Microsoft (MSFT -1.27%) rallied 30% over the past 12 months, beating the NASDAQ's 25% gain and silencing the naysayers who believed that its heyday had passed. But with the stock near historic highs, and its P/E of 33 exceeding the industry average of 31 for software infrastructure providers, investors are likely wondering if they should take profits.

I personally believe investors should keep holding Microsoft for four simple reasons: its cloud growth remains robust, it's shrewdly cutting costs, it's building app ecosystems instead of operating systems, and it's expanding into next-gen markets.

The exterior of a Microsoft office.

Source; Pixabay.

1. Microsoft's $20 billion goal

Back in mid-2015, CEO Satya Nadella claimed that Microsoft would generate $20 billion in annual cloud revenues by the end of fiscal 2018. That was a lofty goal that called for Microsoft to triple its cloud revenues within three years. But thanks to the expansion of Microsoft's core cloud services (Office 365, Dynamics 365, and Azure), the company is now ahead of hitting that target.

Last quarter, Microsoft reported that its commercial cloud revenue had hit an annual run rate of $18.9 billion, thanks to 43% annual sales growth in Office 365, 74% growth in Dynamics 365, and 97% growth in Azure. If Microsoft's cloud revenue hits $20 billion by the end of fiscal 2018 (next June), it will account for almost a fifth of its projected revenues for the year. That growth could easily offset its slowing sales of Windows licenses.

2. It's trimming the fat

Analysts expect Microsoft's cloud growth to boost its revenue by 7% to $103.6 billion this year, but its earnings should stay nearly flat due to the higher costs of those investments.

That's why Microsoft has been shuttering its weaker businesses and cutting jobs. It recently stopped supporting Windows Phone, and unveiled plans to reduce its global sales force by about 10%. Those cuts can help it focus more on expanding Azure, which still trails behind Amazon's (AMZN -2.56%) AWS (Amazon Web Services) in the cloud platform race.

3. Focusing on apps instead of operating systems

In the past, Microsoft depended on users or PC makers paying for the latest version of Windows. That business model started crumbling after Alphabet's (GOOG -1.10%) (GOOGL -1.23%) Google and Apple (AAPL -1.22%) popularized free operating systems like Android, Chrome OS, iOS, and OS X.

Instead of selling OS licenses, Google and Apple generated revenue by taking a cut of the app store sales. Nadella's predecessor Steve Ballmer tried to counter Google and Apple by turning Windows into a third mobile OS.

Office on Android.

Office on Android. Source: Google Play.

But Nadella realized that instead of fighting a losing war against Google and Apple, it was smarter to hitch a ride on those operating systems with its own Android and iOS apps -- like Office, OneDrive, and Outlook. Microsoft also struck deals with Android OEMs to pre-install those apps on their phones. Those moves are keeping Microsoft in the mobile race, even though Windows Phone flopped.

4. It's expanding into next-gen markets

Under Ballmer, Microsoft constantly remained behind the tech curve. Under Nadella, Microsoft is moving ahead of the tech curve again with its HoloLens augmented reality headset, virtual reality partnerships with OEMs, and upgraded consoles like the Xbox One S and Xbox One X. It also offers Xbox One to Windows 10 game streaming -- which widens its PC moat against Valve's Steam.

Microsoft's HoloLens.

Microsoft's HoloLens. Source: Microsoft.

Microsoft is also expanding into smart homes via thermostats and speakers tethered to its voice assistant Cortana. Since Cortana already has 145 million users, those devices can help it counter Amazon's Echo, Google's Home, and Apple's upcoming HomePod in the growing smart home market.

Microsoft also recently introduced an auto licensing plan, which lets automakers license navigation, entertainment, and voice recognition features for connected vehicles. All these moves could "future proof" Microsoft's business and help it keep pace with its industry rivals.

The road ahead...

Microsoft's trailing P/E looks lofty, but its forward P/E of 22 looks reasonable. Its upside potential might be limited, but I believe that Microsoft is making all the right moves to remain relevant in the "mobile-first, cloud-first world" which Nadella outlined back in early 2014.