azure-pipelines - 如何获取 Azure 数据工厂管道中错误消息的详细信息

标签 azure-pipelines azure-data-factory error-messaging

我在 Azure 数据工厂中的管道的最后一步执行另一个管道,其中包含一个笔记本步骤。作为我要求的一部分,我需要在此步骤失败时捕获错误消息的详细信息(将其存储在数据库中)。 enter image description here

但是,最后一步的输出不提供此信息,只提供到另一个的链接。我的挑战是我无法修改“内部”管道来获取该数据(我们对错误的 URL 感兴趣),我需要从我创建的管道开始做所有事情。

不幸的是,我无法找到任何可能的解决方案或文档来尝试解决这个问题。如果您能给我任何建议,我将不胜感激。

最佳答案

任何事件都将以如下格式存储输出。

@activity('*activityName*').output.*subfield1*.*subfield2*

要访问失败事件的输出,您可以选择 失败流上添加事件并用于设置变量。

但是,在这种情况下,由于正在执行另一个管道,其返回到父管道(ExecutePipeline 事件)的输出只是子 PipelineName 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

1. 从 ExecutePipeline 事件输出中获取 PipelineRunId 并设置为变量。

enter image description here

enter image description here

错误输出: @activity('Execute Pipeline').output.pipelineRunId

enter image description here

2.使用这个run id动态形成url

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

enter image description here

3. 现在准备调用 REST API。使用已经准备好的url。设置方法 POST、 header 和正文。

enter image description here

请求的主体是查询管道运行的时间范围。我们将在动态调用之前和之后设置一个 1 小时的窗口。

方法: POST

标题:内容类型:application/json

正文: {"lastUpdatedAfter":getPastTime(1, 'Hour'),"lastUpdatedBefore":getFutureTime(1, 'Hour')}

身份验证:如果使用 MSI 集资源:https://management.azure.com/

4. 最后将该错误消息存储在另一个数组变量中,您可以从中解析数组并根据需要存储到 SQL 接收器。

enter image description here

这是它的内容。

{
    "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"
        }
    ]
}

我有一条不同的错误消息,您会类似地找到所需的 URL。

enter image description here

关于azure-pipelines - 如何获取 Azure 数据工厂管道中错误消息的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69562327/

相关文章:

azure - 按上次提交构建 Azure Pipeline

git - 如何在 Azure CI 管道上进行 git diff

python-3.x - 在Python中使用try和except时如何仍然显示错误消息

yaml - VSTS - Android 签名 - 安全文件不存在或未被授权使用

azure-devops - 设置默认构建代理 VSTS

c# - 使用 VSTS 的数据工厂 V1 的 CI/CD 管道

azure - 通过azure数据工厂将数据从oracle复制到azure blob存储

azure-data-factory - 使用参数的 Azure 数据工厂数据流表达式生成器

vba - 保护非空单元格VBA