0
VirtualMachineGetResponse get(String resourceGroupName, String vmName) throws IOException, ServiceException, URISyntaxException;

From VirtualMachineGetResponse, I can get VirtualMachine. Is there any way to get VirtualMachine object by just giving instanceId as above code snippet expects resourceGroupName and instanceName?

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
Rishi Anand
  • 280
  • 1
  • 4
  • 15

2 Answers2

0

Judging by how ARM works, I don't think there is a way to do that at all (doesn't matter what language\tool you are using).

What you can do, is get the list off ALL vm's and filter the one you need.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
0

There is not any way to get VM object with only instance name in ARM for any languages. It's depended on Azure REST API Get for Virtual Machines in ARM, and the Java API just wrap it.

The REST API GET request for Virtual Machines in ARM, as below.

GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2016-03-30[&$expand]

Besides subscriptionId required for authentication, the parameters resourceGroupName & vmName are required in the api uri.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43