0

Given an Azure VM size as string (e.g. "STANDARD_A4_v2") I would like to programmatically infer available memory and number of vCPUs. I've looked through azure-mgmt-compute but can't find what I'm looking for. I saw this post using a ComputeManagementClient to iterate over all available VM sizes, but that's not what I need and furthermore in my case I only have access to Azure Batch credentials. Do I have to role my own (at least for vCPUs) following the naming conventions?

Many thanks,

Andreas

2 Answers 2

1

The issue that you have seen is what you need. The virtual_machine_sizes only have one function and it's the list. So you need to find your real VM size in the list. For example:

compute_client = CompteManagementClient(credentials, subscription_id)
vmSizes = compute_client.virtual_machine_sizes.list(location)
for vmSize in vmSizes:
  if(vmSize.name == "STANDARD_A4_v2")
    print("number of vCPU: " + vmSize.number_of_cores)
    print("available memory: " + vmSize.memory_in_mb)

And naming conventions are the rules that how does Azure define the VM size. You just need to read it to understand the VM size.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks Charles. I saw that logic in the post I linked. However in my case, I only have Azure Batch credentials, so I can't even initialize a CompteManagementClient(). Sure, I can parse the number of cores just from the name, but unfortunately I can't do that for memory size. Any idea idea how else to get that list (without subscription id etc.)?
@Andreas Can you share your credential for Azure Batch? Which role do you have? You can only find the sizes in the document without a subscription, not in code.
Thanks Charles. That answers it I guess.
@Andreas OK, if it works for you please accept it as the answer.
Hi Charles, I'll accept this answer. The only caveat is that you can't achieve the above just with just Batch credentials, if I understood correctly.
|
0

You should be able to use Azure command line and get the result directly e.g. az vm List-sizes -l AustraliaEast

this gives me following result

Screenshot of output

Document you can refer to -- https://learn.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az-vm-list-sizes

Note you need to login using 'Az login' first before you can execute the above command

1 Comment

Thanks. In my case I need to do this from within a Python environment, which only holds Azure Batch credentials

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.