我正在尝试在Azure数据工厂中添加参数,以便我可以覆盖每个开发、测试和生产环境的参数值。目前我已在 DevOps Release 中设置静态字符串作为参数值。
但是我从 Azure DevOps 中收到奇怪的错误。 我想知道为什么数据工厂将参数名称保存为“Web pipeline_properties_parameters_LogicAppURL_defaultValue”,Web 后面有空格。
已编辑“ARM模板”->“编辑参数配置”并发布参数:
“Microsoft.DataFactory/工厂/管道”:{ “特性”: { “参数”: { “逻辑应用URL”:{ “默认值”:“=” } } }
ARMTemplateParametersForFactory.json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"factoryName": {
"value": "my-warehouse-dev-df"
},
"Web pipeline_properties_parameters_LogicAppURL_defaultValue": {
"value": "http://www.devpipeline.fi"
}
}
}
创建发布时出错:
The detected encoding for file 'D:\a\r1\a\_Azure Data
Factory DevOps-CI\drop\ARMTemplateForFactory.json' is 'utf-8'
The detected encoding for file 'D:\a\r1\a\_Azure Data
Factory DevOps-CI\drop\ARMTemplateParametersForFactory.json' is 'utf-8'
There was an error while overriding 'Web' parameter
because of 'TypeError: Cannot read property 'type' of undefined', make sure it
follows JavaScript Object Notation (JSON)
There was an error while overriding '' parameter
because of 'TypeError: Cannot read property 'type' of undefined', make sure it
follows
JavaScript Object Notation (JSON)
Starting template validation.
Deployment name is ARMTemplateForFactory-20211220-162118-0e5d
There were errors in your deployment. Error code:
InvalidDeploymentParameterKey.
##[error]One of the deployment parameters has an empty
key. Please see https://aka.ms/resource-manager-parameter-files for details.
这是一个已知问题。正如错误所示,尝试如下编辑参数名称。
但是,将其放在
" "
之间就足够了。
"Web_pipeline_properties_parameters_LogicAppURL_defaultValue"
另外,如果您想默认将参数值保留为空,您可以设置如下:
"Microsoft.DataFactory/factories/pipelines": {
"properties": {
"parameters": {
"LogicAppURL": {
"defaultValue": {}
}
}
}
并且在覆盖模板参数时,使用:
-param "value"
什么对我有用:
在数据工厂选项卡上,转到管理>ARM 模板> 在 ARM 模板中包含全局参数。将尚未参数化的任何参数添加到arm-template-parameters-definition.json 文件中。将arm-template-parameters-definition.json 文件添加到数据工厂工件所在的 DevOps 存储库中。
部署到不同环境时,使用
- task: AzureKeyVault@2
inputs:
azureSubscription: ${{ variables.service_connection }}
KeyVaultName: ${{ variables.kv_name }}
SecretsFilter: 'exampleValue,anotherValue'
displayName: 'get environment-specific secrets'
- task: AzureResourceManagerTemplateDeployment@3
inputs:
azureResourceManagerConnection: ${{ variables.service_connection }}
subscriptionId: $(SubscriptionId)
location: ${{ variables.location }}
templateLocation: 'Linked artifact'
csmFile: '$(Pipeline.Workspace)/ARMTemplateForFactory.json'
csmParametersFile:'$(Pipeline.Workspace)/ARMTemplateParametersForFactory.json'
overrideParameters: '
-example_properties_typeProperties_value $(exampleValue)
-another_properties_typeProperties_value $(anotherValue)
-factoryName "${{ variables.factory_name }}"'
deploymentMode: 'Incremental'