In 2012, Microsoft looked like it could crumble.

It posted its first quarterly loss in the company’s history, set against the background of a failing smartphone strategy and the rise of Apple’s iPhone and iPad line. The company’s $6.3 billion all-cash acquisition of advertising company aQuantive in 2007 had not turned around its Bing search engine’s five-year streak of losses, and the new iteration of its operating system, Windows 8, was widely maligned.

After 12 years under CEO Steve Ballmer, the software behemoth needed a reboot. It was still formidable, but when you stop being a growth story, you stop being a story people care about (see: IBM).

Six years later, the company is on a vastly different track. Investors are almost uniformly optimistic about the stock, and the company is reporting consistent double-digit revenue growth year over year.

The change? Satya Nadella. Analysts tell Quartz that the start of the CEO’s tenure in 2014 turned a new page for the company. It’s rooted in Nadella’s history at Microsoft, working his way up the corporate ladder over the course of 19 years to president of the company’s cloud business in 2011 (then called “Server and Tools” and now “Intelligent Cloud”) and ultimately to the top spot.

Next week (July 19) Microsoft will announce its quarterly earnings, and investors are already anticipating the company will beat expectations; the stock is at an all-time high of around $104 as of Friday (July 13).

Head in the cloud

Nadella was quick to make changes, taking the Azure cloud platform that Ballmer set up and putting it front and center at Microsoft. He allowed Linux, the open source operating systems once called “a cancer” by Ballmer, to be used on the Azure platform. Microsoft began rolling out Office products on iOS and Android in a meaningful way, and the company started launching hardware bets like the Surface and augmented reality device HoloLens.

“What Microsoft really did right was pivot towards this cloud-first, mobile-first approach, behind new leadership. Satya came in and was the spark, the primary catalyst to contribute to the stock almost doubling in the last few years,” Brent Bracelin, an analyst at KeyBanc Capital Markets, told Quartz.

Nadella’s cloud experience is key to Microsoft’s future—analysts see this as a nascent market where big tech companies can use existing data centers to make billions.

Bracelin says the industry’s biggest cloud players, such as Amazon, Microsoft, and Google, have only captured about 12% of the market spend so far, leaving tons of room for growth. And the numbers back that up: Azure and AWS have consistently grown 45-90% year over year in recent quarters.

The cloud also keeps customers paying for the services used on Microsoft’s servers, another pillar of the company’s recent success.

Money in the long term

Microsoft has long locked in enterprise customers with licensing agreements and small businesses with subscriptions, but consumer products like Office 365 and personal cloud OneDrive have only switched to subscription models under Nadella. Earlier this year, it reported nearly 30 million subscribers pay for Office 365 annually.

The company pitches this as a win-win for itself and consumers. Microsoft gets to keep customers in its ecosystem year after year, with the potential to up-sell them more storage as they use Word, Excel, and PowerPoint more. Meanwhile, rather than shelling out a large sum every few years for software, customers pay smaller amounts regularly but always have access to the latest software.

Add this growth in subscriptions and cloud services to LinkedIn (where revenue was up 37% last quarter from a year earlier) and Bing, which has been growing at least 10% year over year over the last four quarters, and KeyBank projects that these new revenue streams will account for 45% of Microsoft’s total revenue by 2020, up from 16% in 2016.

More games, more money

With all the focus on productivity, it can be easy to forget that Microsoft also makes the Xbox, a device designed for the opposite. The company’s gaming revenue rose 18% year over year last quarter to $2.25 billion.

Like Microsoft’s other businesses, Xbox executives are focusing on how to keep gamers paying monthly or annually.

“Microsoft is changing the way it monetizes its gaming segment by pivoting towards subscription based services, similar to the shift we have seen towards Office 365,” Barclays analyst Raimo Lenschow wrote in a note last month.

Microsoft has long sold Xbox Live as a subscription to connect your machine to the internet and play online with friends (or strangers). But in June 2017 it announced a new subscription called Game Pass: For $10 a month, subscribers can download and play hundreds of games, rather than having to buy each game individually, kind of like the model used by Spotify and Netflix.

Cultural shift

Brad Reback, an analyst at Stifel Nicolaus, stresses that the change at Microsoft isn’t just new revenue models.

“The cultural change is something not to underestimate, the openness of the organization, and the willingness to embrace all sorts of non-Microsoft technologies,” Reback says.

The change can be seen in the fact that Minecraft, Nadella’s $2.5 billion acquisition, still runs on iPads and Mac computers. It’s seen in Office 365 being platform agnostic, and Linux on Azure. In other words, the company no longer lives or dies on the success of the latest Windows release.

Even Microsoft’s $7.5 billion acquisition of GitHub, perhaps the most central place on the internet for programmers to share and distribute code, would have been unthinkable under Ballmer—unless the plan was to try and force every developer into writing the C++ language.

But Nadella’s emphasis on subscription business tools and the cloud means that’s how his performance will be graded.

“Commercial cloud is Office 365, Azure, and Dynamics 365. That’s how [Wall Street] has measured Satya’s performance, that ability for him to transform Microsoft from a legacy client-server company into a cloud leader,” Bracelin said.