简体   繁体   中英

How to find the status of an Azure v2 VM via rest / powershell ARM

I have just converted some existing VMs to v2 (Resource Manager) VMs, and subsequently updating scripts etc.

I have this line to find out the status (stopped / running / starting) of machines.

            string URL = string.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualmachines/{2}?api-version=2015-05-01-preview",
            SubscriptionID,
            ResourceGroup,
            ComputerName
            );

In the classiccompute model I would get some json that I could parse to find status. Now however all I get is json object describing my machine. (size, attached disks etc)

No problem I thought! there's going to be an earlier version of the API that gives what I'm looking for I found a versioning document that talks about the service management versions but I can't find anything about the ARM versioning.

No problem I thought, I'll see what Powershell does. Alas it seems to read the same API, and give the same information. (and obviously service management mode no longer sees my VM)

From what I've seen in the last hour of poking around this, there's no way of checking the status of a v2 VM. I imagine I'm missing something that is getting lost in the sea of V1 google results.

How do I find out if my v2 VM is running? (bonus points for a document that covers the ARM api versions!)

After some further digging around! it appears the answer is to append /instanceview to the URI which will give the state of all of the attached resources.

For powershell there is the -status parameter for Get-AzureVM which will give the same json resource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM