Anyone know how to get zone info using the Python SDK? I found this technet post that shows you how to dump supported machine types by zone using powershell, and the Azure command line tools equivalent seems to be as follows:
user@server:~$ az vm list-skus -l southeastasia --zone | wc -l
12350
user@server:~$ az vm list-skus -l southeastasia --zone | head -n 120 | grep family -A 18
"family": "standardNVFamily",
"kind": null,
"locationInfo": [
{
"location": "southeastasia",
"zoneDetails": [],
"zones": [
"3"
]
}
],
"locations": [
"southeastasia"
],
"name": "Standard_NV6",
"resourceType": "virtualMachines",
"restrictions": [],
"size": "NV6",
"tier": "Standard"
user@server:~$
But I haven't found the right SDK method yet after trawling through the docs for quite a while.
compute_client.virtual_machine_images.list_skus() does not return zone info, just image e.g.
{
'additional_properties': {
'properties': {
'automaticOSUpgradeProperties': {
'automaticOSUpgradeSupported': False
}
}
},
'id': '/Subscriptions/f03687b3-57b3-43c9-9734-6fb36e0de268/Providers/Microsoft.Compute/Locations/southeastasia/Publishers/Debian/ArtifactTypes/VMImage/Offers/debian-10/Skus/10-backports',
'name': '10-backports',
'location': 'southeastasia',
'tags': None
}
This is super easy using the AWS SDK:
boto3.client('ec2').describe_availability_zones()
results=compute_client.resource_skus.list()
. For more details, please refer to docs.microsoft.com/en-us/python/api/azure-mgmt-compute/… – Jim Xuif(result.resource_type=='virtualMachines' and result.locations[0].lower() == result.location_info[0].location.lower() ):
result.location_info[0].location is always equal to result.locations[0] anyway so no need to filer. I am also usinglen(result.location_info[0].zones) > 0
to get redundant regions, andresult.location_info[0].location.lower().endswith('euap')
to filter Early Updates Access Program images if anyone is interested. – woOt