Skip to content

Instantly share code, notes, and snippets.

@ehashman
Created August 19, 2020 18:19
Show Gist options
  • Save ehashman/bccd02e90416e7fde4589a2b3feb979b to your computer and use it in GitHub Desktop.
Save ehashman/bccd02e90416e7fde4589a2b3feb979b to your computer and use it in GitHub Desktop.
Get capacity information about Azure VM SKUs from CLI dump.
import json
import pprint
SUPPORTED_SKUS = [
"Standard_D16as_v4",
"Standard_D16s_v3",
"Standard_D2s_v3",
"Standard_D32as_v4",
"Standard_D32s_v3",
"Standard_D4as_v4",
"Standard_D4s_v3",
"Standard_D8as_v4",
"Standard_D8s_v3",
"Standard_E16s_v3",
"Standard_E32s_v3",
"Standard_E4s_v3",
"Standard_E8s_v3",
"Standard_F16s_v2",
"Standard_F32s_v2",
"Standard_F4s_v2",
"Standard_F8s_v2"
]
def main():
"""Get capacity information about Azure VM SKUs from CLI dump.
Usage:
az vm list-skus > skus
python3 sku_specs.py
"""
skus = json.load(open('skus', 'r'))
specs = {}
for sku in skus:
if sku['name'] not in SUPPORTED_SKUS:
continue
specs[sku['name']] = {'vCPUs': 0, 'MemGB': 0}
for c in sku['capabilities']:
if c['name'] == 'vCPUs':
specs[sku['name']]['vCPUs'] = c['value']
elif c['name'] == 'MemoryGB':
specs[sku['name']]['MemGB'] = c['value']
pprint.pprint(specs)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment