Azure ARM Templates to deploy WebJobs

2019-04-20 20:12发布

Everyone,

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

Thanks, Rajaram.

3条回答
何必那么认真
2楼-- · 2019-04-20 20:46

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.

查看更多
一纸荒年 Trace。
3楼-- · 2019-04-20 20:47

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}

查看更多
Evening l夕情丶
4楼-- · 2019-04-20 20:48

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,

查看更多
登录 后发表回答