0

I am trying to use a nested template in an Azure Blueprint artifact to deploy a Topic to an Azure Service Bus. This bus is created in a different subscription than the rest of the blueprint. I've been following this article: https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-cross-resource-group-deployment

My artifact is defined as:

{
"kind": "template",
"properties": {
    "template": {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "servicebusNamespace": {
                "type": "string"
            },
            "topicName": {
                "type": "string"
            }
        },
        "resources": [
            {
                "apiVersion": "2019-05-01",
                "name": "nestedTemplate",
                "type": "Microsoft.Resources/deployments",
                "resourceGroup": "myResourceGroup",
                "subscriptionId": "mySubscriptionId",
                "properties": {
                    "mode": "Incremental",
                    "template": {
                        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                        "contentVersion": "1.0.0.0",
                        "parameters": {},
                        "variables": {},
                        "resources": [
                            {
                                "type": "Microsoft.ServiceBus/namespaces/topics",
                                "apiVersion": "2017-04-01",
                                "name": "[concat(parameters('servicebusNamespace'), '/', parameters('topicName'))]",
                                "location": "North Europe",
                                "properties": {
                                    "defaultMessageTimeToLive": "P14D",
                                    "maxSizeInMegabytes": 1024,
                                    "requiresDuplicateDetection": false,
                                    "duplicateDetectionHistoryTimeWindow": "PT10M",
                                    "enableBatchedOperations": true,
                                    "status": "Active",
                                    "supportOrdering": true,
                                    "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
                                    "enablePartitioning": false,
                                    "enableExpress": false
                                }
                            }
                        ]
                    },
                    "parameters": {}
                }
            }
        ]
    },
    "parameters": {
        "servicebusNamespace": {
            "value": "[parameters('BP_servicebusNamespace')]"
        },
        "topicName": {
            "value": "[parameters('BP_topicName')]"
        }
    }
},
"type": "Microsoft.Blueprint/blueprints/artifacts"

}

When importing the blueprint using Import-AzBlueprintWithArtifact -Name $blueprintName -ManagementGroupId $managementGroupId -InputPath $blueprintFolder -Force I receive the following error:

"ERROR! This artifact is invalid. Error: 'The template resource 'nestedTemplate' at line '13' and column '5' is invalid. 'SubscriptionId' property is not supported for nested deployments inside a deployment at subscription scope. Please see https://aka.ms/arm-template/#resources for usage details.'"

4c74356b41
  • 69,186
  • 6
  • 100
  • 141

1 Answers1

0

the error tells you what is going on there, you cannot use a subscriptionid property for nested deployments inside a deployment at subscription scope. Try converting it to a linked template, that might work (or linked template inside resource group level deployment)

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • I am trying to achieve something similar to this: https://github.com/Azure/azure-docs-json-samples/blob/master/azure-resource-manager/crosssubscription.json and I don't see how my code snippet really differs from this one, except it is embedded in a blueprint artifact – borgewi Nov 18 '19 at 13:42
  • well, maybe thats the answer, that snippet works for sure, but doesnt work for blueprint initiated deployments for some reason (I guess the idea being you are not supposed to do stuff in other subscriptions? i dont really know) – 4c74356b41 Nov 18 '19 at 14:09