如何通过Get-AzureRmAppServicePlan检索workerSize

时间:2017-07-05 12:32:05

标签: powershell azure

通过Azure PowerShell cmdlet New-AzureRmAppServicePlan创建新的AppServicePlan时,我需要添加WorkerSize,例如Small,Medium或Large。例如:

$appServicePlanSettings = @{
    Name = "testingServicePlan";
    Location = "westeurope";
    Tier = "Basic";        
    ResourceGroupName = "testingResourceGroup";
    NumberofWorkers = 1;
    WorkerSize = "Medium";
}

New-AzureRmAppServicePlan @appServicePlanSettings

但是,当我通过Get-AzureRmAppServicePlan检索此相同的AppServicePlan时,我无法找到此信息。相反,我遇到了Sku属性,其中包含Size属性,例如值为B2,表示WorkerSize为中等。例如:

> $plan = Get-AzureRmAppServicePlan -Name "testingServicePlan" -ResourceGroupName "testingResourceGroup"
> $plan.Sku
Name     : B2
Tier     : Basic
Size     : B2
Family   : B
Capacity : 1

如果我希望能够比较等效值,我是否应该在例如HashList中跟踪这些转换,或者我是否有其他方式来检索' Medium'?我可能错过了一些东西,但无法找到这些信息。

根据PowerShell的GetType()方法,返回的对象是ServerFarmWithRichSku,其基本类型为Microsoft.Azure.Management.WebSites.Models.Resource,但此对象的文档对我来说有点缺乏进一步

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.websites.models.resource?view=azuremgmtwebsites-1.6.0-preview

3 个答案:

答案 0 :(得分:2)

我在我的实验室进行测试,$plan.Sku.size的值为WorkerSize。以下是结果。

SMALL
Name     : B1
Tier     : Basic
Size     : B1
Family   : B
Capacity : 1

Medium
Name     : B2
Tier     : Basic
Size     : B2
Family   : B
Capacity : 1

Large
Name     : B3
Tier     : Basic
Size     : B3
Family   : B
Capacity : 1

我同意Sridharan,但你最好使用如下脚本:

$hash = @{}
$hash['B1'] = "Small"
$hash['B2'] = "Medium"
$hash['B3'] = "Large"
$hash['B4'] = "Extra Large"

$plan = Get-AzureRmAppServicePlan -Name "testingServicePlan" -ResourceGroupName "testingResourceGroup"
$val=$plan.Sku.Size
echo $hash[$val]

答案 1 :(得分:1)

我认为最好的方法是使用哈希地图。

但你可以使用" Family"来自" Sku"过来所有B1,B2,M1,M2etc。,

>$hash = @{}
>$hash['S'] = "Small"
>$hash['M'] = "Medium"
>$hash['L'] = "Large"
>$hash['EL'] = "Extra Large"

>$plan = Get-AzureRmAppServicePlan -Name "testingServicePlan" -ResourceGroupName "testingResourceGroup"
> $val=$plan.Sku.Fmaily
>echo $hash[$val]

答案 2 :(得分:0)

对于necroposting很抱歉,但我希望以自己的方式提出,适合各种规模(从Free到Premium)。

$webAppHashSizes = @{}
$webAppHashSizes['1'] = "Small"
$webAppHashSizes['2'] = "Medium"
$webAppHashSizes['3'] = "Large"
$webAppHashSizes['4'] = "Extra Large"
$plan = Get-AzureRmAppServicePlan -Name "testingServicePlan" -ResourceGroupName "testingResourceGroup"
echo $webAppHash[$plan.Sku.size.Substring(1,1)]
相关问题