如何在使用 .NET SDK 创建虚拟机时获取 Azure 可用区提供的区域

发布于 2025-01-13 06:59:44 字数 998 浏览 2 评论 0原文

我尝试使用 .NET SDK 获取可用区提供的区域信息,但无法获取与从门户创建虚拟机时在 Azure 上看到的完全相同的信息。

以下调用返回了巨大的数组列表,其中大多数条目都是空的,但其中很少有 [1 2 3]。此外,这需要很多时间。(大约需要 10-12 秒来获取数据)

        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));
        }

,例如,我只期望 [ 1 2 3 ] 针对“WesternEurope”。

知道如何获取相应的信息吗?

作为参考,以下代码片段。

输入图片此处描述

少数没有区域信息的区域可以收集。

输入图片此处描述

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.

enter image description here

Few regions where there are no zones information can be collected.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文