We released 1.1 of the Azure Management Libraries for Java. This release adds support for:

Cosmos DB Azure Container Service and Registry Active Directory Graph

Getting started

Add the following dependency fragment to your Maven POM file to use 1.1 version of the libraries:

Create a Cosmos DB with DocumentDB API

You can create a Cosmos DB account by using a define() … create() method chain.

DocumentDBAccount documentDBAccount = azure.documentDBs().define("myDocumentDB")

In addition, you can:

Create an Azure Container Registry

You can create an Azure Container Registry by using a define() … create() method chain.

Registry azureRegistry = azure.containerRegistries().define("acrdemo")

You can get Azure Container Registry credentials by using listCredentials().

RegistryListCredentials acrCredentials = azureRegistry.listCredentials();

Create an Azure Container Service with Kubernetes Orchestration

You can create an Azure Container Service by using a define() … create() method chain.

ContainerService azureContainerService = azure.containerServices().define("myK8S")
      .withServicePrincipal(servicePrincipalClientId, servicePrincipalSecret)

You can instantiate a Kubernetes client using a community developed Kubernetes client library.

KubernetesClient kubernetesClient = new DefaultKubernetesClient(config);

Deploy from Container Registry to Kubernetes in Container Service

You can deploy an image from Azure Container Registry to a Kubernetes cluster using the same community developed Kubernetes client library and an image pull secret associated with the Container Registry.

ReplicationController rc = new ReplicationControllerBuilder()
          .addToLabels("acssample-nginx", "nginx")
                    .addToLabels("acssample-nginx", "nginx")

You can find the full sample code to deploy an image from container registry to Kubernetes in Container Service
Similarly, you can deploy an image from Azure Container Registry to Linux containers in App Service.

Create Service Principal with Subscription Access

You can create a service principal and assign it to a subscription with contributor role by using a define() … create() method chain.

ServicePrincipal servicePrincipal = authenticated.servicePrincipals().define("spName")
     // define credentials
     // define certificate credentials
           // export credentials to a file
           .withAuthFileToExport(new FileOutputStream(authFilePath))
     .withNewRoleInSubscription(role, subscriptionId)

Similarly, you can:

Try it

You can get more samples from Give it a try and let us know what do you think (via e-mail or comments below).

You can find plenty of additional info about Java on Azure at

  • Explore


    Let us know what you think of Azure and what you would like to see in the future.


    Provide feedback

  • Build your cloud computing and Azure skills with free courses by Microsoft Learn.


    Explore Azure learning

Join the conversation

Leave a Reply

Your email address will not be published. Required fields are marked *