I plan to create two resources in my resource groups: one web app and one service bus. The web app is going to have a connection string to point to the service bus. So, I need to first create the service bus and then add web app with its connection string. For both web app and the service bus, I'm using linked templates. My simplified azuredeploy.json
looks like this:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "myWebAppDeploy",
"apiVersion": "2017-05-10",
"type": "Microsoft.Resources/deployments",
"dependsOn": [
"UNKNOWN-DEPENDENCY"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "link/to/webapp.azuredeploy.json",
"contentVersion": "1.0.0.0"
},
"parameters": {
"name": {
"value": "myWebApp"
},
"connectionStrings": {
"value": {
"serviceBusConnectionString": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', 'myServiceBus', 'RootManageSharedAccessKey'), '2017-04-01').primaryConnectionString]"
}
}
}
}
},
{
"name": "myServiceBusDeploy",
"apiVersion": "2017-05-10",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "link/to/servicebus.azuredeploy.json",
"contentVersion": "1.0.0.0"
},
"parameters": {
"name": {
"value": "myServiceBus"
}
}
}
}
]
}
No matter what I put in UNKNOWN-DEPENDENCY
section, I receive the following error:
Template deployment returned the following errors:10:02:23 AM - Resource Microsoft.ServiceBus/namespaces/authorizationRules 'myServiceBus/RootManageSharedAccessKey' failed with message '{
"error": {
"code": "ParentResourceNotFound",
"message": "Can not perform requested operation on nested resource. Parent resource 'myServiceBus' not found."
}
}'
Looks like it's trying to deploy the web app before the service bus. I have tried the followings, but no luck:
"myServiceBus"
"myServiceBusDeploy",
"[concat('Microsoft.Resources/deployments/', 'myServiceBusDeploy')]",
"[concat('Microsoft.ServiceBus/namespaces', 'myServiceBus')]"
"[resourceId('Microsoft.Resources/deployments', 'myServiceBusDeploy')]"
"[resourceId('Microsoft.ServiceBus/namespaces', 'myServiceBus')]"
I'm out of ideas and don't know how to set up the dependencies between these two linked templates.
UPDATE: If I deploy my template again after receiving the error, it will work since the service bus is already deployed in the first deploy. So, I'm pretty sure that the nested/linked templates are OK.