Search code examples
azureazure-rm-templateazure-appserviceazure-app-service-plansazure-hybrid-connections

Add Existing Hybrid Connection to Azure App service Plan via ARM Template


We created an Azure Standard Logic App created via ARM template. This Logic App should use an existing Hybrid Connection.

I shared the ARM template below that we used to create Azure App Service Plan. I think I need to reference the Hybrid Connection settings in the template below, but couldn't find any document on how to do it.

How could I modify the template to set hybrid connection?

Thank you

{
    "apiVersion": "2022-09-01",
    "dependsOn": [
    ],
    "kind": "",
    "location": "[parameters('location')]",
    "name": "[parameters('hostingPlanName')]",
    "properties": {
        "maximumElasticWorkerCount": 20,
        "name": "[parameters('hostingPlanName')]",
        "numberOfWorkers": "[parameters('numberOfWorkers')]",
        "workerSize": "[parameters('workerSize')]",
        "workerSizeId": "[parameters('workerSizeId')]",
        "zoneRedundant": false
    },
    "sku": {
        "Name": "[parameters('skuCode')]",
        "Tier": "[parameters('sku')]"
    },
    "tags": {
    },
    "type": "Microsoft.Web/serverfarms"
}

Solution

  • To the existed template, you can add a connection using Microsoft.Web/connections provider in ARM template as shown below.

    I've created a sample office 365 connection and it worked as expected.

    {
      "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "name": {
          "type": "String"
        },
        "location": {
          "type": "String"
        },
        "sku": {
          "type": "String"
        },
        "skucode": {
          "type": "String"
        },
        "workerSize": {
          "type": "String"
        },
        "workerSizeId": {
          "type": "String"
        },
        "numberOfWorkers": {
          "type": "String"
        },
        "hostingPlanName": {
          "type": "String"
        },
        "office365_1_Connection_DisplayName": {
          "type": "String"
        },
        "office365_1_Connection_Name": {
          "type": "String"
        }
      },
      "resources": [
        {
          "apiVersion": "2022-09-01",
          "dependsOn": [],
          "kind": "",
          "location": "[parameters('location')]",
          "name": "[parameters('hostingPlanName')]",
          "properties": {
            "maximumElasticWorkerCount": 20,
            "name": "[parameters('hostingPlanName')]",
            "numberOfWorkers": "[parameters('numberOfWorkers')]",
            "workerSize": "[parameters('workerSize')]",
            "workerSizeId": "[parameters('workerSizeId')]",
            "zoneRedundant": false
          },
          "sku": {
            "Name": "[parameters('skuCode')]",
            "Tier": "[parameters('sku')]"
          },
          "tags": {},
          "type": "Microsoft.Web/serverfarms"
        },
        {
          "type": "Microsoft.Web/connections",
          "apiVersion": "2016-06-01",
          "name": "[parameters('office365_1_Connection_Name')]",
          "location": "[parameters('location')]",
          "properties": {
            "api": {
              "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('location'), '/managedApis/', 'office365')]"
            },
            "displayName": "[parameters('office365_1_Connection_DisplayName')]"
          }
        }
      ]
    }
    
    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "name": {
          "value": "plan1"
        },
        "location": {
          "value": ""
        },
        "sku": {
          "value": "Free"
        },
        "skucode": {
          "value": "F1"
        },
        "workerSize": {
          "value": "0"
        },
        "workerSizeId": {
          "value": "0"
        },
        "numberOfWorkers": {
          "value": "1"
        },
        "hostingPlanName": {
          "value": "newnsme"
        },
        "office365_1_Connection_Name": {
          "value": "connectionnew"
        },
        "office365_1_Connection_DisplayName": {
          "value": "newdis"
        }
      }
    }
    

    Output:

    enter image description here

    enter image description here