使用Bicep创建BlockBlobStorage存储账户遇参数错误求助
解决Bicep创建存储账户时kind/sku参数无效的问题
问题概述
在西欧区域使用Bicep创建存储账户时,模板部署验证失败,错误提示请求参数kind、sku无效,核心为kind参数值不合法。使用工具版本:AZ CLI 2.57.0、Bicep 0.25.53。
报错详情
{"code": "InvalidTemplateDeployment", "message": "The template deployment 'bicep-deployment-from-ground-up' is not valid according to the validation procedure. The tracking id is '1a94c0f3-1bf2-4b71-8f03-0a2689129899'. See inner errors for details."} Inner Errors: {"code": "PreflightValidationCheckFailed", "message": "Preflight validation failed. Please refer to the details for the specific errors."} Inner Errors: {"code": "InvalidValuesForRequestParameters", "target": "dtcontent", "message": "Values for request parameters are invalid: kind, sku. For more information, see - https://aka.ms/storageaccounttypes"} Inner Errors: {"code": "InvalidValuesForRequestParameters", "target": "dtcontent", "message": "Values for request parameters are invalid: kind."}
原Bicep代码
param location string = resourceGroup().location resource dtcontent 'Microsoft.Storage/storageAccounts@2023-01-01' = { name: 'dtcontent' location: location kind: 'BlockBlobStorage' sku: { name: 'Premium_LRS' } properties: { minimumTlsVersion: 'TLS1_2' publicNetworkAccess: 'Enabled' allowBlobPublicAccess: true accessTier: 'Hot' } resource blobService 'blobServices@2023-01-01' = { name: 'default' resource content 'containers@2023-01-01' = { name: 'content' properties: { publicAccess: 'Container' } } } }
解决方案
问题根源在于高级性能的BlockBlob存储账户不支持配置accessTier参数,该参数仅适用于标准性能的Blob存储账户,多余的配置导致验证逻辑报错(错误提示指向kind属于误导性关联)。
修改步骤
- 删除
properties中的accessTier: 'Hot'配置项; - 保留
kind: 'BlockBlobStorage'与sku.name: 'Premium_LRS'的组合,该组合是合法的高级块Blob存储账户配置。
修改后的Bicep代码
param location string = resourceGroup().location resource dtcontent 'Microsoft.Storage/storageAccounts@2023-01-01' = { name: 'dtcontent' location: location kind: 'BlockBlobStorage' sku: { name: 'Premium_LRS' } properties: { minimumTlsVersion: 'TLS1_2' publicNetworkAccess: 'Enabled' allowBlobPublicAccess: true } resource blobService 'blobServices@2023-01-01' = { name: 'default' resource content 'containers@2023-01-01' = { name: 'content' properties: { publicAccess: 'Container' } } } }
内容的提问来源于stack exchange,提问作者Lukas Heeren
相关产品推荐
相关产品推荐

