Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
13.94k stars 16.07k forks source link

How to add userMetadata via arm template #3782

Open lczc1988 opened 7 years ago

lczc1988 commented 7 years ago

Customer used this https://github.com/Azure/azure-quickstart-templates/tree/master/201-azure-relay-create-hybridconnection arm template to create a hybrid connection.

He wanted to configure the userMetadata. Cx tried to add the parameters as below, but it is not added to Hybrid connection as expected. Any idea here? Thank you.

"userMetadata": { "type": "string", "metadata": { "description": "userMetadata information" }

"userMetaData": "[parameters('userMetaData')]"

We can add the userMetadata via portal or in reources.azure.com.

gtd4 commented 7 years ago

Yup, I had a similar issue trying to automate deployment of a hybrid connection

NehaOberoi92 commented 5 years ago

I am also facing similar issue... trying to create hynrid connection and relay namespace aling with usermetadata - key and value Tried to give usermetadata as json array but failed Any help is appreciated

mandarj123 commented 4 years ago

same issue here.anybody got the format which works?

nehaoberoi26 commented 4 years ago

@mandarj123 : I have used "userMetadata": "[concat('[{\"key\":\"endpoint\",\"value\":\"', parameters('hybid_endpoint_web'), '\"}]')]"

mandarj123 commented 4 years ago

what does final value looks like? endpoint:abc.com:9399 can be a valid value ?

nehaoberoi26 commented 4 years ago

yes, you want to integrate hybrid connection with app service ? It has 2 steps - Create Hybrid connection in relay Integrate it with app service

For creating hybrid connection - { "name": "[concat(parameters('apiname'), '/', parameters('servicebus_name'), '/', parameters('hybid_connection_sql'))]", "type": "Microsoft.Web/sites/hybridConnectionNamespaces/relays", "apiVersion": "2018-02-01", "dependsOn": [ "[resourceId('Microsoft.Web/sites', parameters('apiname'))]" ], "location": "[parameters('location')]", "properties": { "serviceBusNamespace": "parameters('servicebus_name')", "relayName": " parameters('hybid_connection_sql')", "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]" }
}

where variable - "hybridConnectionResourceId": "[resourceId(parameters('resourcegroup'), 'Microsoft.Relay/Namespaces/Hybridconnections', parameters('servicebus_name'), parameters('hybid_connection_sql'))]"

parameter - hybid_connection_sql is name of hybrid connection for example sqlhybrid connection

"userMetadata": "[concat('[{"key":"endpoint","value":"', parameters('hybid_endpoint_sql'), '"}]')]" this template will pick endpoint from hybrid connection ( endpoint like you gave - abc.com:9399 )