我正在尝试在使用 powershell 部署新服务器之前检查核心可用性。
我设法获取每个 vCPU 系列的当前核心限制和值,但 VM 大小没有列出其“系列”。
有没有什么方法可以有效地做到这一点?
答案1
有没有什么方法可以有效地做到这一点?
目前,不Azure PowerShell 命令列出 Azure VM 大小及其 VCPU 系列。
我们知道,我们可以使用此命令Get-AzureRmVMUsage
来获取限制:
PS C:\Users\Jason> Get-AzureRmVMUsage -Location eastus
Name Current Value Limit Unit
---- ------------- ----- ----
Availability Sets 0 2000 Count
Total Regional vCPUs 0 20 Count
Virtual Machines 0 10000 Count
Virtual Machine Scale Sets 0 2000 Count
Basic A Family vCPUs 0 20 Count
Standard A0-A7 Family vCPUs 0 20 Count
Standard A8-A11 Family vCPUs 0 20 Count
Standard D Family vCPUs 0 20 Count
Standard Dv2 Family vCPUs 0 20 Count
Standard G Family vCPUs 0 20 Count
Standard DS Family vCPUs 0 20 Count
Standard DSv2 Family vCPUs 0 20 Count
Standard GS Family vCPUs 0 20 Count
Standard F Family vCPUs 0 20 Count
Standard FS Family vCPUs 0 20 Count
Standard NV Family vCPUs 0 18 Count
Standard NC Family vCPUs 0 18 Count
Standard H Family vCPUs 0 8 Count
Standard Av2 Family vCPUs 0 20 Count
Standard LS Family vCPUs 0 20 Count
Standard Dv2 Promo Family vCPUs 0 20 Count
Standard DSv2 Promo Family vCPUs 0 20 Count
Standard MS Family vCPUs 0 0 Count
Standard Dv3 Family vCPUs 0 20 Count
Standard DSv3 Family vCPUs 0 20 Count
Standard Ev3 Family vCPUs 0 20 Count
Standard ESv3 Family vCPUs 0 20 Count
Standard B Family vCPUs 0 10 Count
Standard FSv2 Family vCPUs 0 20 Count
Standard ND Family vCPUs 0 0 Count
Standard NCv2 Family vCPUs 0 0 Count
Standard NCv3 Family vCPUs 0 0 Count
Standard LSv2 Family vCPUs 0 0 Count
Standard Storage Managed Disks 0 10000 Count
Premium Storage Managed Disks 0 10000 Count
我们可以使用此命令Get-AzureRmVMSize
获取有关 Azure VM 大小的详细信息:
我们可以使用 Azure VM 大小名称来查找大小系列。
笔记:
如果需要增加配额来购买单个订阅 RI,您可以请求增加配额在您的订阅中。
答案2
你可以用正则表达式构建自己的地图。像这样:
foreach ($location in @('EastUS')) {
Get-AzVmSize -Location $location | % {
New-Object -TypeName PSobject -Property @{
Name = $_.Name;
NumberOfCores = $_.NumberOfCores;
MemoryInMB = $_.MemoryInMB;
MaxDataDiskCount = $_.MaxDataDiskCount;
OSDiskSizeInMB = $_.OSDiskSizeInMB;
ResourceDiskSizeInMB = $_.ResourceDiskSizeInMB;
Family = $(switch -regex ($_.Name) {
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+m?r?$' {
'{0} {1} Family vCPUs' -f $matches[1], $matches[2];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+m?r?_Promo$' {
'{0} {1} Promo Family vCPUs' -f $matches[1], $matches[2];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+[lmt]?s$' {
'{0} {1}S Family vCPUs' -f $matches[1], $matches[2];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M|P)([BC])[0-9]+r?s$' {
'{0} {1}{2}S Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+(-(1|2|4|8|16|32|64))?m?s$' {
'{0} {1}S Family vCPUs' -f $matches[1], $matches[2];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)S[0-9]+$' {
'{0} {1}S Family vCPUs' -f $matches[1], $matches[2];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)1?[0-9]+m?_v([2-4])$' {
'{0} {1}v{2} Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)?[0-9]+_v([2-4])_Promo$' {
'{0} {1}v{2} Promo Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)1?[0-9]+_v([2-4])$' {
'{0} {1}v{2} Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)1?[0-9]+m?s_v([2-4])$' {
'{0} {1}Sv{2} Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+(-(1|2|4|8|16|32|64))?s_v([2-4])$' {
'{0} {1}Sv{2} Family vCPUs' -f $matches[1], $matches[2], $matches[5];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)S[0-9]+(-(1|2|4|8|16|32|64))?_v([2-4])$' {
'{0} {1}Sv{2} Family vCPUs' -f $matches[1], $matches[2], $matches[5];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+(-(1|2|4|8|16|32|64))?i_v([2-4])$' {
'{0} {1}Iv{2} Family vCPUs' -f $matches[1], $matches[2], $matches[5];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)[0-9]+(-(1|2|4|8|16|32|64))?is_v([2-4])$' {
'{0} {1}ISv{2} Family vCPUs' -f $matches[1], $matches[2], $matches[5];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)S[0-9]+_v([2-4])_Promo$' {
'{0} {1}Sv{2} Promo Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)1?[0-9]+a_v([2-4])$' {
'{0} {1}Av{2} Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^(Basic|Standard)_(A|B|D|E|F|H|L|M)1?[0-9]+as_v([2-4])$' {
'{0} {1}ASv{2} Family vCPUs' -f $matches[1], $matches[2], $matches[3];
break;
}
'^Standard_N([CV])[0-9]+r?$' {
'Standard N{0} Family vCPUs' -f $matches[1];
break;
}
'^Standard_N([CV])[0-9]+r?_Promo$' {
'Standard N{0} Promo Family vCPUs' -f $matches[1];
break;
}
'^Standard_N([DP])S[0-9]+$' {
'Standard N{0}S Family vCPUs' -f $matches[1];
break;
}
'^Standard_N([DP])[0-9]+r?s$' {
'Standard N{0}S Family vCPUs' -f $matches[1];
break;
}
'^Standard_N([CDV])[0-9]+r?s_v([2-4])$' {
'Standard N{0}Sv{1} Family vCPUs' -f $matches[1], $matches[2];
break;
}
default {
$null;
break;
}
})
}
} | Format-Table
}