Quickstart: Enable Azure Automanage for virtual machines using Java

Azure Automanage allows users to seamlessly apply Azure best practices to their virtual machines. This quickstart guide will help you apply a Best Practices Configuration profile to an existing virtual machine using the azure-sdk-for-java repo.



Free trial accounts do not have access to the virtual machines used in this tutorial. Please upgrade to a Pay-As-You-go subscription.


You need to have the Contributor role on the resource group containing your VMs to enable Automanage. If you are enabling Automanage for the first time on a subscription, you need the following permissions: Owner role or Contributor along with User Access Administrator roles on your subscription.

Add required dependencies

Add the Azure Identity and Azure Automanage dependencies to the pom.xml.

<!-- https://mvnrepository.com/artifact/com.azure/azure-identity -->

<!-- https://mvnrepository.com/artifact/com.azure.resourcemanager/azure-resourcemanager-automanage -->

Authenticate to Azure and create an Automanage client

Use the Azure Identity package to authenticate to Azure and then create an Automanage Client:

AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
TokenCredential credential = new DefaultAzureCredentialBuilder()

AutomanageManager client = AutomanageManager
    .authenticate(credential, profile);

Enable best practices configuration profile to an existing virtual machine

String configProfile = "/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction";

    .define("default") // name must be default
    .withExistingVirtualMachine("resourceGroupName", "vmName")
        new ConfigurationProfileAssignmentProperties()

Next steps

Learn how to conduct more operations with the Java Automanage Client by visiting the azure-sdk-for-java repo.