The coronavirus outbreak has driven the S&P 500 down 13% year to date. However, two top-quality stocks -- one tech and one retail -- have held up in the face of the coronavirus-induced sell-off.

Microsoft (MSFT -1.46%) and Costco (COST -0.57%) are two companies that have held their own thanks to the importance of the products and services they provide. The former's wide offering of cloud services and productivity software, and the latter's supply of household essentials remain in demand despite the economic fallout from the pandemic. As such, they seem to be well-positioned to ride out the turmoil.

Let's look at why you should consider these recession-resilient stocks for your portfolio.

1. Microsoft

Microsoft provides essential services and products to both individuals and companies. The global lockdowns have forced millions of people to work from home, leading to increased demand for the tech giant's offerings.

For example, its cloud services have seen increased demand due to telecommuting (Microsoft Teams), Windows virtual desktop, increased cloud usage, and gaming activity. Regarding its Teams App, management commented during the fiscal third-quarter earnings call:

We saw more than 200 million meeting participants in a single day this month, generating more than 4.1 billion meeting minutes. Teams now has more than 75 million daily active users, engaging in rich forms of communication and collaboration, and two-thirds of them shared, collaborated, or interacted with files on Teams. And the number of organizations integrating their third-party and line of business apps with Teams has tripled in the past two months.

The company also noted, "Usage of Windows Virtual Desktop tripled this quarter as organizations deploy virtual desktops and apps on Azure to enable secure remote work." In gaming, the quarter saw record engagement with close to 90 million active users of Xbox live. Microsoft also reported that it saw increased monetization of in-game content and services.

A Microsoft Teams video chat between four users

Image source: Microsoft.

Overall, the company reported a strong set of results in the quarter as revenue rose 15% year over year to $35.0 billion. Following suit, net income and earnings per share increased 22% and 23% to $10.8 billion and $1.40, respectively. Other things to like from the latest report are its solid balance sheet and free-cash-flow generation. On this note, Microsoft mentioned that it returned $9.9 billion to shareholders in the form of dividends and share repurchases, which was up 33% year over year.

Two areas to watch going forward are its Power Platform and Dynamic 365 offerings. Power Platform allows businesses to create apps that can be up and running in just a few hours or days, and it is currently used with 3.4 million developers. For Dynamic 365, management noted during the earnings call, "Dynamic 365 is helping thousands of organizations accelerate digital transformation as they remote every part of the operation, from manufacturing to supply chain management, to sales and customer service, inclusive of new scenarios like curbside pickup, contactless shopping, remote customer assistance and operations."

The pandemic will undoubtedly change the way individuals work and how businesses operate going forward. Both will only employ more technology in their day-to-day activities, and the current crisis is lifting demand for Microsoft's offerings.

2. Costco

Costco's large network of warehouse stores have provided customers with a one-stop shop for their household needs. For the fiscal 2020 second quarter, Costco reported net sales of $38.3 billion, up 10.5% year over year. Membership fees saw an uptick in the quarter coming in at $816 million, up from $768 million for the prior-year period.

The strong membership fees were driven by renewal rates above 88% for the U.S., Canada, and international markets. More specifically, Costco added a ton of new members, "At the end of the second quarter, we had 55.3 million member households, up about 600,000 from the 54.7 million 12 weeks earlier."

Not only did a household membership increase, but a strong uptick in executive memberships was also recorded. According to the latest earnings call, "At Q2 end, paid executive memberships stood at 21.7 million members, an increase of 321,000 during the 12 weeks."  

A woman pushing a shopping cart in a warehouse club

Image source: Getty Images

As the pandemic took hold, Costco reported that its March sales figures stood at $15.5 billion, which was 11.7% higher year over year. More pertinent was the fact that e-commerce sales in March saw a 48.3% jump, more than doubling the growth in the first two months of the year. The shift to e-commerce is no surprise given the stay-at-home orders that remain in effect across the country, and growth in that channel further accelerated to 85.7% in April.

Comparable sales across the company were down 4.7% in April as reductions to certain services such as the optical, hearing aid, and photo departments -- not to mention gasoline -- pulled total revenue 1.8% lower. While Costco has had to adapt to current market conditions, it has survived multiple recessions and come out on top. Looking back at the financial crisis of 2008 and 2009 recession, the warehouse retailer reported strong membership growth in both years.

Though investors should not expect explosive growth from these large, mature enterprises, their ability to thrive even in a pandemic and the accompanying recession offers patient investors plenty of long-term upside.