使用Bicep部署Azure Data Factory时出现参数缺失错误
问题描述
我参考微软官方的文件移动模板,用Bicep部署Azure Data Factory(ADF)。在ADF UI里编辑运行管道一切正常,但从ADF导出ARM模板转换成带相同参数的Bicep模板后,部署时收到错误:
Status Message: Missing parameter definition for SourceStore_Location,SourceStore_Directory
我能不能这么引用参数?有没有人做过类似操作?
resource dataFactoryPipeline 'Microsoft.DataFactory/factories/pipelines@2018-06-01' = { parent: dataFactory name: pipelineName properties: { parameters: { SourceStoreLocation : { type: 'String' defaultValue: 'xxxx\\xxxx\\xxxx\\xxxx' } DestinationStoreLocation : { type: 'String' defaultValue: 'xxxx\\xxxx' } SourceStoreDirectory : { type: 'String' defaultValue: 'xxxx' } DestinationStoreDirectory : { type: 'String' defaultValue: 'xxxx' } } activities: [ { name : 'GetFileList' type: 'GetMetadata' typeProperties: { dataset: { referenceName: sourceDataSetName type: 'DatasetReference' parameters: { FolderPath: { value : '@pipeline().parameters.SourceStore_Location' type: 'Expression' } Directory: { value: '@pipeline().parameters.SourceStore_Directory' type: 'Expression' } } } fieldList: ['childItems'] storeSettings: { type: 'FileServerReadSettings' recursive: true } formatSettings: { type: 'DelimitedTextReadSettings' } } } { name : 'FilterFiles' type: 'Filter' dependsOn: [ { activity: 'GetFileList' dependencyConditions: [ 'Succeeded' ] } ] typeProperties: { items:{ value: '@activity(\'GetFileList\').output.childItems' type: 'Expression' } condition: { value: '@equals(item().type, \'File\')' type: 'Expression' } } } { name : 'ForEachFile' type: 'ForEach' dependsOn: [ { activity: 'FilterFiles' dependencyConditions: [ 'Succeeded' ] } ] typeProperties: { items: { value : '@activity(\'FilterFiles\').output.value' type : 'Expression' } activities: [ { name : 'CopyFile' type: 'Copy' typeProperties: { source: { type: 'DelimitedTextSource' storeSettings: { type: 'FileServerReadSettings' recursive: true } formatSettings: { type: 'DelimitedTextReadSettings' } } sink: { type: 'DelimitedTextSink' storeSettings: { type: 'AzureFileStorageWriteSettings' } formatSettings: { type: 'DelimitedTextWriteSettings' quoteAllText: true fileExtension: '.txt' } } } inputs: [ { referenceName: sourceDataSetFileName type: 'DatasetReference' parameters: { FolderPath: { value : '@pipeline().parameters.SourceStore_Location' type: 'Expression' } Directory: { value: '@pipeline().parameters.SourceStore_Directory' type: 'Expression' } FileName: { value: '@item().name' type: 'Expression' } } } ] outputs: [ { referenceName: sinkDataSetName type: 'DatasetReference' parameters: { FolderPath: { value : '@pipeline().parameters.SourceStore_Location' type: 'Expression' } Directory: { value: '@pipeline().parameters.SourceStore_Directory' type: 'Expression' } FileName: { value: '@item().name' type: 'Expression' } } } ] } { name : 'DeleteFiles' type: 'Delete' dependsOn: [ { activity: 'CopyFile' dependencyConditions: [ 'Succeeded' ] } ] typeProperties: { dataset: { referenceName: sourceDataSetFileName type: 'DatasetReference' parameters: { FolderPath: { value : '@pipeline().parameters.SourceStore_Location' type: 'Expression' } Directory: { value: '@pipeline().parameters.SourceStore_Directory' type: 'Expression' } FileName: { value: '@item().name' type: 'Expression' } } } storeSettings: { type: 'FileServerReadSettings' recursive: true } } } ] } } ] } dependsOn: [ sinkDataSet sourceDataSet sourceDataSetFile ] }
解决方案
错误核心是管道参数定义名和表达式引用名不匹配:
- 你在管道
parameters里定义的是SourceStoreLocation、SourceStoreDirectory(无中间下划线) - 但活动表达式里引用的是
SourceStore_Location、SourceStore_Directory(多了中间下划线)
有两种修正方式:
- 修改管道参数名,和表达式保持一致:将
SourceStoreLocation改为SourceStore_Location,SourceStoreDirectory改为SourceStore_Directory - 修改表达式引用,和管道参数名保持一致:将所有
@pipeline().parameters.SourceStore_Location改为@pipeline().parameters.SourceStoreLocation,@pipeline().parameters.SourceStore_Directory改为@pipeline().parameters.SourceStoreDirectory
另外,ARM转Bicep的过程偶尔会出现这类命名格式偏差,部署前一定要核对参数定义和引用的名称完全一致。
内容的提问来源于stack exchange,提问作者ProgH
相关产品推荐
相关产品推荐

