빠른 시작: Java를 사용하여 가상 머신용 Azure Automanage 사용

Azure Automanage를 통해 사용자는 Azure 모범 사례를 가상 머신에 원활하게 적용할 수 있습니다. 이 빠른 시작 가이드는 azure-sdk-for-java 리포지토리를 사용하여 기존 가상 머신에 모범 사례 구성 프로필을 적용하는 데 도움이 됩니다.

필수 조건

참고 항목

평가판 계정은 이 자습서에서 사용되는 가상 머신에 액세스할 수 없습니다. 종량제 구독으로 업그레이드하세요.

중요

Automanage를 사용하도록 설정하려면 VM이 포함된 리소스 그룹에 대한 기여자 역할이 있어야 합니다. 구독에서 처음으로 Automanage를 사용하도록 설정하는 경우 다음 권한이 필요합니다. 구독에 대한 사용자 액세스 관리자 역할과 함께 소유자 역할 또는 기여자

필요한 종속성 추가

Azure IdentityAzure Automanage 종속성을 pom.xml에 추가합니다.

<!-- https://mvnrepository.com/artifact/com.azure/azure-identity -->
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-identity</artifactId>
    <version>1.6.0-beta.1</version>
    <scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.azure.resourcemanager/azure-resourcemanager-automanage -->
<dependency>
    <groupId>com.azure.resourcemanager</groupId>
    <artifactId>azure-resourcemanager-automanage</artifactId>
    <version>1.0.0-beta.1</version>
</dependency>

Azure에 인증하고 Automanage 클라이언트 만들기

Azure ID 패키지를 사용하여 Azure에 인증한 다음, Automanage 클라이언트를 만듭니다.

AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
TokenCredential credential = new DefaultAzureCredentialBuilder()
    .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
    .build();

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

기존 가상 머신에 대한 모범 사례 구성 프로필 사용

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

client
    .configurationProfileAssignments()
    .define("default") // name must be default
    .withExistingVirtualMachine("resourceGroupName", "vmName")
    .withProperties(
        new ConfigurationProfileAssignmentProperties()
            .withConfigurationProfile(configProfile))
    .create();

다음 단계

azure-sdk-for-java 리포지토리에서 Java Automanage 클라이언트로 더 많은 작업을 수행하는 방법을 알아봅니다.