我知道您可以使用以下命令从 Azure CLI 启动/停止容器实例 az container stop --name mycontainer --resource-group myResourceGroupVM
但是因为在我的组织中 azure cli 给出了“访问被拒绝”错误,我想知道如何使用 powershell 或 ARM 来做同样的事情。我无法从文档中获取任何 powershell cmdlet 来启动或停止 conrainer 实例。请帮助。
还有谁能告诉我为什么我得到“访问被拒绝”。对于所有 az (CLI) 命令?
要使用较新的 Powershell“Az”模块执行此操作:
$cg = Get-AzContainerGroup -ResourceGroupName <yourResourceGroupName> -Name <yourContainerGroupName>
Invoke-AzResourceAction -ResourceId $cg.Id -Action start -Force
Action
参数可以是start
, stop
, restart
.
我从 Azure Resource Explorer 获得了这些可能的值:https://resources.azure.com/providers/Microsoft.ContainerInstance/operations