如何使用 Powershell 命令或 ARM 命令启动停止 azure 容器实例

Meg*_*asa 4 containers instance azure

我知道您可以使用以下命令从 Azure CLI 启动/停止容器实例 az container stop --name mycontainer --resource-group myResourceGroupVM

但是由于在我的 org azure cli 中出现“访问被拒绝”错误,我想知道如何使用 powershell 或 ARM 来做同样的事情。我无法从文档中获取任何 powershell cmdlet 来启动或停止 conrainer 实例。请帮忙。

我参考了以下文档:https : //docs.microsoft.com/en-us/powershell/module/azurerm.containerinstance/?view=azurermps-6.9.0#container_instances

也有人能告诉我为什么我得到“访问被拒绝”。对于所有 az (CLI) 命令?

Cha*_* Xu 6

您可以使用 PowerShell cmdlet 停止 ACI,该 cmdlet 将如下所示:

Invoke-AzureRmResourceAction -ResourceGroupName yourResourceGroup -ResourceName yourContainerGroup -Action Stop -ResourceType Microsoft.ContainerInstance/containerGroups
Run Code Online (Sandbox Code Playgroud)

PowerShell cmdlet 的结果如下:

在此处输入图片说明

此外,它还显示 Azure 门户上的状态:

在此处输入图片说明