You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Python Azure SDK获取支持Enhanced Networking及AVX-512的VM Size信息

How to Find Azure VM Sizes with Enhanced Networking and AVX-512 Support Using Python SDK

Got it, let's walk through how to solve this problem step by step. You're right that the virtual_machine_sizes.list() method only returns basic VM specs—it doesn't include the enhanced networking or AVX-512 details you need. The Resource SKUs API is exactly what you're looking for, and even in Azure SDK 4.0.0, you can access it through the same ComputeManagementClient you're already using.

Step 1: Use the resource_skus.list() Method

In Azure SDK 4.0.0, the ComputeManagementClient has a resource_skus property that lets you call list(). This method returns all resource SKUs (including VMs) with detailed capabilities, including the ones you're targeting.

Step 2: Filter and Extract Required Details

You'll need to narrow down the SKUs to only virtual machines in your target region, then check their capabilities for:

  • Enhanced Networking: Look for a capability named AcceleratedNetworkingEnabled with a value of True
  • AVX-512: Some SKUs explicitly list an AVX512Enabled capability, while others can be identified by their CPUFamily (e.g., Intel Xeon Platinum 8000-series processors support AVX-512)

Here's a working code example:

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient

# Initialize your Compute Management Client
# Replace these with your own Azure service principal details
credentials = ServicePrincipalCredentials(
    client_id="YOUR_CLIENT_ID",
    secret="YOUR_CLIENT_SECRET",
    tenant="YOUR_TENANT_ID"
)
compute_client = ComputeManagementClient(credentials, "YOUR_SUBSCRIPTION_ID")

# Define your target region
target_region = "eastus"

# Fetch all VM SKUs in the target region
sku_list = compute_client.resource_skus.list(
    filter=f"location eq '{target_region}' and resourceType eq 'virtualMachines'"
)

# Filter for VMs with both Enhanced Networking and AVX-512 support
qualified_vms = []
for sku in sku_list:
    has_enhanced_net = False
    supports_avx512 = False

    # Check each capability of the SKU
    for cap in sku.capabilities:
        # Check for Enhanced Networking
        if cap.name == "AcceleratedNetworkingEnabled" and cap.value == "True":
            has_enhanced_net = True
        # Check for explicit AVX-512 support
        if cap.name == "AVX512Enabled" and cap.value == "True":
            supports_avx512 = True
        # Fallback: Check CPU family (adjust based on known AVX-512 supported families)
        elif cap.name == "CPUFamily" and "Xeon Platinum" in cap.value:
            supports_avx512 = True

    # If both requirements are met, add to our list
    if has_enhanced_net and supports_avx512:
        # Extract key specs for clarity
        vcpus = next(c.value for c in sku.capabilities if c.name == "vCPUs")
        memory_gb = next(c.value for c in sku.capabilities if c.name == "MemoryGB")
        qualified_vms.append({
            "vm_size": sku.name,
            "vcpus": vcpus,
            "memory_gb": memory_gb,
            "enhanced_networking": has_enhanced_net,
            "avx512_supported": supports_avx512
        })

# Print the results
print("VM Sizes supporting both Enhanced Networking and AVX-512:")
for vm in qualified_vms:
    print(f"- {vm['vm_size']}: {vm['vcpus']} vCPUs, {vm['memory_gb']} GB RAM")

Key Notes:

  • Capability Names: Some older VM SKUs might use AcceleratedNetworking instead of AcceleratedNetworkingEnabled—if you don't get results, adjust the check to match the actual capability name returned by the API.
  • AVX-512 Detection: Not all SKUs list AVX512Enabled explicitly, so using the CPU family as a fallback helps capture those cases. You can expand the CPU family check to include other known AVX-512 supported processors like Xeon Scalable 3rd Gen.
  • SDK Version: While this works with Azure SDK 4.0.0, consider upgrading to the latest azure-mgmt-compute package (now a standalone library separate from the old azure metapackage). Newer versions have better API coverage and bug fixes.

内容的提问来源于stack exchange,提问作者Scott

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 19:42:38