使用 arm 模板部署存储帐户时遇到问题
Posted
技术标签:
【中文标题】使用 arm 模板部署存储帐户时遇到问题【英文标题】:I am facing an issue while deploy storage account using arm templates 【发布时间】:2019-11-13 18:00:17 【问题描述】:我在:
部署模板验证失败:'模板资源'sneha1' 对于类型 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Common.Entities.TemplateGenericProperty`1[System.String]' 在“20”行和“59”列的段长度不正确。一个嵌套 资源类型必须具有与其资源相同数量的段 姓名。根资源类型的段长度必须大于 1 它的资源名称。
这是我的模板:
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters":
"storageAccounts_sneha_name":
"defaultValue": "sneha,
"type": "String"
,
"variables": ,
"resources": [
"type": "Microsoft.Storage/storageAccounts/sneha",
"apiVersion": "2019-04-01",
"name": "[concat(parameters('storageAccounts_sneha_name'), copyIndex(1) ) ]",
"location": "centralus",
"copy":
"Name":"rama",
"count": 5
,
"sku":
"name": "Standard_LRS",
"tier": "Standard"
,
"kind": "StorageV2",
"properties":
"networkAcls":
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
,
"supportsHttpsTrafficOnly": true,
"encryption":
"services":
"file":
"enabled": true
,
"blob":
"enabled": true
,
"keySource": "Microsoft.Storage"
,
"accessTier": "Hot"
,
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2019-04-01",
"name": "[concat(parameters('storageAccounts_sneha_name'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_sneha_name'))]"
],
"properties":
"cors":
"corsRules": []
,
"deleteRetentionPolicy":
"enabled": false
,
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-04-01",
"name": "[concat(parameters('storageAccounts_sneha_name'), '/default/container1')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_sneha_name'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_sneha_name'))]"
],
"properties":
"publicAccess": "Blob"
]
【问题讨论】:
【参考方案1】:它说的是资源sneha1
名称格式错误,如果您可以分享资源名称我可以帮助您修复它,但简而言之,名称应该比类型短 1 段:
name: "xxx",
type: "microsoft.storage/storageAccounts"
或者像这样:
name: "xxx/diag",
type: "microsoft.storage/storageAccounts/diagnosticSettings"
【讨论】:
【参考方案2】:如果您的 name 属性的长度大于 TYPE
,则会出现此问题"apiVersion": "2016-12-01",
"name": "[concat(parameters('vaultName'), '/', parameters('policyName'))]",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies"
在上面的例子中,名称有两级,类型有3级。
示例如下图:
"name":"azVault/policy1"
"type":"Microsoft.RecoveryServices/vaults/backupPolicies"
【讨论】:
【参考方案3】:这可能是您的问题,删除类型中的 sneha 并尝试。
"type": "Microsoft.Storage/storageAccounts/sneha", "name": "[concat(parameters('storageAccounts_sneha_name'), '/copyIndex(1)' ) ]",
【讨论】:
以上是关于使用 arm 模板部署存储帐户时遇到问题的主要内容,如果未能解决你的问题,请参考以下文章
如何为具有防火墙后存储帐户的 sql server 启用 arm 模板漏洞评估
无法通过 ARM 模板将 CMK 加密应用于 Azure 存储帐户
使用 Azure ARM 部署Word Press 遇到 Extension节点 扩展的问题