1

Short version: How can I deploy a new version without first manually stopping the app-service?

Long version: I'm using the following workflow to publish a new version of my ASP.NET Core app to an Azure App-Service.

The App-Service is running on a basic instance. I understand this is not intended for real use but I hope there is a good way to get this workflow running before we go into production(standard instance).

This works but how can I avoid step 4 to 7?

  1. Publish the solution into a local folder.
  2. Move the published content into a local git repo.
  3. Commit all files and push to the app-service.
  4. Stop the app-service from the portal
  5. Enter the console and delete all files in the wwwroot folder
  6. Redeploy the commit from the portal
  7. Start the app-service

I was hoping that the push in step 3 would automatically trigger the remaining steps. After step 3 I can see that the files have been updated, the new static files are served to the browser but the old binary is still running.

Similarly I can switch between deployment slots on the portal. I get the new static files served but the previous deployed binary is still answering all calls.

This doesn't work, the static files are changed but the old binary is still responding to calls.

  1. Redeploy from portal
  2. Restart app-service

The old binary is still served.

This works.

  1. Stop app-service
  2. Deploy from portal
  3. Start app-service

It appears the running binary is blocking the deployment. How can I automate deployment using git push or from the portal without manually having to stop the service?

Application settings: App service Application settings

hultqvist
  • 17,451
  • 15
  • 64
  • 101

2 Answers2

1

You need to enable msdeploy flag MSDEPLOY_RENAME_LOCKED_FILES=1 in Azure App Service application settings. The option if set enables msdeploy to rename locked files that are locked during app deployment

Click application settings and scroll down until you see app settings. set this key: MSDEPLOY_RENAME_LOCKED_FILES and for its value put 1

  • It was already set to 1. I've added a screenshot of the settings in the question. I noticed I also had AppInsights enabled, might that cause a problem? – hultqvist Jan 19 '18 at 11:46
  • Am I using MSDeploy when doing a git push or using the portal? – hultqvist Jan 19 '18 at 11:48
0

How can I deploy a new version without first manually stopping the app-service?

When I develop my .Net Core Web application via VS, I would leverage the publish wizard, check the option Remove additional files at destination and use the App offline support by setting EnableMSDeployAppOffline to true under the publish profile for publishing my application to Azure Web App.

enter image description here

Based on your current deployment workflow, I assume that you are using the Continuous Deployment to your Azure App Service with your local Git Repository. After I changed the source code, then commit the changes to the local repository, then push the source code to my web app remote repository, the source code would be built and copied to D:\home\site\wwwroot on Azure side. Details you could follow Local Git Deployment to Azure App Service.

For your step 1 to 3, I just push the code changes from the local repository to my app service remote repository. Azure would generate the deployment script for you to build your source code project and move the built content to D:\home\site\wwwroot. Moreover, you could Custom Deployment Script for your additional requirement.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35
  • From what I can tell the problem is unexpected behavior, a file that is supposed to be deleted can't be deleted because it's locked. – hultqvist Jan 22 '18 at 11:46
  • You could leverage **Remove Additional Files at Destination** and **Take Application Offline**. Details you could follow [Azure App Service Deployment](https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/AzureRmWebAppDeployment/README.md) and this similar [issue](https://stackoverflow.com/questions/20792405/how-to-take-web-app-offline-while-publishing/20888597#20888597). – Bruce Chen Jan 24 '18 at 03:05