0
votes

I'm using the latest java SDK for azure. When I fetch all VMs, I'm not getting VMs from the Virtual Machines (classic)

ServiceClientCredentials credentials = new ApplicationTokenCredentials(client, tenant, key, AzureEnvironment.AZURE);
Azure azure = Azure.authenticate(credentials).withSubscription(subscriptionId);

PagedList<VirtualMachine> vms = azure.virtualMachines().list();
1

1 Answers

0
votes

@ElroieRoash, Per my experience, according to the REST API List the resources in a subscription in ARM, I think the feasible way with ARM to list the classic VMs is that list all resources in the subscription and filter them with the resource type.

The resource type of classic virtual machine in ARM is Microsoft.ClassicCompute/virtualMachines.

So you just need to use the function list() of the class Subcriptions to list all resources and filter the resources which type is Microsoft.ClassicCompute/virtualMachines.

Meanwhile, I think the more clear way is that directly use the rest api with the parameter filter below. please refer to the section Common parameters and headers.

$filter=resourceType eq Microsoft.ClassicCompute/virtualMachines