You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Azure Data Factory按时间戳筛选复制Azure存储账号文件

基于Azure Data Factory实现指定UTC时间段文件复制解决方案

核心逻辑说明

你需要筛选的时间区间为UTC每日19:00到次日8:00,属于跨天时间段,需要通过动态表达式判断当前触发时间所属的时段,生成对应的过滤起止时间。

方案1:使用复制活动内置「按上次修改时间过滤」功能

这是你原本尝试的方案,直接填写正确的动态表达式即可:

过滤起始时间(UTC) 表达式(复制时需删除换行改为一行)

@if(greaterOrEquals(int(formatDateTime(utcNow(),'HH')), 19), convertToUtc(formatDateTime(utcNow(), 'yyyy-MM-dd 19:00:00')), convertToUtc(formatDateTime(addDays(utcNow(), -1), 'yyyy-MM-dd 19:00:00')))

过滤结束时间(UTC) 表达式(复制时需删除换行改为一行)

@if(greaterOrEquals(int(formatDateTime(utcNow(),'HH')), 19), convertToUtc(formatDateTime(addDays(utcNow(), 1), 'yyyy-MM-dd 08:00:00')), convertToUtc(formatDateTime(utcNow(), 'yyyy-MM-dd 08:00:00')))

简化场景说明

如果你的管道固定在UTC 8:00之后触发,仅需要拉取前一天19:00到当天8:00的文件,可以直接使用简化版表达式:

  • 起始时间:@convertToUtc(formatDateTime(addDays(utcNow(), -1), 'yyyy-MM-dd 19:00:00'))
  • 结束时间:@convertToUtc(formatDateTime(utcNow(), 'yyyy-MM-dd 08:00:00'))

方案2:Get Metadata + Filter 组合方案(兼容复杂过滤逻辑)

如果内置过滤器无法满足后续扩展需求,可以用此流程实现:

  1. 添加Get Metadata活动,关联源存储容器,待获取字段选择Child Items、Last Modified
  2. 添加Filter活动,输入项关联Get Metadata输出:@activity('Get Metadata').output.childItems,过滤条件填写:
@or(greaterOrEquals(int(formatDateTime(item().lastModified, 'HH')),19), lessOrEquals(int(formatDateTime(item().lastModified, 'HH')),8))
  1. 添加ForEach活动,遍历Filter的输出结果,每个子项单独执行复制活动即可。

内容的提问来源于stack exchange,提问作者Gourav Joshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 15:45:06