14

I have a Git-Enabled ASP.NET WebApp with one associated Azure WebJob. When I deploy this via Visual Studio everything is fine, but this is kinda hard in a Continuous Delivery Environment so I would like to publish the Web App and the WebJob via Git.

Via the Azure Tooling I associated my WebJob project and I got a "webjobs-list.json" file inside the WebApp Project:

{
"$schema": "http://schemastore.org/schemas/json/webjobs-list.json",
"WebJobs": [{
  "filePath": "../CodeInside.Hub.Job/CodeInside.Hub.Job.csproj"
  }]
}


webjobs-list.json Source

Inside the Console App Project I got a "webjob-publish-settings.json" file with this content: 

{
"$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
"webJobName": "Hub-Crawler",
"startTime": "2014-11-25T02:00:00+01:00",
"endTime": null,
"jobRecurrenceFrequency": "Day",
"interval": 1,
"runMode": "Scheduled"
}

webjob-publish-settings.json

As you can see the "runMode" is set to "Scheduled" and everything is fine when I deploy it via Visual Studio.

But without Visual Studio I got this "on demand" WebJob: enter image description here

Is this currently not supported or what could be the problem?

The complete .sln can be found on GitHub

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Robert Muehsig
  • 5,206
  • 2
  • 29
  • 33

3 Answers3

6

Indeed, the problem is that the scenario is not yet well supported. Specifically, when publishing via git (or GitHub/Bitbucket), the webjob-publish-settings.json file is ignored.

One workaround is to publish once using VS just to get the scheduler created, and then use git afterwards.

Eventually, this scenario will be solved by using Azure Resource Manager templates that define both the WebSite and the scheduler. Technically, this can be done today, but there is not much documentation out there yet.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Ok - now I'm even not able to publish it via Visual Studio 2013 Update 4. I get this error described here but could figure out what is wrong: http://stackoverflow.com/questions/26277009/azure-webjob-deploy-error-managementcertificatepath Ideas? – Robert Muehsig Nov 27 '14 at 22:46
  • That is an unrelated issue, so it would be best to discuss it separately. – David Ebbo Nov 30 '14 at 02:54
  • Ok - after updating VS/Azure Tools (and deleting the existing scheduler & job on the portal) the manuel deployment worked again. – Robert Muehsig Dec 01 '14 at 20:07
  • 1
    Do you know if this limitation still exists? [This](https://github.com/projectkudu/kudu/wiki/Web-jobs#deploying-net-console-webjobs-alongside-an-aspnet-application) from the kudu wiki mentions being able to git deploy along with a website, but doesn't mention anything about scheduled or continuous jobs. – Sandeep Phadke Mar 22 '15 at 23:15
  • 1
    It appears this limitation still exists at this time. Hopefully MSFT will address this. – dprothero May 01 '15 at 00:28
  • Try provisioning the site & scheduler using an ARM template like this one: https://github.com/davidebbo/AzureWebsitesSamples/blob/master/ARMTemplates/WebSiteWithWebJobs.json. – David Ebbo May 01 '15 at 06:21
5

There is finally a solution for deploying scheduled webjobs with git deployment.

This blog has details.

The solution uses the kudu scheduler as opposed to the Azure scheduler so the Azure portal still shows the job as "On Demand" but it does execute per schedule and the portal shows history accurately.

Sandeep Phadke
  • 862
  • 9
  • 23
  • Used it since a week - forgot to mention it here. I wasn't sure whats the connection between the different settings.json / web-publish settings files are and created an issue here: https://github.com/projectkudu/kudu/issues/1601 The answer did help me, but there are still some questions left ;) – Robert Muehsig Jul 03 '15 at 07:13
0

Until there's a better supported mechanism for this from Azure, you could look into scripting this out using PowerShell. See: Create a Scheduled Azure WebJob with PowerShell

Community
  • 1
  • 1
dprothero
  • 2,683
  • 2
  • 21
  • 28