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?
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.