gpt4 book ai didi

azure - 从 terraform 脚本为 Azure Active Directory 打开 'App Service Authentication'

转载 作者:行者123 更新时间:2023-12-04 14:18:49 24 4
gpt4 key购买 nike

需要从我的 terraform 脚本中为 Active Directory 打开“应用服务身份验证”。

当我使用正在创建的 app_service 的 client_id 将 auth_settings 部分添加到我的 azurerm_app_service 资源时,出现错误

“不允许自引用”

有道理,但是我是否要为我正在创建的项目启用身份验证?

  name                = "${var.prefix}-${var.environment_code}-${var.environment_segment_code}-web"
location = "${azurerm_resource_group.my_resource_group.location}"
resource_group_name = "${azurerm_resource_group.my_resource_group.name}"
app_service_plan_id = "${azurerm_app_service_plan.my_app_service_plan.id}"

app_settings = {
APPINSIGHTS_INSTRUMENTATIONKEY = "${azurerm_application_insights.my_insights.instrumentation_key}"
}

tags = {
my-Environment = "${var.environment}"
my-Location = "${var.country}"
my-Stack = "${var.stack}"
}

lifecycle {
ignore_changes = [
"app_settings"
]
}

auth_settings {
enabled = true
active_directory {
client_id = "${azurerm_app_service.web.client_id}"
}
default_provider = "AzureActiveDirectory"
}
}```

I'd like to have ad authentication enabled for my website when I terraform.

最佳答案

来自azurerm_app_service

一个active_directory block 支持以下内容:

client_id - (Required) The Client ID of this relying party application. Enables OpenIDConnection authentication with Azure Active Directory.

没有直接client_id azurerm_app_service 中的属性 block ,您需要在 Azure Active Directory 中注册应用服务应用程序,然后添加 Application (client) ID在 Azure 门户上 active_directory堵塞。查看详情configure your App Service app to use Azure Active Directory sign-in

Azure Active Directory 资源已拆分为新的 AzureAD 提供程序 - 因此 AzureRM 提供程序中的 AzureAD 资源已弃用,并将在下一个主要版本 (2.0) 中删除。你可以用 azuread_application 来做到这一点 block 。

例如,这对我有用地形 v0.12.5+ 提供商.azureread v0.5.1+ 提供商.azurerm v1.32.0

# Configure the Microsoft Azure Active Directory Provider
provider "azuread" {
version = "~> 0.3"
}

# Create an application
resource "azuread_application" "example" {
name = "${var.prefix}-app-service"
homepage = "https://${var.prefix}-app-service"
identifier_uris = ["https://${var.prefix}-app-service"]
reply_urls = ["https://${var.prefix}-app-service.azurewebsites.net/.auth/login/aad/callback"]
available_to_other_tenants = false
oauth2_allow_implicit_flow = true

}

 auth_settings  {
enabled = true

active_directory {
client_id = "${azuread_application.example.application_id}"
}
default_provider = "AzureActiveDirectory"
issuer = "https://sts.windows.net/xxxxxxx-xxxx-xxx-xxxx-xxxtenantID/"

}

结果

enter image description here

关于azure - 从 terraform 脚本为 Azure Active Directory 打开 'App Service Authentication',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57260721/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com