[英]Azure REST API: Stop a classic service
I'm trying to invoke Azure REST API from Powershell to start/stop a classic service.我正在尝试从 Powershell 调用 Azure REST API 来启动/停止经典服务。
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer $($token.Token)")
$headers.Add("Content-Type", "application/json")
$response = Invoke-RestMethod "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$rscGrp/providers/Microsoft.ClassicCompute/domainNames/$serviceName/slots/production/$action?api-version=2020-02-01" -Method 'POST' -Headers $headers
$response | ConvertTo-Json
When $action="start"
, the command works perfectly and the service starts all instances as required.当
$action="start"
时,该命令完美运行,服务根据需要启动所有实例。 However, when $action="stop"
, the command deletes the whole service all together.但是,当
$action="stop"
时,该命令会一起删除整个服务。 The whole deployment slot is deleted instead of simply stopping the instances.删除整个部署槽而不是简单地停止实例。 Basically, I want it to behave exactly like clicking on the "stop" button in Azure Portal.
基本上,我希望它的行为与单击 Azure 门户中的“停止”按钮完全一样。
You can use this Rest API , to Power off the cloud service.您可以使用此Rest API来关闭云服务。 Note that resources are still attached and you are getting charged for the resources
请注意,资源仍然附加,您需要为这些资源付费
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff?api-version=2021-03-01
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.