首页 > 解决方案 > 通过 Web 活动使用 Azure 事件中心进行数据工厂 MSI 身份验证

问题描述

我正在尝试通过数据工厂的 Web 活动向事件中心发送消息。

我的数据工厂设置有系统分配的托管标识 (MSI),并且该标识已在事件中心命名空间 (RBAC / IAM) 上被赋予“Azure 事件中心数据发送者”角色。

Web活动设置如下:

{
    "name": "Send to Event Hub",
    "type": "WebActivity",
    "dependsOn": [],
    "policy": {
        "timeout": "7.00:00:00",
        "retry": 0,
        "retryIntervalInSeconds": 30,
        "secureOutput": false,
        "secureInput": false
    },
    "userProperties": [],
    "typeProperties": {
        "url": "https://<eventhubnamespace>.servicebus.windows.net/<eventhub>/messages?timeout=60&api-version=2014-01",
        "method": "POST",
        "body": {
            "DeviceId": "dev-01",
            "Temperature": "37.0"
        },
        "authentication": {
            "type": "MSI",
            "resource": "https://servicebus.azure.net"
        }
    }
}

不幸的是,该请求似乎总是未经授权的。Web 活动失败并显示以下消息:

{
    "errorCode": "2108",
    "message": "Invoking Web Activity failed with HttpStatusCode - 'Unauthorized'.",
    "failureType": "UserError",
    "target": "Event Hub",
    "details": []
}

我还尝试根据发送事件 REST API docs指定 Content-Type 标头,但没有任何区别。

根据这篇文章,应该可以使用带有 OAuth2.0 Bearer 令牌的服务主体对事件中心进行身份验证。我的理解是 ADF 的 MSI 与服务主体没有什么不同,只是我不必自己管理机密和令牌。我错过了什么?

标签: azure-data-factoryazure-eventhub

解决方案


推荐阅读