Azure 数据工厂 - 在存储事件触发器中使用 typeProperties 参数

Azure Data Factory - Use parameter for typeProperties in storage event trigger

我在类型属性“blobPathBeginsWith”的存储事件触发器中使用参数时遇到问题。默认情况下,当使用存储事件触发器时,typeProperty“范围”出现在 ARMTemplateParamtersForFactory.json 中,并且可以在 CI/CD 进程中针对不同的环境正确设置。

但是,当我使用从 Power Apps 到 Data Lake 的标准集成“Export to datalake”时,Data Lake 中的容器名称因环境而异(且无法更改)。例如

Environment ContainerName
dev dataverse-researchdwhd-xxx1
test dataverse-researchdwhd-xxx2

现在,当我创建一个存储事件触发器并手动填写所有必需信息,包括订阅、存储帐户名称、容器名称、blob 路径开头和结尾时,会自动创建以下类型属性:

        "typeProperties": {
            "blobPathBeginsWith": "/dataverse-researchdwhd-xxx1/blobs/apss_project/Snapshot",
            "blobPathEndsWith": ".csv",
            "ignoreEmptyBlobs": true,
            "scope": "/subscriptions/6fxxxb5a/resourceGroups/rdwh-dev/providers/Microsoft.Storage/storageAccounts/datalakerdwhdev",
            "events": [
                "Microsoft.Storage.BlobCreated"
            ]
        }

触发器发布后,以下参数在 ARMTemplateParametersForFactory.json 中可用,因此可以在发布管道中设置。

        "trigger_snapshot_project_properties_typeProperties_scope": {
            "value": "/subscriptions/6fxxxb5a/resourceGroups/rdwh-dev/providers/Microsoft.Storage/storageAccounts/datalakerdwhdev"
        }

在我的用例中,不仅 typeProperty“范围”依赖于环境,而且 typeProperty“blobPathBeginsWith”也是如此,因为“导出到数据湖”集成自动创建的容器在​​所有环境中都有唯一的名称。因此,我必须以某种方式能够参数化 typeProperty“范围”,以便它可以根据部署的环境在发布管道中进行设置。

到目前为止我尝试了什么:

创建了一个名为“container_name”的全局参数,并尝试手动更新触发器 json 以使用此全局参数。

"blobPathBeginsWith": "parameters('container_name')",

但是,无论参数是否仅包含容器名称(/dataverse-researchdwhd-xxx1/)或整个以路径(/dataverse-researchdwhd-xxx1/blobs/apss_project/Snapshot/)开头,一旦我保存了json和在 UI 中打开触发器,消息“容器名称未以可接受的格式写入”出现在容器名称下拉列表下方。

根据 Microsoft 文档“存储事件触发器示例”(https://docs.microsoft.com/en-us/azure/data-factory/how-to-create-event-trigger),格式应该是正确的,但似乎无法在触发器中引用全局参数。

除了“scope”之外,任何专家都可以引导我在触发器 json 中参数化 typeProperties 的正确方法?

提前致谢!

用例在微软文档中有描述,只是没看对地方:https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-delivery-resource-manager-custom-parameters

在启用了 GIT 的 Azure 数据工厂中,您可以导航到“管理”>“ARM 模板”>“编辑参数配置”。

这将打开 arm-template-parameters-definition.json,您可以在其中添加默认情况下未参数化的属性。对于我的用例,我将参数“blobPathBeginsWith”添加为触发器的“typeProperties”:

"Microsoft.DataFactory/factories/triggers": {
    "properties": {
        "pipelines": [
            {
                "parameters": {
                    "*": "="
                }
            },
            "pipelineReference.referenceName"
        ],
        "pipeline": {
            "parameters": {
                "*": "="
            }
        },
        "typeProperties": {
            "scope": "=",
            "blobPathBeginsWith": "="
        }
    }
}

更改发布后,这会自动更新 adf_publish-branch 中的文件“ARMTemplateParametersForFactory.json”,并为所有触发器添加一个新的参数模拟跟随模式,然后可以在发布管道中使用.

        "trigger_name_properties_typeProperties_blobPathBeginsWith": {
        "value": "/container/blobs/folder/Snapshot"
        }