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

偶尔善良 提交于 2021-01-03 06:06:34

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/49383380/link-existing-hybrid-connection-to-an-azure-web-app-through-arm-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!