azureazure-functionsazure-cliazure-cli2

How to stop a functionapp in a slot using azure CLI


I would like to issue a command using Azure CLI that stops a functions app in a particular deployment slot only.

The Azure CLI 2.0 documentation Azure CLI 2.0 documentation lists the command:

az functionapp stop --name
                    --resource-group

But it is not clear to me how to stop not the "main" app, but the app in a particular deployment slot.

In my case the slot is called dev and the app is called myapp. I've tried:

az functionapp stop --name=dev --resource-group=myresourcegroup
The Resource 'Microsoft.Web/sites/dev' under resource group myresourcegroup' was not found.

az functionapp stop --name=myapp/dev --resource-group=myresourcegroup
az functionapp stop --name='myapp/dev' --resource-group=myresourcegroup
Operation failed with status: 'Not Found'. Details: 404 Client Error: Not Found for url: https://management.azure.com/subscriptions/long-guid/resourceGroups/myresourcegroup/providers/Microsoft.Web/sites/myapp%2Fdev/start?api-version=2016-08-01

I'm able to stop the main app no problem. And when I issue the command to stop the main app, the app in the deployment slot does not stop (as I can see by checking in the portal GUI).

So, how can I stop the app in the deployment slot from the command line?


Solution

  • You could use az resource invoke-action --action stop --ids to stop funtion app slot

    For example:

    az resource invoke-action --action stop --ids  /subscriptions/*********/resourceGroups/shuiResourceGroup/providers/Microsoft.Web/sites/shuiFunctionApp/slots/shuiSlot