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

ADF中Web活动在ForEach内执行失败,单独运行正常求助

问题分析与解决方案

问题现象

Azure Data Factory(ADF)管道使用ForEach活动遍历多站点,通过@concat动态生成HTTP端点传入Web活动。第一个迭代的Web活动返回授权拒绝错误,但单独运行该Web活动可成功,后续其他站点迭代也能正常执行。

第一个迭代Web活动输入

{"method": "GET", "headers": {}, "disableCertValidation": true, "turnOffAsync": false, "url": "https://xx.xx.xx.xxx/piwebapi/dataservers?Name=XXX-XX44", "connectVia": {"referenceName": "xx-xxx-sandbox-adf-01-shir", "type": "IntegrationRuntimeReference"}, "authentication": {"type": "Basic", "username": "uname", "password": {"type": "SecureString", "value": "**********"}}}

错误输出

{"Message": "Authorization has been denied for this request.", "ADFWebActivityResponseHeaders": {"Transfer-Encoding": "chunked", "X-Frame-Options": "SAMEORIGIN", "Content-Security-Policy": "default-src 'self'", "Cache-Control": "no-cache", "Date": "Wed, 17 Sep 2025 02:11:32 GMT", "Server": "Microsoft-HTTPAPI/2.0", "WWW-Authenticate": "Negotiate;Basic realm=\"PI Web API\"", "Content-Type": "application/json; charset=utf-8"}, "effectiveIntegrationRuntime": "xx-xxx-xxxx-xxx-01-xxx(xx-xxx-xxxx-xxx-01-xxx)", "executionDuration": 0, "durationInQueue": {"integrationRuntimeQueue": 5}, "billingReference": {"activityType": "ExternalActivity", "billableDuration": [{"meterType": "SelfhostedIR", "duration": 0.016666666666666666, "unit": "Hours"}]}}

排查与解决方向

  • 调整ForEach并发度:ForEach默认并发执行(默认并发度20),第一个迭代可能在身份验证上下文初始化完成前发起请求。将并发度设为1,改为串行执行验证是否解决问题。
  • 添加初始化延迟:在Web活动前增加Wait活动(设置1-2秒延迟),确保@concat生成的动态参数完全初始化后再执行请求。
  • 优化凭据引用方式:避免直接在Web活动中嵌入密码,改用Azure Key Vault存储密码,通过@secrets('kv-name','secret-name')引用,确保SHIR能正确加载认证凭据。
  • 对比请求日志:开启ADF管道诊断日志,对比单独运行与循环中运行的Web活动请求头,确认第一个迭代的认证头是否正确传递。
  • 添加预热请求:在第一个迭代前添加一个简单的API根路径GET请求,提前建立会话,规避目标PI Web API的首次请求验证限制。

内容的提问来源于stack exchange,提问作者Balajee Addanki

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 08:52:41