In April 2020, the Azure SDK for Java team released its first Azure client SDK Bill of Materials (BOM). This BOM file includes all Generally Available (GA) Azure SDK for Java client packages with their compatible dependency version. Using the BOM file eases dependency version management for customers. However, customers also indicated the slower release cadence hindered its adoption.
Beginning in September of 2021, the Azure client SDK BOM has been released monthly. You can depend on the latest features of Azure SDK client libraries with BOM.
Include Azure SDK client library in your project using BOM
The Azure SDK for Java supports each Azure service through one or more Maven packages. To include the Java client library for an Azure service:
- Add the following snippet in your project’s pom.xml file:
<dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-sdk-bom</artifactId> <version>{bom_version_to_target}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>{artifactId}</artifactId> </dependency> <dependency> <groupId>com.azure</groupId> <artifactId>{artifactId}</artifactId> </dependency> </dependencies>
- Replace the
{bom_version_to_target}
placeholder with the BOM version number to target. - Replace
{artifactId}
with the Azure service’s client library package name.
All releases of the Azure SDK for Java client BOM can be found here. Including the BOM in your project ensures Maven picks the library versions specified in it for all Azure client SDKs in your project. To upgrade to a newer version of the Azure SDK for Java client libraries, update the azure-sdk-bom
version, which is released monthly.
Why to use dependency versions in the BOM
Consider the following dependency section from a pom.xml file:
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-servicebus</artifactId>
<version>7.4.2</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs</artifactId>
<version>5.10.1</version>
</dependency>
</dependencies>
These dependencies introduce multiple versions of azure-core
and azure-core-amqp
in the dependency tree. The multiple versions can cause unexpected issues for your app at compile time or runtime.
To ensure Maven retrieves the correct version of each of the dependencies, specify your dependencies as follows:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-sdk-bom</artifactId>
<version>1.0.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Then include the direct dependency in the dependencies
section without the version tag.
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-servicebus</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs</artifactId>
</dependency>
</dependencies>
The Maven version for each of these libraries will be resolved to the version specified in the BOM. The dependency resolution for this pom.xml file is as follows.
As you can see, all Azure SDK Java packages are now resolved to a single version with no conflicts.
Azure SDK Blog Contributions
Thanks for reading this Azure SDK blog post. We hope you learned something new, and we welcome you to share the post. We’re open to Azure SDK blog contributions from our readers. To get started, contact us at azsdkblog@microsoft.com with your idea, and we’ll set you up as a guest blogger.
- Azure SDK Website: aka.ms/azsdk
- Azure SDK Intro (3-minute video): aka.ms/azsdk/intro
- Azure SDK Intro Deck (PowerPoint deck): aka.ms/azsdk/intro/deck
- Azure SDK Releases: aka.ms/azsdk/releases
- Azure SDK Blog: aka.ms/azsdk/blog
- Azure SDK Twitter: twitter.com/AzureSDK
- Azure SDK Design Guidelines: aka.ms/azsdk/guide
- Azure SDKs & Tools: azure.microsoft.com/downloads
- Azure SDK Central Repository: github.com/azure/azure-sdk
- Azure SDK for .NET: github.com/azure/azure-sdk-for-net
- Azure SDK for Java: github.com/azure/azure-sdk-for-java
- Azure SDK for Python: github.com/azure/azure-sdk-for-python
- Azure SDK for JavaScript/TypeScript: github.com/azure/azure-sdk-for-js
- Azure SDK for Android: github.com/Azure/azure-sdk-for-android
- Azure SDK for iOS: github.com/Azure/azure-sdk-for-ios
- Azure SDK for Go: github.com/Azure/azure-sdk-for-go
- Azure SDK for C: github.com/Azure/azure-sdk-for-c
- Azure SDK for C++: github.com/Azure/azure-sdk-for-cpp
0 comments