如何在 Azure DevOps Pipeline 中覆盖数据工厂的参数? - ARM 模板中的空 space 会导致错误吗?

How to overwrite parameter of Data Factory in Azure DevOps Pipeline? - Empty space in ARM Template cause errors?

我正在尝试在 Azure 数据工厂中添加参数,以便我可以覆盖每个开发、测试和生产环境的参数值。目前我在 DevOps Release 中设置了静态字符串作为参数值。

但是我从 Azure DevOps 收到奇怪的错误。 我想知道为什么数据工厂将参数名称保存为“Web pipeline_properties_parameters_LogicAppURL_defaultValue”,它在 Web.

之后为空 space
  1. 已编辑“ARM模板”->“编辑参数配置”并发布参数:

    “微软。DataFactory/factories/pipelines”:{ “特性”: { “参数”: { “LogicAppURL”:{ “默认值”:“=” } } }

  2. ARMTemplateParametersForFactory.json 在 Git 回购:

     {
     "$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"