There is a growing fear among some experts that a recession is on its way and will hit within the next year. And so investors are rightly worried, especially since we're already dealing with various economic problems such as inflation.

But one good way to prepare for this potential development is by purchasing shares of solid, dividend-paying companies that can survive in almost any economic environment. Let's examine two stocks which fit the bill: Amgen (AMGN -0.19%) and Microsoft (MSFT 0.37%).

1. Amgen

Some drugmakers have significantly outperformed the market this year. Amgen is one of them. That's because its lineup of products, which are essential to the health and well-being of its customers, is helping it navigate the downturn better than most.

That should continue even if a recession arrives. Amgen's portfolio includes Tezspire, a medicine for severe asthma that was approved in December; cancer drug Lumakras, which is also a relatively new approval; immunosuppressant Otezla; and osteoporosis medicines Prolia and Evenity, among many others.

The company has a knack for developing new medicines, and its pipeline features 17 late-stage programs. Amgen also recently acquired ChemoCentryx -- a biopharmaceutical company that develops treatments for autoimmune diseases and cancer -- for about $3.7 billion in cash.

ChemoCentryx's lead asset is Tavneos, which targets a form of vasculitis (a group of illnesses that causes inflammation of the blood vessels). According to management, there remains an unmet need in this area. The acquisition of Tavneos could help Amgen build a presence in this space. Whether through Tavneos or other products, Amgen should continue strengthening its lineup.

The company will also benefit from long-term tailwinds like the world's aging population. The need for medicines rises as people get older. This demographic shift will provide plenty of opportunities to companies like Amgen. 

Amgen prioritizes rewarding shareholders with dividends. Earlier this year, it said it planned to pay an average of about 60% of its adjusted net income to shareholders through 2030. The company currently offers a yield of 2.83%, well above the S&P 500's average yield of 1.82%.

Amgen has raised its dividends by 68.7% in the past five years. Patient investors who hold the company's shares for a while will likely see many more dividend hikes in the future. 

2. Microsoft 

Unlike Amgen, Microsoft has lagged behind the market this year. While the tech world led the way during the incredible bull market that marked the 2010s -- and during the early days of the pandemic -- investors are turning on many of these companies, partly because current market conditions are harming them. 

Consider Microsoft's latest earnings report for the first quarter of its fiscal 2023, ended on Sept. 30. The company's revenue for the period increased by almost 11% year over year to $50.1 billion. A strengthening U.S. dollar negatively affected Microsoft's revenue growth.

Currency fluctuations aside, Microsoft's revenue would have jumped by 16% year over year, which would have helped reverse its recent decline in revenue growth rates.

Chart showing Microsoft's quarterly year-over-year revenue growth falling in 2022.

MSFT Revenue (Quarterly YoY Growth) data by YCharts

Currency dynamics also tempered Microsoft's operating income of $21.5 billion, a 15% year-over-year increase in constant currency terms but only a 6% rise compared to the year-ago period as reported. Microsoft's net income declined by 14% year over year as reported -- and 8% in constant currency terms -- to $17.6 billion.

Microsoft could remain vulnerable in the near term as the economy isn't out of the woods yet. Even if the economy gets worse, though, it's worth holding on to this company's stock.

The tech giant's products are invaluable to companies. That includes its productivity tools and its cloud offerings. Microsoft's cloud business through Azure looks particularly strong. In its Q1 2023, reported revenue from Microsoft Azure grew 35% year over year (42% in constant currency terms).

Microsoft is a leader in cloud computing. It's also the leader in computer operating systems and benefits from a strong brand name. The company has built a solid competitive edge, and some areas in which it does business still have plenty of room to grow. That is the case with cloud computing, an industry projected to grow at a compound annual rate of 15.7% through 2030.

Microsoft's business is solid and its prospects are bright, even with the headwinds it is encountering. On the dividend side, its yield of 1.15% may not seem impressive, but it is a solid dividend stock nonetheless. The company routinely raises its payouts, having increased them by 61.9% in the past five years. Microsoft's low cash payout ratio of 29% gives it plenty more room for further increases.

With a solid business behind it, Microsoft should continue rewarding shareholders with steady and growing dividends for many years.