ResourceGroup()。嵌套模板混淆中的位置

问题描述 投票:0回答:1

我在下面有嵌套模板。似乎容器注册表的resourcegroup().location指的是父模板中定义的资源组,而不是通过nestedTemplate部署的资源组。如何在嵌套模板中正确引用资源组的位置?

        {
            "apiVersion": "2017-05-10",
            "name": "nestedTemplate",
            "type": "Microsoft.Resources/deployments",
            "resourceGroup": "[variables('SharedResourceGroup')]",
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {},
                    "variables": {},
                    "resources": [
                        {
                            "name": "[variables('ACRName')]",
                            "type": "Microsoft.ContainerRegistry/registries",
                            "apiVersion": "2017-10-01",
                            "location": "[parameters('location')]",
                            "comments": "Container registry for storing docker images",
                            "sku": {
                                "name": "Standard",
                                "tier": "Standard"
                            },
                            "properties": {
                                "adminUserEnabled": true
                            }
                        },
azure azure-resource-manager arm-template
1个回答
1
投票

您需要使用链接模板,而不是内联模板。带内联模板的东西在部署之前呈现它。所以它渲染它就好像它是父模板的一部分。

{
    "type": "Microsoft.Resources/deployments",
    "apiVersion": "2018-05-01",
    "name": "linkedTemplate",
    "properties": {
        "mode": "Incremental",
        "templateLink": {
            "uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json",
            "contentVersion":"1.0.0.0"
        },
        "parametersLink": {
            "uri": "https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.parameters.json",
            "contentVersion":"1.0.0.0"
        }
    }
}

它将以这种方式工作。我建议不要使用嵌套的内联模板。

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates

© www.soinside.com 2019 - 2024. All rights reserved.