【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub

简介: 【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub

问题描述

使用Logic App服务,创建Event Hub触发的Workflow。 根据以下信息配置Event Hub连接器的Active Directory OAuth认证方式:

  • Authentication Type 选择“Active Directory OAuth”
  • Fully Qualified Namespace 输入目标 Event Hub Namespace的Host Name, 如 myehnamespace.servicebus.chinacloudapi.cn
  • Authoriy 输入中国区Azure的Authority,值为:https://login.partner.microsoftonline.cn/
  • Tenant 输入自己在AAD中注册应用的Tenant ID
  • Credential Type 选择 “Secret”
  • Client ID 输入在AAD中注册应用的Application ID ( Client ID)
  • Client Secret 输入在AAD中注册应用生成的密钥

在正确配置以上信息后。保存Workflow,却无法不能正常工作。

报错信息:

2024-08-17T08:40:30Z   [Error]   An exception occurred while retrieving properties for Event Hub: logicapp. Error Message: 'ClientSecretCredential authentication failed: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant.

 

问题解答

根据错误信息 “Error Message: 'ClientSecretCredential authentication failed: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. ”, 可知获取认证的时候,无法找到Tenant信息,所以无法完成。这是因为在中国Azure中,需要设置正确的Authority(https://login.partner.microsoftonline.cn/)。这里虽然配置了正确的Authority,但没有生效,认证请求依旧指向了Global Azure。

而Logic App是无代码开发,如果配置无法生效的情况下,就只能让Logic App服务团队修复这个问题。

 

目前的代替方案就是使用  Connection String 或 Managed Identity 认证方式。这两种认证方式都可以正常工作!

 

通过Function App复现问题

我们知道,Logic App使用的就是Function App为框架搭建的服务。为了进一步证明是服务本身的问题,可以通过Function App,创建一个Event Hub Trigger的函数,使用Active Direcotry OAuth认证。来复现同样的问题。

第一步:通过VS 2022创建一个Eevent Hub Trigger的函数

第二步:配置Active Directory OAuth信息

在 local.settings.json 文件中,用 TEST_EVENTHUB_AUTH__fullyQualifiedNamespace等系列配置 替换 TEST_EVENTHUB_AUTH 连接字符串。

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_INPROC_NET8_ENABLED": "1",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureWebJobsStorage": "... ... ... ",
    //"TEST_EVENTHUB_AUTH": "... ... ... ",
    "TEST_EVENTHUB_AUTH__fullyQualifiedNamespace": "youreventhubnamespacename.servicebus.chinacloudapi.cn",
    "TEST_EVENTHUB_AUTH__blobServiceUri": "https://xxxx.blob.core.chinacloudapi.cn/",
    "TEST_EVENTHUB_AUTH__queueServiceUri": "https://xxxx.queue.core.chinacloudapi.cn/",
    "TEST_EVENTHUB_AUTH__tenantId": "xxxx-xxxx-xxxx-xxxx-xxxx",
    "TEST_EVENTHUB_AUTH__clientId": "xxxx-xxxx-xxxx-xxxx-xxxx",
    "TEST_EVENTHUB_AUTH__clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "TEST_EVENTHUB_AUTH__Authority": "https://login.partner.microsoftonline.cn/"
  }
}

 

第三步:本地执行,复现 AADSTS90002 错误

 

 

 

参考资料

Azure Functions 开发人员指南 : https://docs.azure.cn/zh-cn/azure-functions/functions-reference?tabs=blob&pivots=programming-language-csharp#local-development-with-identity-based-connections

在函数应用中连接到服务总线 : https://docs.azure.cn/zh-cn/azure-functions/functions-identity-based-connections-tutorial-2#connect-to-the-service-bus-in-your-function-app

 

相关文章
|
存储 安全 Linux
【Azure App Service】在App Service中查看CA证书
在 Azure App Service 中,使用自签名或私有 CA 证书的远程服务可能会导致 SSL 握手失败。解决方法包括使用受信任 CA 签发的证书,或通过 App Service Environment 加载自定义根证书,实现安全连接。
358 4
|
Java 应用服务中间件 API
【App Service】部署War包到Azure云上遇404错误
Java应用部署至Azure App Service for Windows后报404,本地运行正常。经排查,日志提示类文件版本不兼容:应用由Java 17(class file version 61.0)编译,但环境仅支持到Java 11(55.0)。错误根源为Java版本不匹配。调整App Service的Java版本至17后问题解决,成功访问接口。
1389 3
|
存储 Linux 网络安全
【Azure App Service】Root CA on App Service
Azure App Service for Windows应用连接外部SSL服务时,需确保其证书由受信任的根CA颁发。多租户环境下无法修改根证书,但ASE(单租户)可加载自定义CA证书。若遇证书信任问题,可更换为公共CA证书或将应用部署于ASE并导入私有CA证书。通过Kudu的PowerShell(Windows)或SSH(Linux)可查看当前受信任的根证书列表。
317 13
|
API 网络架构 容器
【Azure Container App】查看当前 Container App Environment 中的 CPU 使用情况的API
在扩展 Azure Container Apps 副本时,因 Container App Environment 的 CPU 核心数已达上限(500 cores),导致扩展失败。本文介绍如何使用 `az rest` 命令调用 Azure China Cloud 管理 API,查询当前环境的 CPU 使用情况,并提供具体操作步骤及示例。
467 17
|
网络协议 Java Linux
【App Service】在Azure环境中如何查看App Service实例当前的网络连接情况呢?
在 Azure App Service(Windows 和 Linux)中部署应用时,分析网络连接状态是排查异常、验证端口监听及确认后端连接的关键。本文介绍如何在 Linux 环境中使用 `netstat` 命令查看特定端口(如 443、3306、6380)的连接情况,并解析输出结果。同时说明在 Windows App Service 中 `netstat` 被禁用的情况下,如何通过门户抓包等替代方法进行网络诊断。内容涵盖命令示例、操作步骤及附录说明,帮助开发者快速掌握云环境中的网络分析技巧。
352 11
|
数据安全/隐私保护
【Azure Function App】PowerShell Function 执行 Get-AzAccessToken 的返回值类型问题:System.String 与 System.Security.SecureString
将PowerShell Function部署到Azure Function App后,Get-AzAccessToken返回值类型在不同环境中有差异。正常为SecureString类型,但部分情况下为System.String类型,导致后续处理出错。解决方法是在profile.ps1中设置环境变量$env:AZUREPS_OUTPUT_PLAINTEXT_AZACCESSTOKEN=false,以禁用明文输出。
395 1
|
存储 缓存 Serverless
【Azure Container App】如何在Consumption类型的容器应用环境中缓存Docker镜像
在 Azure 容器应用的 Consumption 模式下,容器每次启动均需重新拉取镜像,导致冷启动延迟。本文分析该机制,并提出优化方案:使用 ACR 区域复制加速镜像拉取、优化镜像体积、设置最小副本数减少冷启动频率,或切换至 Dedicated 模式实现镜像缓存,以提升容器启动效率和应用响应速度。
728 0
|
缓存 移动开发 JavaScript
如何优化UniApp开发的App的启动速度?
如何优化UniApp开发的App的启动速度?
1992 139
|
移动开发 JavaScript weex
UniApp开发的App在启动速度方面有哪些优势和劣势?
UniApp开发的App在启动速度方面有哪些优势和劣势?
950 137

热门文章

最新文章