Last year was exceptionally difficult for many investors. The S&P 500 and the Nasdaq Composite fell into bear market territory as high inflation and rising interest rates rattled the U.S. economy. In fact, both indexes fell more sharply in 2022 than in any year since the Great Recession in 2008.

Fortunately, there is a silver lining to that difficult situation. Every U.S. bear market in the past, regardless of its duration or severity, has ended in a bull market, and there is no reason to expect a different outcome this time. In the meantime, investors have an opportunity to buy great stocks like Cloudflare (NET 0.73%) and Microsoft (MSFT 1.49%) while they are still trading at discounted prices. 

Cloudflare: A disruptive cloud computing company

Cloudflare is becoming a cloud computing giant. It started as a simple content delivery network (CDN), but its portfolio now includes a broad array of application, network, and security services that protect and accelerate corporate infrastructure and software. Cloudflare also provides compute and storage services through its developer platform, meaning businesses can build performant software and websites directly on its network.

The cloud computing industry is intensely competitive, but Cloudflare operates the fastest cloud network and developer platform on the market. In fact, it can deliver content to 95% of the internet-connected population within 50 milliseconds. That speed has helped Cloudflare achieve a leadership position in CDN software and edge development platforms, and the company is also gaining momentum in other cloud verticals, including zero-trust security.

Cloudflare reported monster financial results in the third quarter, brushing aside the economic headwinds that have plagued so many businesses. Its customer count climbed 18% to 156,000, and the average customer spent 24% more over the past year. In turn, revenue rose by 47% in the third-quarter to $254 million, and the company reported a non-GAAP profit of $0.06 per diluted share, up from $0 per share in the prior-year period.

Looking ahead, Cloudflare should have no problem maintaining its rapid growth trajectory, as it has hardly scratched the surface of its $125 billion total addressable market (TAM). In fact, management expects revenue to grow fivefold in the next five years, even without the company building any new products. That implies annualized revenue growth of 38% through 2027. Of course, Cloudflare has built new products quickly throughout its history, so investors have reason to believe it will grow its top line even faster.

With that in mind, shares currently trade at 20.5 times sales. That is a reasonable valuation for a business growing as quickly as Cloudflare, and it's an absolute bargain compared to its three-year average of 41.8 times sales. That's why this growth stock is worth buying today.

Microsoft: The best software company on the planet

Microsoft recently reported disappointing financial results for its fiscal 2023 second quarter, which ended Dec. 31. Revenue rose just 2% to $52.7 billion, a significant deceleration from the 20% growth it achieved in the prior-year period, while GAAP earnings slipped 11% to $2.30 per diluted share. Unfortunately, the near-term outlook is equally grim. Management expects 3% revenue growth in its fiscal third quarter as unfavorable exchange rates and macroeconomic conditions continue to weigh on the business.

Fortunately, there is a silver lining for patient investors. Microsoft stock has fallen more sharply during the current bear market than at any other point in the past decade, but the economic headwinds responsible for that decline should prove to be temporary problems. Additionally, Microsoft provides a broad number of mission-critical software products and cloud services to hundreds of thousands of businesses, and that positions the company to reaccelerate growth when the economy recovers.

In fact, Microsoft ranked as the best software seller worldwide last year, according to research company G2. That recognition was based on its high user satisfaction scores and its leadership positions in several software markets. Of course, Microsoft 365 is the gold standard in office productivity software, but G2's analysts have also recognized the company as a leader in areas like enterprise resources planning and cybersecurity, and both of those markets are expected to grow at compound annual rates in the double-digit percentages through the end of the decade, according to Grand View Research.

Meanwhile, Microsoft Azure is steadily gaining market share in cloud computing. After taking 2 percentage points over the past year, it now accounts for 23% of cloud infrastructure and platform services (CIPS) spending, which makes it the second-largest CIPS vendor by a wide margin. That positions Microsoft for tremendous growth in the coming years, as cloud computing spending is expected to increase by an average of 16% annually to reach $1.6 trillion by 2030.

Finally, Microsoft has quietly become the seventh-largest digital advertising publisher in the world, and its partnership with Netflix should help the company take share in online video advertising, a market expected to grow at an average of 14% annually to reach $362 billion by 2027.

Here's the upshot: Microsoft is well-positioned to grow its revenues at a double-digit percentage pace annually for the foreseeable future, which makes its current valuation of 9.4 times sales look reasonable. That's why investors should capitalize on this once-in-a-decade buying opportunity.