d29*_*907 5 azure-data-factory azure-pipelines error-messaging
Azure 数据工厂中管道的最后一步执行另一个管道,其中包含笔记本步骤。作为我的要求的一部分,我需要在该步骤失败时捕获错误消息的详细信息(将其存储在数据库中)。

但是,最后一步的输出不提供此信息,仅提供指向另一个信息的链接。我的挑战是我无法修改“内部”管道来获取该数据(我们对错误的 URL 感兴趣),我需要从我创建的管道开始执行所有操作。
不幸的是,我无法找到任何可能的解决方案或文档来尝试解决此问题。如果您能给我任何建议,我将不胜感激。
任何活动都将以如下格式存储输出。
@activity('*activityName*').output.*subfield1*.*subfield2*
Run Code Online (Sandbox Code Playgroud)
要在活动失败时访问输出,您可以选择添加活动 failure stream并用于设置变量。
但是,在这种情况下,由于正在执行另一个管道,因此返回到父管道(ExecutePipeline活动)的输出只是 ChildPipelineName和PipelineRunId。
因此,让我们利用这个 PipelineRunId。让我们使用 WebActivity 来调用 REST API Activity Runs - Query By Pipeline Run
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelineruns/{runId}/queryActivityruns?api-version=2018-06-01
Run Code Online (Sandbox Code Playgroud)
1.从 ExecutePipeline 活动输出获取PipelineRunId并将其设置为变量。
错误输出: @activity('Execute Pipeline').output.pipelineRunId
2.使用这个run id动态形成url
网址: https://management.azure.com/subscriptions/b83c1ed3-xxxx-xxxx-xxxx-2b83a074c23f/resourceGroups/myrg/providers/Microsoft.DataFactory/factories/ktestadf/pipelineruns/@{variables('pipelineRunId')}/queryActivityruns?api-version=2018-06-01
3.现在准备 REST API 调用。使用url已经准备好的。设置方法 POST、标头和正文。
请求正文是查询管道运行的时间范围。我们将在动态调用之前和之后设置 1 小时的窗口。
方法:邮寄
标头:内容类型:application/json
身体: {"lastUpdatedAfter":getPastTime(1, 'Hour'),"lastUpdatedBefore":getFutureTime(1, 'Hour')}
身份验证: 如果使用 MSI 设置资源:https://management.azure.com/
4.最后将该错误消息存储在另一个数组变量中,您可以从中解析数组并根据需要存储到 SQL 接收器。
这是它的内容。
{
"name": "ErrorMsg",
"value": [
{
"activityRunEnd": "2021-10-14T07:43:20.1291832Z",
"activityName": "Notebook",
"activityRunStart": "2021-10-14T07:43:18.3867797Z",
"activityType": "DatabricksNotebook",
"durationInMs": 1742,
"retryAttempt": null,
"error": {
"errorCode": "2011",
"message": "Caller was not found on any access policy in this key vault, secretName: databricksclientsecret, secretVersion: , vaultBaseUrl: https://ktestkeyvaults.vault.azure.net/. The error message is: The user, group or application 'name=Microsoft.DataFactory/factories;appid=3ecdccaf-xxxx-xxxx-8818-4f30b45856eb;oid=7ee614a9-xxxx-xxxx-a7cd-fbad1afc715b;iss=https://sts.windows.net/72f988bf-xxxx-41af-91ab-2d7cd011db47/' does not have secrets get permission on key vault 'ktestkeyvaultss;location=eastus'. For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125287.",
"failureType": "UserError",
"target": "Notebook",
"details": []
},
"activityRunId": "6c9519e1-b646-4d5b-a974-29bef371d7e5",
"iterationHash": "",
"input": {
"notebookPath": "https://adb-7020907718042127.7.azuredatabricks.net/?o=7020907718041127#notebook/171399934287251/command/171399934287255"
},
"linkedServiceName": "",
"output": {
"effectiveIntegrationRuntime": "DefaultIntegrationRuntime (Central US)",
"executionDuration": 0,
"durationInQueue": {
"integrationRuntimeQueue": 1
},
"billingReference": {
"activityType": "ExternalActivity",
"billableDuration": [
{
"meterType": "AzureIR",
"duration": 0.016666666666666666,
"unit": "Hours"
}
]
}
},
"userProperties": {},
"pipelineName": "error2",
"pipelineRunId": "6a717388-516e-46d7-883c-fdcf2d517bd8",
"status": "Failed",
"recoveryStatus": "None",
"integrationRuntimeNames": [
"defaultintegrationruntime"
],
"executionDetails": {
"integrationRuntime": [
{
"name": "DefaultIntegrationRuntime",
"type": "Managed",
"location": "Central US"
}
]
},
"id": "/SUBSCRIPTIONS/B83C2ED3-xxxx-xxxx-xxxx-2B80A074C23F/RESOURCEGROUPS/myrg/PROVIDERS/MICROSOFT.DATAFACTORY/FACTORIES/KTESTADF/pipelineruns/6a717388-516e-46d7-883c-fdcf2d517bd8/activityruns/6c9519e1-b646-4d5b-a974-29bef371d7e5"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我有不同的错误消息,您会类似地找到所需的 URL。
小智 6
@activity('activityname').Error.message
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19922 次 |
| 最近记录: |