Walmart and Microsoft team up to fight Amazon

Walmart and Microsoft are joining forces in the fight against Amazon.

Under a five-year deal announced Tuesday, Walmart will boost its use of Microsoft's cloud services and work with the tech firm on artificial intelligence and machine learning projects.

The agreement will help both companies take on Amazon.

Walmart(WMT) 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(MSFT) competes with Amazon(AMZN). 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.

It has partnered with Macy's(M) 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(MAKSY) in the United Kingdom.