Last year, Morgan Stanley analysts led by Keith Weiss identified Microsoft (MSFT -0.21%) as the software company best positioned to monetize generative artificial intelligence (AI) across infrastructure and applications.

Weiss reiterated that opinion following a recent survey of chief information officers (CIOs), which identified Microsoft as the company most likely to gain share in generative AI over the next three years. For context, 38% of CIOs selected Microsoft, while 12% selected Amazon, putting the company in second place.

Investors should be excited about AI given the tremendous opportunity it creates. Bloomberg Intelligence believes generative AI spending could compound at 43% annually through 2032. But it would be imprudent to buy a single AI stock, even if that company is expected to be the biggest winner. It makes more sense to own a basket of AI stocks. So, investors need to ask themselves if Microsoft belongs in that basket.

Microsoft is supercharging its business with artificial intelligence

Microsoft has two major growth engines in enterprise software and cloud computing. The company not only has a strong presence in both markets, but also has been gaining share. That leaves Microsoft ideally positioned to monetize artificial intelligence (AI) across software and cloud services, and new products like Microsoft 365 Copilot and Azure OpenAI Service should help the company do just that.

To elaborate, Microsoft led the enterprise software market last year, accounting for 18% of total sales, up 350 basis points from 2018, according to the International Data Corp. Its flagship productivity platform Microsoft 365 was the primary source of that success. The company is leaning into that momentum with Microsoft 365 Copilot, a generative AI assistant that automates tasks across office applications like Excel, PowerPoint, and Word.

Meanwhile, Microsoft Azure ranked second in cloud infrastructure and platform services (CIPS) in the fourth quarter. It accounted for 24% of CIPS spending, up 750 basis points from 2018, according to Synergy Research Group. Product categories contributing those share gains include cybersecurity, database, and developer services, especially those related to artificial intelligence and machine learning.

Going forward, Microsoft is well positioned to maintain that trend. Azure is the exclusive cloud provider to OpenAI, meaning it monetizes usage of the popular chatbot ChatGPT. Moreover, Azure OpenAI Service lets businesses customize OpenAI large language models to build bespoke generative AI applications. Finally, CEO Satya Nadella recently told analysts that Azure offers the best infrastructure for AI training and inference.

Amazon Web Services currently holds 31% market share in CIPS, but Morgan Stanley analysts believe Microsoft could overtake Amazon as the market leader by 2027.

Microsoft beat expectation with its second quarter financial report

Microsoft reported strong financial results in the December quarter. Revenue increased 18% to $62 billion, in part because of strong growth in enterprise software and cloud computing services. That beat the $61.1 billion analysts were anticipating. Similarly, non-GAAP net income increased 26% to $2.93 per share because of continued cost discipline. That beat the $2.78 per share analysts were expecting.

On the earnings call, CEO Satya Nadella highlighted market share gains in cloud computing and various software categories. He attribute momentum in those markets to the "AI advantage" Microsoft has cultivated. That tailwind should continue in the future. Morgan Stanley analysts see a bull-case scenario where generative AI revenue from Microsoft 365 Copilot and Azure reaches $121 billion in fiscal 2029.

Investors should view AI as an incremental opportunitiy tacked on to the broader enterprise software and cloud computing markets, which are projected to expand at annual rates of 13.7% and 14.1%, respectively, through 2030. That means Microsoft has a good shot at annual sales growth of 14%-plus, depending on how successfully it monetizes AI.

Microsoft shares look expensive compared to Wall Street's consensus forecast

Lo and behold, Wall Street analysts expect Microsoft to grow sales at 14% annually over the next five years. That consensus makes the current valuation of 13.8 times sales look somewhat pricey. To elaborate, Microsoft grew sales at 14% annually over the last five years, identical to what analysts expect in the future, but the valuation averaged 10.6 times sales during that period.

In other words, the market afforded Microsoft a valuation of 10.6 time sales during a period when sales increased at 14% annually. So, why would the market now afford the company a higher valuation when sales are expected to grow at the same pace? That said, we can examine the situation through a different lens.

The efficient market hypothesis, which says all public information is immediately factored into the price, implies that investors are comfortable with current valuation in spite of the consensus sales forecast. That means the stock could be undervalued if Microsoft grows sales faster than expected. For instance, Morgan Stanley's bull-case calls for annual sales growth of 16% through fiscal 2029.

Here's the bottom line: Microsoft is a competitively advantaged business with a strong presence in enterprise software and cloud computing. To that end, it should be a major beneficiary as AI spending increases, perhaps even the biggest beneficiary. However, shares trade at a premium to the historical valuation, and the stock looks pricey compared to Wall Street's consensus sales forecast. So, investors that think Microsoft can beat the consensus should consider buying a small position today.