gpt4 book ai didi

azure - 如何在azurerm_app_service资源 block 中指定4个连接字符串

转载 作者:行者123 更新时间:2023-12-03 02:23:59 25 4
gpt4 key购买 nike

我在我们的企业中定义了一个模块,用于与 Azure Web 应用程序一起创建应用程序服务计划。但现在我想使用链接中提到的“azurerm_app_service”资源 block :https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service在我们的模块中,连接字符串在参数下定义:

app_settings = {
AzureAd__ClientSecret = <Connection String of the App SP stored in Azure KV>
DbConnection__ConnectionString = <Azure SQL DB Connection String stored in Azure KV>
CosmosDb__Account = <Connection String of the Cosmos DB Account stored in Azure KV>
CosmosDb__Key = <Connection String of the Cosmos DB Account Key stored in Azure KV>
}

现在,在上面的 URL 的“azurerm_app_service”资源 block 中,有一个名为 connection_string 的参数,如 URL 中所示:

connection_string {
name = "Database"
type = "SQLServer"
value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
}

所以我想知道如何根据“connection_string”参数在资源 block 中定义 4 个连接字符串,以及我应该为每个连接字符串选择什么类型?如果我继续定义我的连接字符串,因为它们现在位于“app_settings”下的模块中,可以吗?或者如果我在新的资源 block 结构中这样做,这将是一个问题?

寻求一些帮助

最佳答案

根据您的要求,您可以使用dynamic block 来定义 azurerm_app_service 资源 block 中的多个connection_string。这里为您提供示例代码:

resource "azurerm_app_service" "webapp" {
...

dynamic "connection_string" {
for_each = var.connection_strings
content {
name = each.value.name
type = each.value.type
value = each.value.value
}
}

...
}

所以你看,你最好使用一个变量来配置connection_strings所有必需的东西,然后在动态 block 中使用它。

关于azure - 如何在azurerm_app_service资源 block 中指定4个连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67774844/

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