简体   繁体   English

Azure REST API:停止经典服务

[英]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.

相关问题 Azure REST Api 500 在 virtual.network 中创建应用服务槽时出现内部服务器错误 - Azure REST Api 500 Internal Server Error when creating a app service slot in a virtual network Azure云服务经典版如何增加磁盘存储 - How to increase disk storage in Azure Cloud Service classic Azure 通过 Rest API 或 python 模块(MS Graph)按名称或 email 地址搜索用户、组或服务原则? - Azure search for user, groups, or service principle by name or email address via Rest API or python module (MS Graph)? Azure 开发运营 REST API 发送邮件 - Azure Devops REST API SendMail 当Azure App Service停止时,Azure Webjob是否停止 - Does Azure Webjob stop when Azure App Service is stopped 如何停止 Azure 事件中心服务? - How to stop Azure Event Hubs service? Azure 逻辑应用触发 REST API Azure API 管理 - Azure Logic App trigger a REST API in Azure API Manegement 使用 rest api 将笔记本部署到 azure devops - deploy notebooks to azure devops using rest api Rest API 对于 Azure devops 日历不工作 - Rest API for Azure devops calendar not working AWS 中的哪个服务有一个 api 来安排调用 REST api? - What service in AWS has an api to schedule calling a REST api?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM