Closed eosho closed 5 years ago
Hi @Fumes007 Testing existence of a VM by his name, would be just do a "get" and catch any exception as meaning "does not exist". By tag, you must use the "azure-mgmt-resource" client, using the list ARM resources with a filter: https://docs.microsoft.com/en-us/python/api/azure-mgmt-resource/azure.mgmt.resource.resources.v2018_05_01.operations.resourcesoperations?view=azure-python#list
filter should look like (not tested, might need typo adjustements): tagname eq 'mytag' and resourceType eq 'Microsoft.Compute/virtualMachines'
Closing, answered and no activity.
I am not too versed with using Azure with python. I have searched online but can't find any resource to either query VMs using tags or using VM name, RG or ID to start/deallocate VMs. My main reason for wanting to using python was because the CLI folks told me python can handle wait periods to avoid Azure throttling.
Sample snippet