我正在尝试部署基本文件共享存储帐户。请忽略注释掉的行。当我通过管道进行假设时,我收到此错误图像。我不确定错误是什么,我已经在 param 文件中创建了参数,并在二头肌文件的顶部声明了该参数及其正确的数据类型。
以下是二头肌文件
//--Parameters--//
@description('Specifies the location for resources.')
param saLoc string
@description('Optional. Type of Storage Account to create.')
param saKind string
// The below is optional - if you want to create a fileshare stoarge account with private endpoint, you might need to give the private ip of the private endpoint here
// @description('Specifies the private IP Address of the Storage Account blob private endpoint.')
// param saBlobPrivIp string = ''
@description('Optional. Storage Account Sku Name.')
@allowed([
'Standard_LRS'
'Standard_GRS'
'Standard_RAGRS'
'Standard_ZRS'
'Premium_LRS'
'Premium_ZRS'
'Standard_GZRS'
'Standard_RAGZRS'
])
param saSkuName string
param saShareQuota int
@description('Specifies the storage account to create')
param saName string
@description('Tags for the storage account')
param saTags object
@description('Array of File Shares to create')
param saFileShares array
// The below parameter is optional - if you want to link subnet with privateendpoint
// @description('Subnet to connect Storage Account Private Endpoints')
// param saSubnet string
// The below parameter is optional - if using identity-based authentication settings for Azure Files, then uncomment the below
// @description('Optional. Provides the identity-based authentication settings for Azure Files.')
// param saazureFilesIdentityBasedAuthentication object = {}
//--Variables--//
// Loading values from the JSON file directly, some below are optional - if using private dns zone and domain, add them in envconstants file and uncomment the below
var targetEnv = loadJsonContent('../../envconstants.json', 'targetEnvironment')
// var privDNSZoneId = loadJsonContent('../../envconstants.json', 'privDNSZoneId')
// var domain = loadJsonContent('../../envconstants.json', 'domain')
// Extracting specific values from the JSON, some below are optional - if using managed domain add that in stoarge account, add that in envconstants file and uncomment this
// var privDnsZoneFileCore = privDNSZoneId.fileCore
// var mgDomainGuid = domain.managedDomainGuid
// var mgDomainName = domain.managedDomainName
// Enable Private Endpoints, the below is optional - if using private endpoint in stoarge account, keep this to true
// var deployStorageAccPrivateEndpoints = false
//--Modules--//
module storageAccount 'br/public:avm/res/storage/storage-account:0.12.0' = {
name: saName
scope: resourceGroup(targetEnv.subId, targetEnv.resourceGrp)
params: {
location: saLoc
kind: saKind
skuName: saSkuName
// Required parameters
name: toLower(saName)
// Non-required parameters
allowBlobPublicAccess: false
publicNetworkAccess: 'Disabled'
requireInfrastructureEncryption: true
sasExpirationPeriod: '30.00:00:00'
networkAcls: {
bypass: 'AzureServices'
defaultAction: 'Deny'
}
tags: saTags
// azureFilesIdentityBasedAuthentication: !empty(saazureFilesIdentityBasedAuthentication) ? {
// activeDirectoryProperties: {
// domainGuid: mgDomainGuid
// domainName: mgDomainName
// }
// defaultSharePermission: saazureFilesIdentityBasedAuthentication.defaultSharePermission
// directoryServiceOptions: 'AADDS'
// } : {}
fileServices: !empty(saFileShares) ? {
shareDeleteRetentionPolicy: {
days: 7
enabled: true
}
shares: saFileShares
shareQuota: saShareQuota
tags: saTags
} : {}
// privateEndpoints: deployStorageAccPrivateEndpoints ? [
// !empty(saFilePrivIp) ? {
// privateDnsZoneResourceIds: [ privDnsZoneFileCore ]
// name: '${saName}-${saLoc}-file-pep'
// service: 'file'
// location: saLoc
// subnetResourceId: saSubnet
// customNetworkInterfaceName: '${saName}-${saLoc}-file-nic'
// ipConfigurations: [
// {
// name: '${saName}-file-ipconf'
// properties: {
// groupid: 'file'
// membername: 'file'
// privateIPAddress: saFilePrivIp
// }
// }
// ]
// tags: {
// 'hidden-title': saName
// }
// } : {
// privateDnsZoneResourceIds: [ privDnsZoneFileCore ]
// name: '${saName}-${saLoc}-file-pep'
// service: 'file'
// location: saLoc
// subnetResourceId: saSubnet
// customNetworkInterfaceName: '${saName}-${saLoc}-file-nic'
// tags: {
// 'hidden-title': saName
// }
// }
// ] : []
}
}
以下是bicepparam文件
param saName = 'testfileshare'
param saLoc = 'South Central US'
param saKind = 'StorageV2'
param saShareQuota = 200
param saSkuName = 'Standard_LRS'
param saFileShares = [{ name: 'default' }]
param saTags = {
environment: 'TEST-PERSONAL-REPO'
created_by: 'bicep'
}
使用 Bicep 创建文件共享存储帐户。
在这些情况下,参数可能与您在模块和文件顶层声明的拼写或参数类型相同。
从错误描述来看,错误似乎与您传递参数的方式有关。从错误描述中我可以清楚地识别出参数中多余的空格。
模板参数
'param saName '
删除 saName 后面的多余空格,这会导致您面临这个问题。
实际的参数输入看起来像这样
'param saName'
这就是二头肌期望的输入参数。
我尝试了带有相关输入的演示配置,并且能够提供需求。
配置:
param saLoc string
param saKind string = 'StorageV2'
param saShareQuota int = 100
param saSkuName string = 'Standard_LRS'
param saName string
param saTags object
param saFileShares array = []
module storageAccount 'br/public:avm/res/storage/storage-account:0.12.0' = {
name: saName
scope: resourceGroup('98bccad1-ca91-4b24-83d6-78dfd797ff89', 'vinay-rg')
params: {
location: saLoc
kind: saKind
skuName: saSkuName
name: toLower(saName)
allowBlobPublicAccess: false
publicNetworkAccess: 'Disabled'
requireInfrastructureEncryption: true
sasExpirationPeriod: '30.00:00:00'
networkAcls: {
bypass: 'AzureServices'
defaultAction: 'Deny'
}
tags: saTags
fileServices: length(saFileShares) > 0 ? {
shareDeleteRetentionPolicy: {
days: 7
enabled: true
}
shares: saFileShares
shareQuota: saShareQuota
tags: saTags
} : {}
}
}
部署:
参考: