Microsoft (MSFT 0.74%) has been more of a blue chip stock than a tech one for nearly a decade. Now it can add "safe haven" to its list of attributes. 

With the U.S. in a trade war with China, and recession fears reverberating through the markets, tech investors could be forgiven if they look for places to hide out. 

Apple (AAPL 1.66%) isn't an option. The trade war with China is hurting its ability to compete against Samsung. If a recession does happen, consumers may not be so willing to spend $1,000 on a new mobile phone. 

Alphabet's (GOOG 0.72%) (GOOGL 0.83%) Google has its own problems. Lawmakers and regulators across the globe are gearing up to fine and otherwise penalize the Internet giant. Even Amazon (AMZN -0.17%) could be at risk in a recessionary environment. If consumer spending falls off a cliff, sales could decline for the e-commerce giant. 

And then there's Facebook (META 2.67%). It's in the most precarious situation of the group. Regulators, lawmakers, consumer groups, and even 2020 presidential candidates are calling for its break up. 

That leaves Microsoft, a company not too long ago written off as a dinosaur. Year-to-date shares of the Redmond, Washington, software giant are up more than 36%. The stock has been on a steady climb in recent weeks amid the protracted trade war. The company is also reporting double-digit growth with 2019 fiscal year net profit up 21.6% year over year and sales up more than 14%. Much of the growth is coming from its cloud business, which competes head-on with Amazon Web Services and Google. 

A dollar bill shaped as arrow pointing up.

Image source: Getty Images.

Investors get predictable profitability

There are a lot of reasons to like Microsoft as a way to hedge against the trade war and a potential recession. The software industry isn't completely immune, but it has something many investors crave: recurring revenue. Much of Microsoft's software, including Office, is charged on a subscription basis, which means millions of businesses and consumers are paying on a recurring basis for its products and services. As a result, Microsoft has very predictable profits, something investors crave when things are going south. Microsoft has also done good by its income-seeking investors, raising its dividend more than 10 times since instituting it in 2004. Microsoft's size and market position puts it in a better position to maintain its dividend strategy in the face of a slowing economy. 

It also isn't chasing trends in tech, like some of its big rivals. Amazon and Apple are pouring billions of dollars into streaming content services, but Microsoft isn't following suit. Nor is it taking a stab at mobile phones again, or developing a self-driving vehicle. The software giant is staying in its lanes, focusing on cloud computing and software. As a result, investors don't have to worry too much about Microsoft spending billions on an endeavor that could fail in a recession. 

Software is more immune to tariffs, recession

Of the technology sectors operating in the current environment where tariffs and uncertainty loom large, software tends to be more insulated. It's not immune, but it also isn't reliant on supply chains and manufacturing to make its products, so its exposure is reduced. With the economic cycle likely in the late innings and worries about growth slowing, businesses will step up efforts to slash costs and continue to thrive. Software helps them do that. Large enterprises, in particular, have the ability to continue to spend on software, and Microsoft has a lot of them as customers. All of what's good with the software sector hasn't been lost on investors, including Carl Icahn. The famed investor recently invested in Cloudera, an enterprise software company, of which he now owns 18%. 

No one knows for sure if a recession will happen or if the trade wars will continue unabated, but for tech investors looking for a place to ride out the storm, Microsoft may be it.