简体   繁体   中英

Azure deployment: Error while creating webjob schedule (400 Bad Request)

I receive the following error while publishing and Azure Website from Visual Studio 2013:

12>Publish Succeeded. 12>Creating the scheduler job 12>C:\\projectPath\\packages\\Microsoft.Web.WebJobs.Publish.1.0.7\\tools\\webjobs.console.targets(110,5): Error : An error occurred while creating the WebJob schedule: Response status code does not indicate success: 400 (Bad Request).

I have read another posts with similar issues: 404 error, BadRequest: The condition specified by the ETag is not satisfied... but none of these seem to be the problem here. I have reinstalled the Microsoft Azure Tools for VS 2013, the webjobs.publish package in my solution and it didn't work either. I also checked this post https://social.msdn.microsoft.com/forums/azure/en-US/d5b44e53-c4d7-48ff-a024-4bdd6eb48b79/sheduled-web-jobs-in-azure-web-site-not-configurable-in-same-region-as-web-siteand-workaround?forum=azurescheduler#d5b44e53-c4d7-48ff-a024-4bdd6eb48b79 and did what he tried but it haven't solved the issue. It looks like all my files are uploaded correctly to the Azure website, and the issue begins when the scheduler jobs are being created.

The strange thing is that the webjobs are uploaded (updated) and that they are also working correctly, but the scheduled webjobs are not in my jobcollection list in the Azure management portal. I also tried to remove my current job collection and all the jobs from my website, but when I publish the site, all the webjobs are created but the job collection is empty. I had a similar issue with VS and the problemas was that the credentials of the website were expired, but the problem was solved by reentering the credentials in VS. Any idea of how to solve this issue?

Please see my answer to Visual Studio 2015 Publish WebJobs Issue , which shows an alternate way to do scheduling that makes things far simpler and avoids this type of conditions.

To summarize, you can create a settings.job file at the root of your WebJob file, containing a CRON expression. eg

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

For more information, about this technique, see the following documentation 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/

I faced the same issue today and the solution for me was simpler. What happened is that the startTime I had configured on my webjob-publish-settings.json was for some days ago (while I was developing). I changed the startTime for tomorrow and it worked. Looks like the scheduler is not able to get started when the startTime is not in the future. Hope it helps.

As I have noted in my question, I deleted my webcolletion to solve the issue, but I did not notice that the new collection was created in free mode (I do not know why because my site is in standard mode). So setting the jobcollection to standard mode partially solved the problem. Then I got the following error:

An error occurred while creating the WebJob schedule: Response status code does not indicate success: 409 (Conflict).

I went to the azure portal, and I saw that all jobs but one were created correctly (as scheduled jobs). I reset the webjob-publish-settings.json file of the webjob, I published it and the problem was solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM