azurepowershellazure-resource-managerazure-powershellazure-virtual-machine

Azure PowerShell command to list all Azure VM SKU Sizes enabled for Confidential Computing


Get-AzVMSize -Location "West US"

The command above returns a list of all Azure VM SKU sizes in this format.

Name                      NumberOfCores MemoryInMB MaxDataDiskCount OSDiskSizeInMB ResourceDiskSizeInMB
----                      ------------- ---------- ---------------- -------------- --------------------
Standard_L8as_v3                      8      65536               16        1047552                81920
Standard_L16as_v3                    16     131072               32        1047552               163840
Standard_L32as_v3                    32     262144               32        1047552               327680
Standard_L48as_v3                    48     393216               32        1047552               491520
Standard_L64as_v3                    64     524288               32        1047552               655360

Is there an Azure PowerShell command, C# SDK API or REST API call that can give me a list of all available SKUs that are enabled for confidential computing? There is some document list, but I would like a way to pull this programmatically. I do not see a documented way so far to this in PowerShell either, any suggestions?


Solution

  • The Azure management API has an endpoint that allows you to list resource skus.

    https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Compute/skus?api-version=2021-07-01&$filter=location eq 'westus'
    

    The response contains skus for all types of compute resources, including virtual machines (filtering by region is recommended as the response will otherwise be close to 60MB).

    The capabilities array contains detailed information on what the sku can be used for. You can filter the response using Powershell.

    $apiResponse = Invoke-WebRequest -Method Get `
        -Uri "https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Compute/skus?api-version=2021-07-01&`$filter=location eq 'westus'" `
        -Headers @{
            "Authorization" = "Bearer $($accessToken)"
            "Content-Type" = "application/json"
        }
    
    ($apiResponse.Content | ConvertFrom-Json -Depth 99).value | Where-Object {
        $_.ResourceType -eq "VirtualMachines" -and
        $_.Capabilities.Name -contains "ConfidentialComputingType"
    } | Select-Object Name, Tier, Family, Size, @{ 
        Name = "ConfidentialComputingType"; 
        Expression = { ($_.capabilities | Where-Object {$_.Name -contains "ConfidentialComputingType"}).value -join "," } 
    } | Format-Table
    

    This will output a table containing the VM sizes and the confidential compute type.

    Name                 Tier     Family                 Size        ConfidentialComputingType
    ----                 ----     ------                 ----        -------------------------
    Standard_DC16ads_v5  Standard standardDCADSv5Family  DC16ads_v5  SNP
    Standard_DC16as_v5   Standard standardDCASv5Family   DC16as_v5   SNP
    Standard_DC2ads_v5   Standard standardDCADSv5Family  DC2ads_v5   SNP
    Standard_DC2as_v5    Standard standardDCASv5Family   DC2as_v5    SNP
    ... more results