在Azure云中通过Powershell启用自动缩放设置

时间:2019-06-28 08:58:42

标签: powershell

我具有应创建的Powershell脚本并自动调整规则,并在特定的应用服务计划上启用了该脚本

$myRuleScaleOut = New-AzureRmAutoscaleRule -MetricName "Percentage CPU" -MetricResourceId "/subscriptions/$sub/resourceGroups/$RG/providers/Microsoft.Web/serverFarms/$FARM/webHostingPlan" -TimeGrain 00:01:00 -MetricStatistic "Average" -TimeWindow 00:05:00 -Operator "GreaterThan" -Threshold 70 -ScaleActionDirection "Increase" –ScaleActionScaleType "ChangeCount" -ScaleActionValue 3 -ScaleActionCooldown 00:05:00 

$myRuleScaleIn = New-AzureRmAutoscaleRule -MetricName "Percentage CPU" -MetricResourceId "/subscriptions/$sub/resourceGroups/$RG/providers/Microsoft.Web/serverFarms/$FARM/webHostingPlan" -Operator "LessThan" -MetricStatistic "Average" -Threshold 30 -TimeGrain 00:01:00 -TimeWindow 00:05:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection "Decrease" –ScaleActionScaleType "ChangeCount" -ScaleActionValue 1

$myScaleProfile = New-AzureRmAutoscaleProfile -DefaultCapacity 2 -MaximumCapacity 10 -MinimumCapacity 2 -Rule $myRuleScaleOut,$myRuleScaleIn -Name "autoprofile" 

$myLocation = "North Europe"

Add-AzureRmAutoscaleSetting -Location "North Europe" -Name "autosetting123" -ResourceGroup $RG -TargetResourceId "/subscriptions/$sub/resourceGroups/$RG/providers/Microsoft.Web/serverFarms/$FArm/webHostingPlan" -AutoscaleProfile $myScaleProfile 

但它返回此错误:

WARNING: 10:14:31 AM - *** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 10:14:31 AM - *** The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.
Add-AzureRmAutoscaleSetting : Exception type: ErrorResponseException, Message: Null/Empty, Code: Not Found, Status code:NotFound, Reason phrase: Not Found
At line:1 char:1
+ Add-AzureRmAutoscaleSetting -Location $myLocation -Name test -Resourc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzAutoscaleSetting], PSInvalidOperationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Autoscale.AddAzureRmAutoscaleSettingCommand

0 个答案:

没有答案