azure - 使用 Terraform 时,Azure AD 应用程序注册中的应用程序 ID URI 出现问题

标签 azure azure-active-directory azure-web-app-service terraform-provider-azure

我正在尝试修改我的应用程序标识符 URI 的格式: 将“https://app-contoso.api-qa.contoso.onmicrosoft.com”转换为“api://(app id)”格式 我正在使用 Terraform 来执行此操作。 所以如果我只是使用:

application_identifier_uris   = [format("api://%s", random_uuid.contoso-api-app.result)]

我得到一个随机 ID,而不是实际的应用 ID。 如何确保获得“api://(app ID)”格式的实际应用程序 ID 我必须使用随机 uuid,因为如果我引用应用程序模块中应用程序 ID 的输出,我会在 Terraform 中出现循环错误。

我正在使用我们自己的应用程序模块来进行应用程序注册

最佳答案

i get a random id and not the actual app ID. How do i ensure that i get the actual App ID in the format "api://(app ID)" I have to use a random uuid as i get a cyclic error in Terraform if i refer the output of the app ID from my application module.

您正在生成一个随机 GUID 并在那里分配值,因此您将获得随机 ID,而不是实际的应用 ID。至于循环错误,如果您使用对 AppID 的引用,您将收到如下图所示的错误,因为应用程序在您引用它的同时被创建,因此在创建后仅会显示应用程序 ID可用或已识别。

enter image description here

因此,上述内容目前在 terraform 中是不可能的,因为您已经知道在这个 Github Issue 中已经提出了一个功能标志或增强。 .

<小时/>

对于解决方案,您可以使用其他管理工具,例如 Powershell/Azure-CLI更新identifier uri's .

从 terraform 创建 Azure AD 应用程序后,您可以使用 AzureAD模块或 az ad app CLI 模块以编程方式更新应用程序。

对于您的用例,Powershell 脚本将如下所示:

Connect-AzureAD
$app= Get-AzureADApplication -Filter "DisplayName eq 'ansumanterraformtest'"
$appobjectid = $app.ObjectId
$appId = $app.AppId
Set-AzureADApplication -ObjectId $app.ObjectId -IdentifierUris "api://$appId"

输出:

enter image description here

关于azure - 使用 Terraform 时,Azure AD 应用程序注册中的应用程序 ID URI 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70193492/

相关文章:

azure - OAuth 2.0 和 Azure Active Directory - 错误 AADSTS90009

azure - Azure 中的子域是否需要通配符 ssl 证书?

azure-web-app-service - 如何防止直接访问 Azure 应用服务中托管的 API

c# - 构建 Azure Function v3 时无法解析程序集 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0"

azure - ADF 复制数据事件 - 在插入 SQL 数据库之前检查重复记录

asp.net - Azure 上 ASP.NET MVC3 应用程序的分析预热

c# - 承载错误 - invalid_token - 找不到签名 key

node.js - 使用来自 Azure Identity 的访问 token 与 Nodejs 进行 Azure Sql 连接

azure - 与环境变量相比,在 KeyVault 中存储简单 secret 有哪些优点

azure - 动态创建事件网格主题和订阅,而无需通过编码访问 Azure 门户?