Microsoft (MSFT -0.18%), the third-largest public company in the world by market cap, hasn't been immune to the down period that defined the 2022 stock market. The company's stock has lost over 28% year to date -- which is better than the 36% decline from January to early November.

With that said, at its current price levels, and with a business built to withstand rough macroeconomic conditions, Microsoft's stock is a buy in 2023. Here's why.

Microsoft is dividing and conquering through its diversity

Microsoft has done a great job creating an ecosystem that few, if any, tech companies can compete with. Aside from the fact that its 2022 fiscal year revenue of $198.3 billion (up 18% year over year) is more than Intel, IBM, and Cisco Systems combined, what's really impressive is how diverse Microsoft's revenue streams are.

MSFT Revenue (Annual) Chart

Data by YCharts.

Here's how Microsoft's fiscal 2022 revenue breaks down by segment:

  • Server products and cloud services: 34%
  • Office products and services: 23%
  • Windows: 12%
  • Gaming: 8%
  • LinkedIn: 7%
  • Search advertising: 6%
  • Devices: 4%
  • Enterprise services: 4%
  • Other: 2%

For perspective, the iPhone accounted for more than half of Apple's fiscal year 2022 revenue, and Google advertising accounted for over 78% of Alphabet's. As those products and services go, so do the respective companies. Luckily, the same doesn't apply to Microsoft. It has its bread and butter -- like Office and its cloud service, Azure -- but its success isn't overly reliant on too few products or services.

Don't look past margins

A company's gross profit margin is the money it has left over from sales after subtracting the cost of goods sold (COGS). To find gross profit margin, subtract the COGS from revenue and then divide that total by the revenue. For example, if a company's revenue is $10 billion and its COGS is $4 billion, its gross profit margin would be 60% ($10 billion minus $4 billion, divided by $10 billion).

Microsoft's advantage over some of its competitors is that software accounts for a lot of its revenue. And since software tends to have lower COGS -- since you don't have to pay to produce each individual item, as with physical products -- Microsoft has higher gross profit margins than other big tech companies.

MSFT Gross Profit Margin Chart

Data by YCharts.

Gross profit margin is important because it shows a company's ability to generate future profits. It also helps a company squeeze out profits from fewer sales in case spending slows down, which might be so in the near future if expert predictions are correct. This is a tougher ask for companies like Apple, which rely a lot on hardware products and manufacturing.

The cloud is growing

The need for cloud services and infrastructure will only increase as we progress toward a digital-dominant world. The global cloud computing market was valued at over $405.6 billion in 2021. In 2022, it's estimated to be over $480 billion, and by 2029, it's expected to exceed $1.7 trillion. So we're still in the early stages of the cloud.

Microsoft's Azure is the second-largest public cloud service by market share, trailing only Amazon Web Services (AWS). That has a considerable lead with a 34% market share, but Azure is comfortably in second place with 21% -- 10 percentage points higher than the third largest, Google Cloud.

In fiscal year 2022, Azure's revenue grew 45% year over year and was Microsoft's second-largest moneymaker by product, trailing only the suite of Office software. It's bound to be Microsoft's growth driver for the foreseeable future. Of the $30.2 billion increase in revenue during fiscal year 2022, Azure was responsible for $13.5 billion. As the cloud industry expands, there's no reason to believe Azure won't grow at comparable levels, if not faster.

Business to business

An overlooked part of Microsoft's business is just how many of its customers are other businesses. Countless companies across the globe rely on its products and services. With cloud services, Office software, and LinkedIn recruiting, it is ingrained in the daily operations of many companies. This doesn't make it recession-proof by any means, but it does make it more recession-resistant.

The economy could cause consumers to slow spending, but because of the vital products and services Microsoft provides, the company should weather the storm relatively unscathed. Things may get worse before they get better for Microsoft's stock, but at current price levels, it's looking like the time to start (or begin increasing) your stake.