How to retrieve vm by vmId, instead of resource id.

Songyeon Won 1 Reputation point

I am developing a program that retrieve vm information using java sdk.

i can retrieve vm by resource id as below,

but i don't know, how to retrieve vm by vm id(uuid).


TokenCredential tokenCredential = new EnvironmentCredentialBuilder()

AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

AzureResourceManager azureResourceManager = AzureResourceManager.configure()
                    .authenticate(tokenCredential, profile)

VirtualMachines virtualMachines = azureResourceManager.virtualMachines();

VirtualMachine vm = virtualMachines.getById("/subscriptions/*************/resourceGroups/*****/providers/Microsoft.Compute/virtualMachines/vm2");
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,372 questions
{count} votes