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

Issue with Application ID URI in Azure AD App registration , while using Terraform

我正在尝试将我的应用程序标识符 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)”的实际 App ID 如果我从我的应用程序模块引用应用程序 ID 的输出,我必须使用随机 uuid,因为我在 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。至于 Cyclic Error 如果您使用对 AppID 的引用,您将收到类似下图的错误,因为应用程序是在您引用它的同时创建的,因此在创建后仅应用程序id 将可用或被识别。

因此,以上内容目前无法通过 terraform 实现,因为您已经知道已经提出了 功能标志或增强功能 同样在这个 Github Issue.


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

从 Terraform 创建 Azure AD 应用程序后,您可以使用 AzureAD Modules or 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"

输出: