13

Everyone,

Could anyone please help me on deploying WebJobs using ARM Templates ?

Thanks, Rajaram.

Chris Pietschmann
  • 29,502
  • 35
  • 121
  • 166
  • 1
    It would be helpful to get a template for a Continuous webjob as well. The curent answers seem to cover a scheduled webjob only. – NMrt Aug 31 '18 at 01:17

4 Answers4

11

A template shared by David Ebbo shows how to deploy Webjobs using Arm Templates.

In this template, a triggered webjob is linked to a website deployed by the same template. A webjob is a part of a jobCollection. This jobCollection is linked to it's parent website using the "dependsOn" node.

{
  "apiVersion": "2014-08-01-preview",
  "name": "[parameters('jobCollectionName')]",
  "type": "Microsoft.Scheduler/jobCollections",
  "dependsOn": [
    "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
  ],
  "location": "[parameters('siteLocation')]",
  "properties": {
    "sku": {
      "name": "standard"
    },
    "quota": {
      "maxJobCount": "10",
      "maxRecurrence": {
        "Frequency": "minute",
        "interval": "1"
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2014-08-01-preview",
      "name": "DavidJob",
      "type": "jobs",
      "dependsOn": [
        "[resourceId('Microsoft.Scheduler/jobCollections', parameters('jobCollectionName'))]"
      ],
      "properties": {
        "startTime": "2015-02-10T00:08:00Z",
        "action": {
          "request": {
            "uri": "[concat(list(resourceId('Microsoft.Web/sites/config', parameters('siteName'), 'publishingcredentials'), '2014-06-01').properties.scmUri, '/api/triggeredjobs/MyScheduledWebJob/run')]",
            "method": "POST"
          },
          "type": "http",
          "retryPolicy": {
            "retryType": "Fixed",
            "retryInterval": "PT1M",
            "retryCount": 2
          }
        },
        "state": "enabled",
        "recurrence": {
          "frequency": "minute",
          "interval": 1
        }
      }
    }
  ]
}

Regards,

Thibaut Ranise
  • 705
  • 4
  • 12
  • 6
    Thanks Ranise. I already looked on those templates. I creates a Scheduler and a WebJob. My concern is how can I upload my Job (Zip file) to make it run. – Rajaram Kumaraguru Apr 28 '16 at 05:37
10

The other answers cover the template aspect of getting the job created in Azure, but there's still the question of getting the webjob executable uploaded.

Assuming this deploy is part of a larger Azure website deploy, you simply need to include your webjob executable in the distribution of your website.

Per the kudu documentation the convention for placing your EXE is as follows:

To deploy a triggered job copy your binaries to: app_data\jobs\triggered\{job name}

To deploy a continuous job copy your binaries to: app_data\jobs\continuous\{job name}

Community
  • 1
  • 1
Dean Goodman
  • 973
  • 9
  • 22
  • https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-resource-groups-deployment-projects-create-deploy/ Reference the web project and the build artifacts are generated on build. Then add MsDeploy ARM section. – OzBob Feb 24 '17 at 03:27
1

Azure scheduler became obsolete on december 2019, after that, all Scheduler job collections and jobs stopped running, that is why Scheduler Job Collection in not usable anymore, Azure logic apps should be used instead. -Migrate Azure WebJobs from Azure Scheduler to Azure Logic Apps.

manuelrb98
  • 344
  • 2
  • 8
  • 2
    Is the recurring webjob using scheduler under the hood? – mslot May 17 '20 at 19:52
  • Sorry, i did not find any precise information about your question, however i suggest you to migrate to azure logic apps or use azure functions – manuelrb98 May 17 '20 at 21:52
0

Here's an Azure QuickStart Template that deploys an Azure Web App with a Schedule Job.

Additionally, have you looked at the Visual Studio 2015 Azure SDK support for the Azure Resource Manager project type? It contains UI for more easily authoring ARM Templates directly from within Visual Studio.

Chris Pietschmann
  • 29,502
  • 35
  • 121
  • 166
  • Thanks Chris. Will give a try and let you know. – Rajaram Kumaraguru Apr 26 '16 at 05:33
  • Chris, yep I worked. I can now create Scheduler and a web job. Still I didn't see any way to upload any files (.exe) to the newly created Web job. – Rajaram Kumaraguru Apr 26 '16 at 12:44
  • https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-resource-groups-deployment-projects-create-deploy/ Reference the web project and the build artifacts are generated on build. Then add MsDeploy ARM section. – OzBob Feb 24 '17 at 03:27