gpt4 book ai didi

azure - 在 Terraform Azure azurerm 中,如何获取应用程序配置连接字符串?

转载 作者:行者123 更新时间:2023-12-02 23:56:55 24 4
gpt4 key购买 nike

给定一个app_service:

resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}

resource "azurerm_app_service_plan" "example" {
name = "example-appserviceplan"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

sku {
tier = "Standard"
size = "S1"
}
}

resource "azurerm_app_service" "example" {
name = "example-app-service"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id

site_config {
dotnet_framework_version = "v4.0"
scm_type = "LocalGit"
}

app_settings = {
"AppConfig" = "some-value"
}

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

在 app_settings 部分中,如何获取应用程序配置的连接字符串并将其设置为变量 AppConfig?

我想做一些类似的事情:azurerm_app_configuration.appconf.connection_string,但我认为这不起作用。

这个值可以在 terraform 应用时知道吗?

最佳答案

将结果添加到app_settings:

app_settings = {
"AppConfig" = azurerm_app_configuration.example-app-service.primary_read_key[0].connection_string
}

Now you can read it out in C#. (Snipped the code for context.) config variable is passed in to webBuilder.ConfigureAppConfiguration(hostingContext, config).

var settings = config.Build();
Console.WriteLine(settings["AppConfig"]);

关于azure - 在 Terraform Azure azurerm 中,如何获取应用程序配置连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70809280/

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