terraform - azurerm_app_service v2 如何为 v2 启用身份验证设置
问题描述
我使用 terraform 创建了一个 azure 应用服务,默认它选择旧式 AUTH 设置。正如微软建议的那样,旧设置将在今年年底被删除,我们希望迁移到新的 AUTH 设置。我没有看到任何有关它的文档。当我为其中一项应用服务手动升级 AUTH 设置时,terraform 无法再更新给定的应用服务
在我用来创建应用服务的代码片段下方。这将创建具有 AUTH 版本 1 的应用服务。
resource "azurerm_app_service" "as" {
for_each = var.appservice
name = lookup(each.value, "appservice_name")
location = var.location
resource_group_name = var.resource_group_name
app_service_plan_id = var.app_service_plan_id
https_only = lookup(each.value, "https_only", null)
client_cert_enabled = lookup(each.value, "client_cert_enabled", false)
tags = var.standard_tags
dynamic "site_config" {
for_each = lookup(each.value, "site_config",[])
content {
always_on = lookup(site_config.value, "always_on", true)
app_command_line = lookup(site_config.value, "app_command_line", null)
auto_swap_slot_name = lookup(site_config.value, "auto_swap_slot_name", null)
dynamic "cors" {
for_each = lookup(site_config.value, "cors", [])
content {
allowed_origins = lookup(cors.value, "allowed_origins", null)
support_credentials = lookup(cors.value, "support_credentials", null)
}
}
default_documents = lookup(site_config.value, "default_documents", ["index.html", "hostingstart.html"])
dotnet_framework_version = lookup(site_config.value, "dotnet_framework_version", null)
ftps_state = lookup(site_config.value, "ftps_state", "FtpsOnly")
http2_enabled = lookup(site_config.value, "http2_enabled", true)
health_check_path = lookup(site_config.value, "health_check_path", null)
java_container = lookup(site_config.value, "java_container", null)
java_container_version = lookup(site_config.value, "java_container_version", null)
java_version = lookup(site_config.value, "java_version", null)
linux_fx_version = lookup(site_config.value, "linux_fx_version", null)
local_mysql_enabled = lookup(site_config.value, "local_mysql_enabled", null)
managed_pipeline_mode = lookup(site_config.value, "managed_pipeline_mode", null)
min_tls_version = lookup(site_config.value, "min_tls_version", "1.2")
php_version = lookup(site_config.value, "php_version", null)
python_version = lookup(site_config.value, "python_version", null)
remote_debugging_enabled = lookup(site_config.value, "remote_debugging_enabled", null)
remote_debugging_version = lookup(site_config.value, "remote_debugging_version", null)
scm_type = lookup(site_config.value, "scm_type", "VSTSRM")
use_32_bit_worker_process = lookup(site_config.value, "use_32_bit_worker_process", null)
websockets_enabled = lookup(site_config.value, "websockets_enabled", null)
windows_fx_version = lookup(site_config.value, "windows_fx_version", null)
}
}
app_settings = merge(lookup(each.value, "app_settings", {}), var.custom_app_settings)
auth_settings {
enabled = true
default_provider = "AzureActiveDirectory"
issuer = "https://login.microsoftonline.com/XXXXXX/v2.0/"
unauthenticated_client_action = "RedirectToLoginPage"
active_directory {
client_id = var.as_client_id
client_secret = var.as_client_secret
allowed_audiences = [
"https://${lookup(each.value, "appservice_name")}.azurewebsites.net"
]
}
}
解决方案
不幸的是,目前无法使用 Terraform 将 Auth API 版本 V1 迁移到 V2。目前只能从 Portal 完成。
但根据Terraform-Provider-azurerm
3.0 版的发布公告,提到旧 API 将移至使用MSAL auth 而不是ADAL的新 API 。
功能详细信息:切换到使用 MSAL 而非 ADAL 进行身份验证
目前使用 ADAL 库执行对资源管理器等 API 的身份验证,该库产生旧版 v1 身份验证令牌。我们将在提供程序的 3.0 版中使用 v2 令牌。在实践中,这种变化不会产生任何明显的行为差异;但是,由于这支持了提供者对 Azure 服务进行身份验证的方式,因此我们将在主要版本中进行此更改。
您可以参考Release Announcement for Terraform-provider-azurerm
有关 azurerm 3.0 版即将发生的更改的更多详细信息。
推荐阅读
- spring-boot - 春季启动 webflux 部署
- java - 订阅多个 MQTT 主题
- delphi - 选定行的 TListView.OnAdvancedCustomDraw 问题
- vb.net - 使用先前定义的变量的 LINQ 表达式
- fortran - 当我多次运行我的 Fortran 代码时,文件上的值完全相同
- visual-studio-2013 - DevEnv 从命令行构建 BizTalk Visual Studio 2013 解决方案
- java - 如何使用 Java MongoDB 驱动程序访问文档列表中的值和字段?
- python-3.x - 为什么输出只要求“矩形的输入”而不是“三角形的输入”,即使在指定“if,else”语句之后也是如此?
- ios - 如果在其他类中实现,自定义点击识别器方法将不起作用
- javascript - 从 Javascript 数组创建嵌套的 Json 结构