Microsoft CEO Satya Nadella speaks at an Economic Club of New York event in New York on Feb. 7, 2018.

Amazon is the e-commerce giant, a behemoth in cloud computing and an aspiring player in the pharmacy business. Across those industries, Amazon is scaring everyone, forcing them to partner up to defend themselves.

The latest deal was announced on Tuesday, when drug store chain Walgreens said it's teaming up with Microsoft for a seven-year agreement that includes exploring digital health opportunities within stores and developing software for managing patient engagement.

Last month, Walgreens inked a deal with Verily, Alphabet's life sciences company, to work on projects related to helping people take their medicines.

Walgreens and other pharmacy companies are paying particularly close attention to Amazon after it bought online pharmacy PillPack in June for $1 billion. The acquisition came after Amazon had already eaten into sales of household items like paper towels and shampoo, which consumers traditionally bought in local retail stores, often while picking up a prescription.

While Amazon shares have climbed 28 percent in the past year, Walgreens is down 5.6 percent and CVS has plunged 19 percent. Both pharmacy companies have started redesigning stores to add more health services in hopes of driving traffic to their physical locations. When it comes to the online experience, they need the expertise of technology companies, which have learned how to acquire customers and keep them engaged and loyal.

Under the new deal with Microsoft, Walgreens is signing up more than 380,000 employees for its Microsoft 365 cloud apps offering and will move most of its information technology workloads to the Azure public cloud.

Stephen Buck, a drug supply chain expert, said it's a notable development. Back in June, after the PillPack deal, Walgreens CEO Stefano Pessina said he was "not particularly worried" about Amazon.

"This partnership with Microsoft suggests otherwise," Buck said.