【问题标题】:Wildcard in blob ends with path - ADF trigger blob storage eventblob 中的通配符以路径结尾 - ADF 触发 blob 存储事件
【发布时间】:2023-01-10 02:23:35
【问题描述】:

我有一个像这样的 blob 结构:

> data/
>     folder1/
>            dirA/
>            dirB/
>            dirC/
>                 file1.csv
>                 file2.csv
>                 file3.csv
>     dir2/
>            dirA/
>            dirB/
>            dirC/
>                 file1.csv
>                 file2.csv
>                 file3.csv
>     source3/
>            dirA/
>            dirB/
>            dirC/
>                 file1.csv
>                 file2.csv
>                 file3.csv

我想在任何 csv 文件仅上传到 source3/dirC 时触发 blob 存储事件。

问题是 adf 在这里不支持通配符路径。我想要这样的东西:

Blob_path_ends_with:any_dir(exclude folder1 include dir2,source3)/dirC/*.csv (any csv file in dirC in any main directory)

所以我想忽略 folder1 中的任何 csv 上传,但在 dir2 和 source3 中上传文件时触发事件。

【问题讨论】:

  • 根据 ADF 中的 Documentation,当前存储事件触发器不支持通配符路径。看到这个i.imgur.com/ZIjNANi.png
  • 因此,如果您只想在这种情况下使用存储事件触发器,请在该容器上的每个文件上触发,然后使用触发器 filePath 参数过滤管道中包含所需文件夹的文件。

标签: azure-data-factory azure-data-factory-2 azure-data-factory-pipeline


【解决方案1】:

正如 Rakesh Govindula 所提到的,路径开始于以。。结束是唯一的模式匹配存储事件触发器中允许.触发器类型不支持其他类型的通配符匹配。

但是,您可以使用逻辑应用解决此问题,如下所示:

重现步骤:

  1. 创建事件网格系统主题 (Documentaion)
    选择存储帐户(Blob 和 GPv2)对于主题类型。您可以为主题选择任何名称。

  2. 创建具有 http 触发器类型的逻辑应用
    将以下Event Grid Event Schema 粘贴到逻辑应用程序的 http 触发器请求正文 JSON 模式场地:

    [{
      "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
      "subject": "/blobServices/default/containers/test-container/blobs/new-file.txt",
      "eventType": "Microsoft.Storage.BlobCreated",
      "eventTime": "2017-06-26T18:41:00.9584103Z",
      "id": "831e1650-001e-001b-66ab-eeb76e069631",
      "data": {
        "api": "PutBlockList",
        "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
        "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
        "eTag": ""0x8D4BCC2E4835CD0"",
        "contentType": "text/plain",
        "contentLength": 524288,
        "blobType": "BlockBlob",
        "url": "https://my-storage-account.blob.core.windows.net/testcontainer/new-file.txt",
        "sequencer": "00000000000004420000000000028963",
        "storageDiagnostics": {
          "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
        }
      },
      "dataVersion": "",
      "metadataVersion": "1"
    }]
    

    在设计器中保存逻辑应用并复制其中的内容HTTP 发布网址场地。您将在接下来使用它。

    1. 为存储帐户创建事件订阅 (Documentation)
      在系统主题名称字段中输入您在步骤 1 中创建的事件网格系统主题。选择 Webhook 端点类型并粘贴您在步骤 2 中复制的 HTTP POST URL。 准备就绪后,可以测试将文件上传到存储是否会触发逻辑应用。转到逻辑应用并检查日志(http 触发器的原始输出)

    2. 如果 http 请求的 body().data.url 参数不包含您需要的路径,则向逻辑应用添加条件步骤以停止工作流。

    3. 将数据工厂管道运行步骤添加到逻辑应用。 (Useful blogpost)
      您可以将路径字符串作为管道参数从 http 主体传递:body().data.url

    我希望您可以按照我描述的步骤进行操作,无需截图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-27
    • 2020-06-05
    • 1970-01-01
    • 2021-11-05
    • 2019-10-08
    • 1970-01-01
    • 2019-11-16
    • 1970-01-01
    相关资源
    最近更新 更多