Close

ARM DependsOn

Today I have been struggling with the ARM template syntax related to dependency relations. I tried to create a servicebus subscription with subscription rules to a servicebus topic. The correct (abbreviated) syntax can be found below. I’m using function resourceId with separate parameters for servicebus, topic and subscription name, not one parameter with a nested reference.

"resources": [
        {
            "name": "[concat(parameters('serviceBusName'), '/', 'shared~werknemers')]",
            "type": "Microsoft.ServiceBus/namespaces/topics",
            "resources": [
                {
                    "name": "[concat(parameters('serviceBusName'), '/shared~werknemers/', Parameters('SBTopDeskPnbSubscriptionNaam'))]",
                    "type": "Microsoft.ServiceBus/namespaces/topics/subscriptions",
                    "dependsOn": [
	                    "[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('serviceBusName'), 'shared~werknemers')]"
                    ],
                    "resources": [
                        {
                        	"name": "[concat(parameters('serviceBusName'), '/shared~werknemers/', Parameters('SBTopDeskPnbSubscriptionNaam'), '/', parameters('SBTopDeskPnbRuleNaam'))]",
                        	"type": "Microsoft.ServiceBus/namespaces/topics/subscriptions/rules",
                        	"dependsOn": [
                            		"[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions', parameters('serviceBusName'), 'shared~werknemers', Parameters('SBTopDeskPnbSubscriptionNaam'))]"
				]

For learning purposes, you will find my failed attempts and error messages below:

“dependsOn”: [
“[concat(‘Microsoft.ServiceBus/namespaces/topics/’, parameters(‘serviceBusName’), ‘/’, ‘shared~werknemers’)]”
]

The resource ‘/subscriptions/f7d88689-03f4-4be2-bf6d-6165ef232ad6/resourceGroups/rg-int-shared-cwd-dev/
providers/Microsoft.ServiceBus/namespaces/sb-pubsub-cwd-dev/topics/shared~werknemers/subscriptions/la-topdesk-pnb-medewerker-uit-cwd-sub’
at line ’43’ and column ’17’ doesn’t depend on parent resource
‘/subscriptions/f7d88689-03f4-4be2-bf6d-6165ef232ad6/resourceGroups/rg-int-shared-cwd-dev/
providers/Microsoft.ServiceBus/namespaces/sb-pubsub-cwd-dev/topics/shared~werknemers’.

“dependsOn”: [
“[concat(‘Microsoft.ServiceBus/namespaces/topics/’, ‘shared~werknemers’)]”
]

The template resource ‘sb-pubsub-cwd-dev/shared~werknemers/la-topdesk-pnb-medewerker-uit-cwd-sub’
at line ’43’ and column ’17’ is not valid:
The resource identificator ‘Microsoft.ServiceBus/namespaces/topics/shared~werknemers’ is malformed.

“dependsOn”: [
“[concat(parameters(‘serviceBusName’), ‘/’, ‘shared~werknemers’)]”
]

The template resource ‘sb-pubsub-cwd-dev/shared~werknemers/la-topdesk-pnb-medewerker-uit-cwd-sub’
at line ’43’ and column ’17’ is not valid:
The resource identificator ‘sb-pubsub-cwd-dev/shared~werknemers’ is malformed.

“dependsOn”: [
“[resourceId(‘Microsoft.ServiceBus/namespaces/topics’, ‘shared~werknemers’)]”
]

The template resource ‘sb-pubsub-cwd-dev/shared~werknemers/la-topdesk-pnb-medewerker-uit-cwd-sub’
at line ’43’ and column ’17’ is not valid:
Unable to evaluate template language function ‘resourceId’:
the type ‘Microsoft.ServiceBus/namespaces/topics’ requires ‘2’ resource name argument(s).