Meghal Vasa
Meghal Vasa

Reputation: 41

How to start stop azure container instance using Powershell command or ARM command

I know you can start / stop container instance from Azure CLI using the command az container stop --name mycontainer --resource-group myResourceGroupVM

but since in my org Azure cli gives "Access is denied" error I want to know how to do same using powershell or ARM. I am unable to get any powershell cmdlet to start or stop conrainer instance from documentation.

I referred below documentation for same: https://learn.microsoft.com/en-us/powershell/module/azurerm.containerinstance/?view=azurermps-6.9.0#container_instances

Also could anyone tell me why I get "Access is denied." for all az (CLI ) commands?

Upvotes: 4

Views: 2981

Answers (3)

Grzegorz
Grzegorz

Reputation: 1

You can do Start-AzContainerGroup now.

Here's the documentation.

Upvotes: 0

Andrew Shepherd
Andrew Shepherd

Reputation: 45272

To perform this action using the newer Powershell 'Az' modules:

$cg = Get-AzContainerGroup -ResourceGroupName <yourResourceGroupName> -Name <yourContainerGroupName>

Invoke-AzResourceAction -ResourceId $cg.Id -Action start -Force

The Action parameter can be start, stop, restart.

I got those possible values from the Azure Resource Explorer: https://resources.azure.com/providers/Microsoft.ContainerInstance/operations

Upvotes: 3

Charles Xu
Charles Xu

Reputation: 31452

You can use the PowerShell cmdlet to stop the ACI and the cmdlet will like this:

Invoke-AzureRmResourceAction -ResourceGroupName yourResourceGroup -ResourceName yourContainerGroup -Action Stop -ResourceType Microsoft.ContainerInstance/containerGroups

The result of the PowerShell cmdlet like this:

enter image description here

Also, it shows the state on the Azure Portal:

enter image description here

Upvotes: 6

Related Questions