FedEx Corp. and Microsoft Corp. are teaming up to provide commercial shipping customers with early warnings of delays from weather, traffic and other mishaps, giving the courier and the software maker another weapon as each competes with Amazon.com Inc.

The service, using Microsoft’s cloud software, will give big and small companies real-time data to determine ways to improve how they move goods.

For example, a medical-device maker could find out from the new FedEx Surround service that a snowstorm threatens to delay the shipment of a heart-surgery kit to a hospital. Based on the package’s high priority, the shipment could be rerouted to make sure it arrives on time.

“A lot of insight, a lot of intelligence, hides in this data,” Raj Subramaniam, FedEx’s chief operating officer, said in an interview. “Our work together will dramatically improve our visibility and agility across the global supply chain.”

FedEx, which pioneered package scanning and tracking more than four decades ago, wants to attract commercial customers by providing tools that many companies can’t develop themselves. In part because commercial deliveries often involve more than one package, that business is more profitable than residential service.

FedEx Surround is the first fruit of a partnership between the two companies that may lead to other initiatives designed to help the courier position itself as a logistics alternative to Amazon for small and large retailers. Memphis, Tennessee-based FedEx and the online retailer had a falling out last year and canceled contracts for ground and express package deliveries.

For Microsoft, the collaboration could help narrow the gap with Amazon, which is the leader in the cloud-infrastructure market. The Redmond, Washington-based tech giant has been signing deals with large companies to use Microsoft’s cloud and artificial intelligence software to build programs that better automate, track and digitize key parts of a customer’s business.

“In these times, as businesses focus on remaining open and being competitive, having an efficient and capable supply chain is really critical,” said Judson Althoff, Microsoft’s chief of Worldwide Commercial Business.

Many of the software maker’s cloud customers also compete with Amazon in their businesses, and are loath to pay the retail behemoth for the technology they need to increase efficiency.

FedEx Surround won’t cost customers extra and will roll out broadly after a pilot program this summer. The service will use Microsoft’s Azure cloud services and artificial intelligence tools, as well as software that handles data from devices likes FedEx scanners and sensors.