1
votes

When releasing the build in VSO, I would like to release it in a webapp staging slot. I'm using NewRelic, so I have to stop the staging environment, and set AlwaysOn option to false, before deployment, then put it on and start after deployment.

This is what I'm doing using Azure CLI task before the deployment task :

call azure webapp config set --slot staging Default-Web-WestEurope instanceName  --alwayson false
call azure webapp stop --slot staging Default-Web-WestEurope instanceName

It works well when I launch these commands on Azure CLI on my own desktop. But when I put this script on Azure CLI Task on VSO, it works... but on the production slot.

It's very annoying because it put the production down.

Do you know how to update WebApp slot configuration in VSO continuous integration ?

1
So you are saying that the azure cli command is not respecting the slot parameter when run from on the agent?Chris Patterson
@ChrisPatterson yep I guess this is a huge bug, but it's in preview so...Raph
@forester123 I didn't try Powershell task yet, I will with accepted answer !Raph
@Raph can you tell me which version of the azure cli you are using locally? I can't see how the task could cause this and I am curious to see if it is an issue with the version of the CLI installed on the build VM.Chris Patterson

1 Answers

1
votes

According to your description, I tested it on my side and I could reproduce this issue. You could add -vv option as follows to see more verbose output.

azure webapp stop --slot <slot name> <resource-group-name> <your-webapp-name> -vv

Here is the build log of Azure CLI task from my VSO:

Note: Since Azure CLI task is in preview. For a workaround, you could leverage Azure Powershell task to stop/start your web app slot and configure the AlwaysOn option as following steps:

1. Add the AZURE Powsershell task

2. Add the following powershell script and push it to your source repository

1) Stop web app slot by using Stop-AzureRmWebAppSlot

stop-azurermwebappslot -name "<webapp-name>" -slot "<webapp-slot-name>" -resourcegroupname "<resourcegroup-name>"

2) Configure AlwaysOn by using Set-AzureRmResource

Set-AzureRmResource -resourcename "<webapp-name>\slots\<webapp-slot-name>/web" -ResourceGroupName "<resourcegroup-name>" -ResourceType "Microsoft.Web/sites/config" -ApiVersion 2015-08-01 -propertyobject @{alwaysOn = $false;} -v -force

3. Configure your task

Then we could see the following build log:

Additionally, I found there is a similar issue about the options to stop/start web app during Azure Web App deployment, you could refer to it.