How to get Azure Availability Zone provided region while creating Virtual Machine using .NET SDK

Muhammad Usman Khalil 1 Reputation point
2022-03-11T15:54:06.857+00:00

I am trying to get Availability Zone provided the region information using .NET SDK but I am not able to get the exact same information which I can see on Azure while creating virtual machine from portal.

Following call returning me huge list of array where most of the entries are empty but few of them having [1 2 3]. Moreover, it takes alot of time.( around 10-12 seconds to bring the data )

 var connection = GetAzConnection(subscriptionId);  
        List<string> ZoneInfo = new List<string>();  
        var skus = connection.ComputeSkus.ListbyRegionAndResourceType(Region.Create(regionName),ComputeResourceType.VirtualMachines);  
        foreach (IComputeSku sku in skus)  
        {                  
            var regionZones = sku.Zones;  
            ZoneInfo.Add(RegionZoneToString(regionZones));  
        }  

While I am expecting just [ 1 2 3 ] against 'WesternEurope' for example.

Any idea how to get that corresponding info?

For reference, following code snippet.

https://i.stack.imgur.com/StVw0.png

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,044 questions
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.