The COVID-19 recession was abrupt and painful, but many tech companies weathered the storm as stay-at-home measures, remote work, and online education drove demand for their products and services.

However, many tech stocks are now declining as investors pivot toward value stocks and reopening plays as bond yields and vaccination rates rise. High-growth tech companies that relied heavily on pandemic-specific tailwinds, like Zoom Video Communications, are starting to lose their luster.

Faced with these challenges, investors must be more selective with tech stocks. Specifically, they should focus on evergreen tech giants that are resistant to the next recession which will more likely be caused by traditional macroeconomic challenges instead of another global pandemic.

Let's examine three companies that check those boxes: salesforce.com (CRM 1.05%), Palo Alto Networks (PANW 4.19%), and Microsoft (MSFT 1.65%).

A sign warning of a "recession ahead".

Image source: Getty Images.

1. Salesforce

Salesforce, the world's largest provider of cloud-based customer relationship management (CRM) services, has already weathered two major recessions since its IPO in 2004.

Salesforce's stock price has risen nearly 8,000% since its public debut and rallied about 50% over the past 12 months as demand for its services -- which also include cloud-based sales, marketing, and analytics tools -- remained robust throughout the pandemic.

Salesforce's revenue rose 24% to $21.25 billion in fiscal 2021, which ended this January, as its adjusted earnings grew 65%. It also reiterated its target of more than doubling its annual revenue to over $50 billion by fiscal 2026.

Salesforce is setting such confident long-term forecasts because companies will continue to streamline their sales teams, digitize their operations, and rely more on data-driven decisions to cut costs, improve their efficiency, and reduce their dependence on human employees for repetitive tasks.

Those secular trends could accelerate through economic downturns. Salesforce's near-term earnings growth will be squeezed by its planned takeover and integration of Slack, but its stock still looks reasonably valued at just over 50 times forward earnings and less than eight times this year's sales.

2. Palo Alto Networks

The cybersecurity sector is an evergreen market. In fact, cyberattacks often intensify during recessions as hackers, companies, and state-backed organizations resort to new ways to steal money and secrets.

Escalating tensions between the U.S., China, and other countries -- which drove President Biden to designate cybersecurity as a "top priority" for his administration -- should enable top-tier cybersecurity companies to continue growing through future recessions.

An IT professional checks a tablet.

Image source: Getty Images.

Palo Alto Networks, which serves more than 80,000 customers in over 150 countries, is my top pick in this sector. It's a market leader in enterprise firewalls, and it's been pivoting away from on-site appliances toward cloud-based and AI services in recent years.

That expansion, which the company is supporting with big acquisitions and investments, locks in customers with subscriptions and widens its moat against cloud-native competitors like CrowdStrike and networking giants like Cisco, which offers its own security services.

Palo Alto's revenue rose 24% year-over-year in the first half of fiscal 2021, which ended this January, and its adjusted earnings jumped 41%. It expects its revenue to rise 22%-23% for the full year, and for its adjusted earnings to grow 19%-21%.

The stock trades at about 50 times forward earnings and less than seven times next year's sales, which makes it a reasonably valued growth stock in this frothy market.

3. Microsoft

Over the past seven years, Microsoft has transformed from an aging software giant into a growing cloud company. Satya Nadella, who previously helmed Microsoft's cloud and enterprise group, led that turnaround as its third CEO with his "mobile first, cloud first" mantra.

Under Nadella, Microsoft's Azure became the world's second-largest cloud infrastructure platform after Amazon Web Services (AWS). It transformed its desktop-based productivity software into cloud-based services and launched Windows 10 as the "last" version of Windows, which would subsequently be updated through the cloud instead of local OS installations.

As a result, Microsoft's commercial cloud revenue -- which includes Office 365, Dynamics 365, Azure, and other services -- rose 34% year over year last quarter and accounted for 39% of its top line. This core business is well-insulated from a recession because it locks in its users with sticky subscriptions.

Nadella also abandoned Microsoft's ill-fated Windows Phone, launched mobile versions of its apps for iOS and Android, and continues to expand its Xbox and Surface businesses. It also entered the augmented reality market with the HoloLens and the cloud gaming market with Xbox Cloud Gaming.

Microsoft's revenue increased 15% year over year in the first half of fiscal 2021, which ended at the end of 2020, as its earnings grew 33%. Analysts expect its revenue and earnings to grow 15% and 29%, respectively, for the full year -- yet the stock still has a reasonable forward P/E ratio of 31.

The bottom line

Salesforce, Palo Alto Networks, and Microsoft all held up well during the pandemic, but they won't rely on stay-at-home trends to keep growing. Their stocks are also cheap relative to those of many other high-growth tech darlings, and their core businesses are all well-equipped to handle future recessions.