The agreement will help both companies take on Amazon.
Walmart has been pushing aggressively to transform its digital operations in order to compete with online rivals.
And cloud computing is one of the few areas where Microsoft competes with Amazon. While it's best known as an online retailer, Amazon also has a cloud service that racked up over $5 billion in sales in the first quarter.
Announced during the Amazon Prime Day sale, the deal will see Walmart shift a significant portion of walmart.com and samsclub.com to Azure, Microsoft's cloud business.
"Walmart was never going to partner with Amazon for obvious reasons and Microsoft is the second largest provider of cloud solutions in the world," said Dusan Milosavljevic, an analyst at Berenberg bank.
Walmart will also get access to artificial intelligence technology that could reduce energy consumption in its stores and machine learning expertise that would improve its delivery systems.
Last month, Walmart announced a new personal shopping service that lets customers order items via a text message with speedy delivery. It also launched new apps for back-to-school shopping.
Microsoft has been trying to convince retailers about the power of data and technology, working on everything from inventory to transport to online shopping.
It has partnered with Macy's to build a new "virtual shopping assistant" and with Mars Drinks to create smart vending machines. It's working with department store chain Marks & Spencer in the United Kingdom.