gpt4 book ai didi

azure - 更新 Terraform 中现有的 Azure 应用服务

转载 作者:行者123 更新时间:2023-12-03 06:51:41 25 4
gpt4 key购买 nike

我想通过向此应用服务添加备份来更新 Terraform 中现有的 Azure 应用服务。现在看起来像这样:

data "azurerm_app_service_plan" "example" {
name = "MyUniqueServicePlan"
resource_group_name = "example-resources"
}


resource "azurerm_app_service" "example" {
name = "MyUniqueWebAppName"
location = "West Europe"
resource_group_name = "example-resources"
app_service_plan_id = data.azurerm_app_service_plan.example.id


connection_string {
name = "myConectionString"
type = "SQLServer"
value = "Server=tcp:mysqlservername123.database.windows.net,1433;Initial Catalog=MyDatabaseName;Persist Security Info=False;User ID=xxx;Password=xxxxxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
backup {
name = "MyBackupName"
enabled = true
storage_account_url = "https://storageaccountnameqwetih.blob.core.windows.net/mycontainer?sp=r&st=2022-08-31T09:49:17Z&se=2022-08-31T17:49:17Z&spr=https&sv=2021-06-08&sr=c&sig=2JwQ%xx%2B%2xxB5xxxxFZxxVyAadjxxV8%3D"
schedule {
frequency_interval = 30
frequency_unit = "Day"
keep_at_least_one_backup = true
retention_period_in_days = 10
start_time = "2022-08-31T07:11:56.52Z"
}
}
}

但是当我运行它时,我收到一个错误 ID 为 ......../MyUniqueWebAppName"的资源已存在 - 要通过 Terraform 进行管理,需要将此资源导入到状态中。在 terraform 中,如何指向现有的 Azure APP Service 并添加与我在模板中相同的计划的备份?

最佳答案

在使用 TF 修改现有资源之前,您必须import进入地形状态。为此,您可以使用 import command .

关于azure - 更新 Terraform 中现有的 Azure 应用服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73554205/

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