Visual Studio 2015 Publish WebJobs Issue

杀马特。学长 韩版系。学妹 提交于 2019-12-30 08:15:19

问题


Using the right-click, Publish as Azure WebJob... option in VisualStudio 2015, the job is published however the runMode seems to be ignored.

In my file, I have the following settings, however the job is continually set to an On Demand job in the portal after publishing:

{
  "$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
  "webJobName": "MyJob",
  "startTime": "2015-07-21T00:30:00-08:00",
  "endTime": null,
  "jobRecurrenceFrequency": "Day",
  "interval": 1,
  "runMode": "Scheduled"
}

Using Visual Studio 2015 with the Azure SDK for .NET 2.7

Here is the Error in the output windows after publishing Error : An error occurred while creating the WebJob schedule: Could not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.ActiveDirectoryAuthenticationException' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.16.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.


回答1:


Based off of the error, the issue is that you must be logged into Cloud Explorer within Visual Studio for the job to be scheduled properly.

The job will still publish if you are not logged in, however it will only be available OnDemand.




回答2:


On my case even though I'm already logged into Cloud Explorer I still get the same error.

I have the latest Azure SDK for .NET (VS 2015) installed as of writing. I had to update my NuGet package Microsoft.Web.WebJobs.Publish from version 1.0.2 to the latest version which is 1.0.10. NuGet Package Upgrade

Then finally the web job was published successfully!




回答3:


There is now a better way of scheduling WebJobs using CRON expressions, which is simpler and avoids all the Scheduler issues mentioned here.

To use it, do the following:

  • Your Azure Web App must be running in Standard mode, and have 'Always On' enabled.
  • When creating your WebJob in Visual Studio, choose 'Run on Demand' instead of 'Run on a Schedule'.
  • Create a settings.job file at the root of your WebJob. Make sure to set Copy to Output Directory='Copy if newer'. This file should contain something like this (which makes it run on the top of each hour):

{ "schedule": "0 0 * * * *" }

For more information, about this technique, see the following links:

https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/#CreateScheduledCRON

http://blog.amitapple.com/post/2015/06/scheduling-azure-webjobs/




回答4:


When deploying for Visual Studio, check the Output Window. You should see that it builds your project, and then it will seem to have finished. About 30-90 seconds later, you will see any errors that may occur with the scheduling part of the deployment. You will also see them in the "Azure App Service Activity" window, which will give you a full log of the deployment.

As there's quite a delay where nothing seems to be happening while it deploys, it's easy to miss any error message that may occur. If you see an error, post it here and we can debug further. Thanks.



来源:https://stackoverflow.com/questions/31590059/visual-studio-2015-publish-webjobs-issue

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