Why are changes to my WebJob not being picked up when publishing the Web App?

二次信任 提交于 2021-02-07 13:00:46

问题


I have an ASP.NET MVC Web App which is deployed to Azure. The solution within VS 2013 Pro has 3 projects:

  • the Web App project
  • a Webjob project
  • a Common project which stores code which is common to both the App and the Webjob.

The Webjob project was added to the main App project via the Add --> New Azure Webjob Project context menu, which actually adds a new project within the same solution, which is fine.

When I initially published the app to Azure, the Webjob was deployed too and all is working as expected. The Webjob runs on schedule once per day.

Now I've made some local changes to the Webjob and need those changes to be published. I follow the same process to deploy the App (rtClick main App --> Publish) which should also pick up changes to the Webjob, but the Preview pane is not picking up the changes and the changes are then subsequently not published to the Webjob.

Incidentally, any changes I make to the Common project are picked up successfully so looks like there is something weird about making changes and publishing Webjobs.

Has anyone come across this before?


回答1:


I've found the cause of the problem. It's actually very simple but also pretty frustrating.

When publishing the web app, you have the option to Remove additional files at destination. I have always left this checked because I don't like old files hanging around for no reason.

You also have the option to Exclude files from the App_Data folder which I also always leave checked so that files from App_Data are not deleted based on the remove configuration above. I then usually configure things like NLog log files, ELMAH xml files etc to go into App_Data safe in the knowledge that anything in there won't be deleted.

So the issue with Webjobs is that they're deployed into App_Data. So if the Exclude files from App_Data folder is checked then when the app is published, it's doing what it's told and ignoring App_Data and hence ignoring the changes to the Webjob.

So the simple solution is to uncheck this option and the Webjob is deployed successfully. However the issue now is that all other files in App_Data will be deleted (log files etc).

So you could uncheck the remove files config but that then potentially leaves other unwanted files lying around. Not ideal.

The other option is to leave the remove config checked, click the Preview button within the Publish dialog prior to publishing, then manually unchecking every file you don't want deleted. However the publish process fails if any of the files you want to keep are within sub-folders within App_Data e.g. App_Data/logs.

So the other option is to move all of the files within App_Data that you want to keep into the root of App_Data, then uncheck each of them within the Preview window prior to publishing. Not a huge deal when done once but becomes tedious when publishing lots of times.

I realise I could move log files etc to Azure storage, SQL DBs etc but what if it's the case that other files are in App_Data which need to be kept? App_Data isn't solely intended for Webjobs but using Webjobs creates a bit of an awkward situation if you also use App_Data for other things.

Be keen to know if I'm missing anything obvious here?




回答2:


Try to do a 'Publish to local file system' in VS, and check if the WebJobs files make it that folder (under App_Data). And if that works, try making a change to the WebJob and then do an incremental publish to the same folder. You can find more info relating to this here.

Normally, whatever file set you get to your local folder is what would get deployed to your Azure Web App.

If the same issue occurs locally, then there is probably something wrong with the WebJobs NuGet package in your app. You could try checking for NuGet updates.

Yet another thing you could do to further isolate is to create a new clean dummy WebApp with a WebJob, and see if you see the same. This will help determine if it's specific to your one project.



来源:https://stackoverflow.com/questions/34608759/why-are-changes-to-my-webjob-not-being-picked-up-when-publishing-the-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!