简体   繁体   中英

Link existing hybrid connection to an azure web app through ARM-template

I have a resource group in azure which contains a Relay which contains a hybrid connection. I'm trying to deploy another resourcegroup containing a web app which should link the existing hybrid connection in the other resourcegroup.

Performing this task in the azure portal is trivial but since I want to run "complete mode" during my ARM-template deploy I need to do this during deployment.

I cannot find any good documentation for this and lots of answers seems outdated. Is this possible, and if then, how can it be accomplished?

It seems that Azure does not currently support connecting Azure App Service to a Hybrid Connection via ARM Template.

This is the user feedback , you could vote it.

You can use this code to create hybrid connection on Relay:

{
  "name": "[concat(relayName, '/', hybridConnectionName]",
  "type": "Microsoft.Relay/namespaces/hybridConnections",
  "apiVersion": "2017-04-01",      
  "dependsOn": [
    "relayName"
  ],
  "properties": {
    "requiresClientAuthorization": true,
    "userMetadata": [
       {
          "key": "endpoint",
          "value": "google.com:443"
       }
    ]
  },
  "resources": []
}

And then connect it to the web app:

"variables": { 
   "hybridConnectionResourceId": "[resourceId(relayResourceGroup, 'Microsoft.Relay/Namespaces/Hybridconnections', relayName, hybridConnectionName)]"
},
{
  "name": "[concat(webAppName, '/', relayName, '/', hybridConnectionName)]",
  "type": "Microsoft.Web/sites/hybridConnectionNamespaces/relays",
  "apiVersion": "2018-02-01",
  "dependsOn": [
    "webAppName"
  ],
  "location": "[resourceGroup().location]",
  "properties": {
    "serviceBusNamespace": "relayName",
    "relayName": "hybridConnectionName",
    "relayArmUri": "[variables('hybridConnectionResourceId')]",
    "hostName": "[split(json(reference(variables('hybridConnectionResourceId'), '2017-04-01').userMetadata)[0].value, ':')[0]]",
    "port": "[split(json(reference(variables('hybridConnectionResourceId'), '2017-04-01').userMetadata)[0].value, ':')[1]]",
    "sendKeyName": "defaultSender",
    "sendKeyValue": "[listkeys(concat(variables('hybridConnectionResourceId'), '/authorizationRules/defaultSender'), '2017-04-01').primaryKey]"
  }
}

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM