26

I have an automatic deployment configured from my GIT to Azure App using Web Deploy. Every time when new code pushed to the repo, build is started, then deployed to the Azure with Web Deploy.

The issue is that Web App (ASP.NET MVC) continue to serve requests using the deployed code, and the file replacement doesn't really affect it. Even if web.config was changed. Basically, the only way I can force the new app to loaded is to restart it (or stop/start) manually.

here is my publishig profile:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>https://app-name.azurewebsites.net</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>app-name.scm.azurewebsites.net:443</MSDeployServiceURL>
    <DeployIisAppPath>app-name</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>$app-name</UserName>
    <Password>...</Password>
    <AllowUntrustedCertificate>True</AllowUntrustedCertificate>
    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
  </PropertyGroup>
</Project>

similar topic at msdn with no answer

Alexey Strakh
  • 10,508
  • 17
  • 76
  • 146
  • Have check with kudu if your files have been updated? – Thiago Custodio Feb 15 '17 at 03:53
  • I'm not sure about KUDU but after any deployment I connect using ftp client and can see my new files there. So the issue is that the app is not picking them up – Alexey Strakh Feb 15 '17 at 22:44
  • Are you precompiling views? – lucuma Feb 23 '17 at 02:12
  • I tried both options without and without precompilation. Both works the same way after a deployment. – Alexey Strakh Mar 09 '17 at 06:05
  • Could it be related to the `app_offline.htm is case sensitive` bug that was resolved some weeks ago in Azure App Service? https://github.com/aspnet/Home/issues/694 – Svein Fidjestøl Apr 03 '17 at 12:11
  • 1
    You might have some files conflicting with your app. Right click on your project, **Properties** > **Package/Publish Web** > section **Items to deploy**, make sure "**Only files needed to run this application**" is selected. Then, on your publish profile, change this option to false **False** to remove additional files. Do this only if you are sure you didn't store any extra files (assets...) on your server that are not referenced in your project because they will be removed. – Renaud Dumont Apr 10 '17 at 09:37
  • does it takes new files webapp restart? – Raghavendra Apr 20 '17 at 18:41

2 Answers2

2

David has already shared his insights. There is an alternate way to tackle this scenario through the use of Deployment Slots. You can create a slot and then configure Auto-Swap to tackle this. This has added benefits of zero cold start and zero downtime.

See this for more info: Configure Auto Swap

0

Correct me if I'm wrong here, but what else did you expect? If the application is "running", serving request, then the assemblies are loaded into memory. If you update them you should reload the application to load the new assemblies. As far as I know there is no way to remove assemblies from an existing AppDomain. So you end up needing to create a new one (by restarting the application).

One simple solution is to deploy a app_offline.htm file along with your application. If IIS sees this file, then stops responding to new requests, requests already in the system will be served, then the application will be stopped. For every new request content of the app_offline.htm will be served. After you complete the deployment, run a simple script with WebDeploy e.g. using -postSync:runcommand= in msdeploy and just remove the app_offline.htm file. The new version of the application will start up.

If you update the web.config file, then the new config should be loaded automatically. But this does not mean, the application will be reloaded entirely.

If you have this issue with static files, then maybe HTTP caching is your problem. The files are updated, but clients (browsers) load them from the cache. See this question for more details.

Community
  • 1
  • 1
Dávid Molnár
  • 7,524
  • 6
  • 25
  • 43