azure-webjobs-sdk
azure-webjobs-sdk copied to clipboard
WebJobs not updated in WebDeploy when excluding app_data
From the document Profiling live Azure web apps with Application Insights it can be learned that the Application Insights Profiler is implemented as a normal WebJob. In order to not inadvertently remove this job during deployment, the article states:
If you use WebDeploy to deploy changes to your web application, ensure that you exclude the App_Data folder from being deleted during deployment. Otherwise, the profiler extension's files will be deleted when you next deploy the web application to Azure.
However, as can be seen from the StackOverflow issue Why are changes to my WebJob not being picked up when publishing the Web App?, excluding app_data means that changed WebJobs do not (always) update.
Thus, we are stuck in a silly situation - after each WebDeploy, we must remember to reinstall the profiler. This is error-prone and inconvenient.
Repro steps
-
Create a webapp with a web job.
-
Edit the pubxml file to contain <ExcludeApp_Data>True</ExcludeApp_Data>.
-
Deploy the app.
-
Change something in the web job that is traceable. In my case the file and product version numbers are updated and the job logs the AssemblyInformationalVersion attribute to Logstash.
-
Redeploy. Observe that there are no errors logged during deployment - it just silently skips the updated web job.
Expected behavior
When I redeploy and the web job has changed, it should update the web job. Since other Azure infrastructure depends on preserving app_data, it is not acceptable that the WebDeploy publishing mechanism for WebJobs does not handle this case correctly.
Actual behavior
WebJob is not updated and no errors are present in the WebDeploy log.
Known workarounds
Specify <ExcludeApp_Data>False</ExcludeApp_Data> in the pubxml file and thus wipe app_data along with any Azure-internal web jobs at every deploy.
Related information
I am using the following NuGet package versions:
- Microsoft.Azure.WebJobs v2.0.0
- Microsoft.Azure.WebJobs.Core v2.0.0
- Microsoft.Azure.WebJobs.ServiceBus v2.0.0
- Microsoft.Web.WebJobs.Publish v1.0.13
I'm running into this too and adding the ExcludeApp_Data tag isn't helping. It's a huge problem.
Six years on an this still seems to be a problem. I'm using the AzureRmWebAppDeployment@4 task in a Azure pipeline to deploy our web app and which references our own WebJobs. But having configured the pipeline and followed the "Usage notes" in the task document which states:
When deploying to an App Service that has Application Insights configured, and you have enabled Remove additional files at destination, ensure you also enable Exclude files from the App_Data folder in order to maintain the Application insights extension in a safe state. This is required because the Application Insights continuous web job is installed into the App_Data folder.
...I still don't have any webjobs deployed.
It would be good to have some updates to those docs to suggest what to do when deploying your own WebJobs. Hoping I've missed something obvious though :)
Maybe this is related but the Application Insights troubleshooting describes a deployment error stating the following:
This error occurs if you run Web Deploy from scripts or Azure Pipelines. To resolve this issue, add the following deployment parameters to the Web Deploy task:
- -skip:Directory='.\App_Data\jobs\continuous\ApplicationInsightsProfiler.'
- -skip:skipAction=Delete,objectname='dirPath',absolutepath='.*\App_Data\jobs\continuous$'
- -skip:skipAction=Delete,objectname='dirPath',absolutepath='.*\App_Data\jobs$'
- -skip:skipAction=Delete,objectname='dirPath',absolutepath='.*\App_Data$'
These parameters delete the folder used by Application Insights Profiler and unblock the redeploy process. They don't affect the Profiler instance that's currently running.
...which I'm reading as suggesting to turn off "exclude app_data" so app_data containing your own WebJobs is deployed but ignores the WebJob folder for AppInsights (though I find the statement "These parameters delete the folder..." given configuring a skip is trying to do the exact opposite.
One option I am exploring is whether app insights is deployed elsewhere as I can't find the profiler webjob in the App_Data folder on the app service with it enabled! In fact using Kudu an seeing where the process is running from it's in c:\local\temp\job\continuous.
I get the feeling I can ignore the documentation and turn exclude app_data off.