Search code examples
azure-deploymentazure-rm-templateazure-resource-manager

Provide request header for Microsoft.Scheduler/jobCollections/jobs


I want to know how to provide from my Azure WebApp the user/password to provide header for my webjob

            {
           "name": "[concat('TraitementTableAzure-', parameters('HeliosEnvironnementName'), '-js')]",
           "type": "jobs",
           "apiVersion": "2016-03-01",
           "location": "[resourceGroup().location]",
           "properties": {
              "action": {
                 "request": {
                    "method": "Post",
                    "uri": "[concat('https://', parameters('AzureWebAppWebJobs'), '.scm.azurewebsites.net/api/triggeredwebjobs/', parameters('HeliosEnvironnementName'), '_TraitementTableAzure/run')]",
                    "headers": {
                       "authorization": "[concat('Basic ', reference('???').???)]"                        }
                 },
                 "type": "Http",
                 "retryPolicy": {
                    "retryType": "Fixed"
                 }
              },
              "startTime": "[parameters('SchedulesStartTime').SchedulerTraitementTableAzureStartTime]",
              "recurrence": {
                 "frequency": "Day",
                 "interval": 1
              },
              "state": "Enabled"
           },
           "dependsOn": [
              "[resourceId('Microsoft.Scheduler/jobCollections', variables('AzureSchedulerName'))]"
           ],
           "tags": {
              "displayName": "Cedule_TraitementTableAzure"
           }
        },

I found information over Azure Portal but not in ARM Template under webjob Properties. How can reference information on the blue arrow over my ARM template ? Clip Azure Blade


Solution

  • How can reference information on the blue arrow over my ARM template ?

    If we want to get the publishingPassword, then we could use ListPublishingCredentials API in the ARM template via list function, list(concat('Microsoft.Web/sites/', parameters('websisteName') ,'/config/publishingcredentials'), '2016-08-01').properties.publishingPassword

    According to your template, it seems the that you want to call WebJob REST API, If it is that case, the authorization header is base64(publishusername:publishpassword).

    base64(concat(list(concat('Microsoft.Web/sites/', parameters('websisteName'),'/config/publishingcredentials'), '2016-08-01').properties.publishingUserName,':',list(concat('Microsoft.Web/sites/', parameters('websisteName') ,'/config/publishingcredentials'), '2016-08-01').properties.publishingPassword))
    

    I write a demo to test it on my side, it works correctly .

    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "websisteName": {
          "type": "string"
        }
        },
        "resources": [],
        "outputs": {
          "base64Output": {
            "type": "string",
            "value": "[base64(concat(list(concat('Microsoft.Web/sites/', parameters('websisteName'),'/config/publishingcredentials'), '2016-08-01').properties.publishingUserName,':',list(concat('Microsoft.Web/sites/', parameters('websisteName') ,'/config/publishingcredentials'), '2016-08-01').properties.publishingPassword))]"
          }
        }
      }
    

    enter image description here