问题
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