我正在尝试从 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
当 时$action="start"
,该命令完美运行,服务根据需要启动所有实例。但是,当 时$action="stop"
,该命令会一起删除整个服务。整个部署槽被删除,而不是简单地停止实例。基本上,我希望它的行为与单击 Azure 门户中的“停止”按钮完全一样。