ARM 模板为存储容器类型数组抛出不正确的段长度 [英] ARM template throws incorrect segments lengths for array of storage containers types

查看:21
本文介绍了ARM 模板为存储容器类型数组抛出不正确的段长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到 模板验证失败:类型为Microsoft.WindowsAzure.ResourceStack.Frontdoor.Common.Entities.TemplateGenericProperty`1[System.String]"的模板资源reports"位于34"行和列79"的段长度不正确.嵌套资源类型必须具有与其资源名称相同数量的段.根资源类型的段长度必须比其资源名称大 1.请参阅 https://aka.ms/arm-template/#resources 了解使用详情. 当我让 ARM 从参数文件中的数组创建容器时.

I am getting Template validation failed: The template resource 'reports' for type 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Common.Entities.TemplateGenericProperty`1[System.String]' at line '34' and column '79' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-template/#resources for usage details. when I make ARM to create containers from the array in parameters file.

问题行:type":Microsoft.Storage/storageAccounts/blobServices/containers",

这是我的 ARM template 文件.

Here is my ARM template file.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccountName": {
            "type": "string",
            "metadata": {
                "description": "The name of the storage account"
            }
        },
        "storageContaners": {
            "type": "string",
            "metadata": {
                "description": "The name of the blob containers"
            }
        }
    },
    "functions": [],
    "variables": {
    },
    "resources": [
        {
            "name": "[parameters('storageAccountName')]",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2021-04-01",
            "location": "[resourceGroup().location]",
            "kind": "StorageV2",
            "sku": {
                "name": "Standard_LRS",
                "tier": "Standard"
            }
        },
        {
            "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
            "apiVersion": "2021-04-01",
            "name": "[parameters('storageContaners')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "properties": {
                "publicAccess": "Blob"
            }
        }
    ],
    "outputs": {}
}

这是我的 ARM 参数 文件.

Here is my ARM parameters file.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccountName": {
            "value": "mystorageaccount"
        },
        "storageContaners": {
            "value":  "reports"
        }
    }
}

我尝试将 name 更改为不同的类型,但没有成功.
谁能帮我找出原因?

I have tried changing name to different types but no luck.
Can anybody please help me to figure it out the cause?

推荐答案

嵌套资源下的name参数必须比type<一级/代码>.
这里 type4 级(由 3 个 / 分隔).
所以name必须有3级(用2个/隔开).
类型":Microsoft.Storage/storageAccounts/blobServices/containers",
"name": "[concat(parameters('storageAccountName'), '/default/', parameters('storageContaners')]",
这适用于在父资源下有嵌套资源的情况.

The name parameters under the nested resources must be one level less than the type.
Here type has 4 level(separated by 3 / ).
So name must have 3 level (separated by 2 /).
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"name": "[concat(parameters('storageAccountName'), '/default/', parameters('storageContaners')]",
This applies when having nested resources under parent resource.

这篇关于ARM 模板为存储容器类型数组抛出不正确的段长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆