时人不识凌云木,直待凌云始道高。这篇文章主要讲述用于App Service的地形名称“ xxx”必须是全局唯一的,并且不可用”相关的知识,希望能为你提供帮助。
我正在Terraform中应用以下配置:
resource "azurerm_resource_group" "rg" {
name= var.resourceGroupName
location = var.location
}resource "azurerm_app_service_plan" "app_plan" {
name= var.appServicePlanName
location= var.location
resource_group_name = azurerm_resource_group.rg.namesku {
tier = "Free"
size = "F1"
}
}resource "azurerm_app_service" "app_service" {
name= var.appServiceName
location= var.location
resource_group_name = azurerm_resource_group.rg.name
app_service_plan_id = azurerm_app_service_plan.app_plan.idapp_settings = {
"SOME_KEY" = "some-value"
}
}
我第一次运行“ terraform apply”,结果就是我期望的结果。资源已创建。如果我将再次运行相同的配置,我将收到:错误:用于App Service的名称“ xxx”必须是全局唯一的,并且不可用:主机名“ xxx”已存在。请选择其他名称。
我有点困惑,因为我希望Terraform跳过任何更改,只是让我知道什么都没有更改,我缺少什么?我的provider(provider.tf)配置如下:
provider "azurerm" {
skip_provider_registration = "true"
subscription_id = var.subscriptionId
tenant_id= var.tenantId
client_id= var.clientId
client_secret= var.clientSecret
}
此外,我还有terraform.tfvars
resourceGroupName = "xxx-poc1-rg"
location = "eastus"
appServicePlanName = "xxx-poc1-asp01"
appServiceName = "xxx-poc1-apsvc01"
subscriptionId = ""
tenantId = ""
clientId = ""
clientSecret = ""
和variables.tf文件
variable "appServiceName" {
type= string
description = "The name of app service"
}variable "appServicePlanName" {
type= string
description = "The name of app service plan"
}variable "resourceGroupName" {
type= string
description = "The name of resource group"
}variable "location" {
type= string
description = "Location"
}variable "subscriptionId" {
type= string
description = "Subscription id"
}variable "tenantId" {
type= string
description = "Tenant id"
}variable "clientId" {
type= string
description = "Client id"
}variable "clientSecret" {
type= string
description = "Client secret"
}
P.S。如果我尝试通过添加connection_string部分或修改app_settings来修改应用程序服务配置,则结果是相同的,但会抛出异常,提示“错误:用于应用程序服务的名称“ xxx”必须是全局唯一的,并且不可用:主机名“ xxx”已存在。请选择其他名称。“
以下是地形状态输出:D: alexus-gitTerraformAppServicePlanTest [master≡
terraform计划计划之前刷新内存中的Terraform状态...刷新后的状态将用于计算此计划,但不会持久保存到本地或远程状态存储。【用于App Service的地形名称“ xxx”必须是全局唯一的,并且不可用”】azurerm_resource_group.rg:刷新状态... [id = / subscriptions / 0f1c414a -...- a351876ecd47 / resourceGroups / xxx-poc1-rg]azurerm_app_service_plan.app_plan:刷新状态... [id = / subscriptions / 0f1c414a -...- a351876ecd47 / resourceGroups / xxx-poc1-rg / providers / Microsoft.Web / serverfarms / xxx-poc1-asp01]
已生成执行计划,如下所示。资源操作用以下符号表示:+创建
Terraform将执行以下操作:
#azurerm_app_service.app_service将被创建+资源“ azurerm_app_service”“ app_service” {+ app_service_plan_id =“ /subscriptions/0f1c414a-...-a351876ecd47/resourceGroups/xxx-poc1-rg/providers/Microsoft.Web/serverfarms/xxx-poc1-asp01”+ app_settings = {+“ SOME_KEY” =“某些值”}+ client_affinity_enabled =(应用后已知)+ default_site_hostname =(应用后已知)+已启用=正确+ https_only =否+ id =(应用后已知)+位置=“ eastus”+名称=“ xxx-poc1-apsvc01”+ outbound_ip_addresses =(应用后已知)+ Possible_outbound_ip_addresses =(套用后才知道)+ resource_group_name =“ xxx-poc1-rg”+ site_credential =(应用后已知)+ source_control =(应用后已知)+标签=(应用后已知)
+ auth_settings { + additional_login_params= (known after apply) + allowed_external_redirect_urls = (known after apply) + default_provider= (known after apply) + enabled= (known after apply) + issuer= (known after apply) + runtime_version= (known after apply) + token_refresh_extension_hours= (known after apply) + token_store_enabled= (known after apply) + unauthenticated_client_action= (known after apply)+ active_directory { + allowed_audiences = (known after apply) + client_id= (known after apply) + client_secret= (sensitive value) }+ facebook { + app_id= (known after apply) + app_secret= (sensitive value) + oauth_scopes = (known after apply) }+ google { + client_id= (known after apply) + client_secret = (sensitive value) + oauth_scopes= (known after apply) }+ microsoft { + client_id= (known after apply) + client_secret = (sensitive value) + oauth_scopes= (known after apply) }+ twitter { + consumer_key= (known after apply) + consumer_secret = (sensitive value) } }+ connection_string { + name= (known after apply) + type= (known after apply) + value = https://www.songbingjia.com/android/(sensitive value) }+ identity { + identity_ids = (known after apply) + principal_id = (known after apply) + tenant_id= (known after apply) + type= (known after apply) }+ logs { + application_logs { + azure_blob_storage { + level= (known after apply) + retention_in_days = (known after apply) + sas_url= (sensitive value) } }+ http_logs { + azure_blob_storage { + retention_in_days = (known after apply) + sas_url= (sensitive value) }+ file_system { + retention_in_days = (known after apply) + retention_in_mb= (known after apply) } } }+ site_config { + always_on= (known after apply) + app_command_line= (known after apply) + auto_swap_slot_name= (known after apply) + default_documents= (known after apply) + dotnet_framework_version= (known after apply) + ftps_state= (known after apply) + http2_enabled= (known after apply) + ip_restriction= (known after apply) + java_container= (known after apply) + java_container_version= (known after apply) + java_version= (known after apply) + linux_fx_version= (known after apply) + local_mysql_enabled= (known after apply) + managed_pipeline_mode= (known after apply) + min_tls_version= (known after apply) + php_version= (known after apply) + python_version= (known after apply) + remote_debugging_enabled= (known after apply) + remote_debugging_version= (known after apply) + scm_type= (known after apply) + use_32_bit_worker_process = (known after apply) + virtual_network_name= (known after apply) + websockets_enabled= (known after apply) + windows_fx_version= (known after apply)+ cors { + allowed_origins= (known after apply) + support_credentials = (known after apply) } }+ storage_account { + access_key= (sensitive value) + account_name = (known after apply) + mount_path= (known after apply) + name= (known after apply) + share_name= (known after apply) + type= (known after apply) } }
计划:添加1,更改0,销毁0。
答案问题是,您不提供使用zurerm的支持,因此不会保存您的状态文件。要解决此问题,您可以在现有的
backend
文件中添加.tf
或创建一个新的文件,例如backend.tf
,内容:terraform {
backend "azurerm" {
}
}
推荐阅读
- Flutter Notification OneSignal-无法确定任务'(app:compileDebugJavaWithJavac'的依赖项)
- 像webapp.to一样开发移动应用程序
- Android(未加载测试广告)
- 如何将我在Android Studio中制作的应用程序放入手机中()
- Android jetpack生物识别DeviceCredentialHandlerActivity输出=真的需要吗()
- ASP.NET CORE没有app.UseEndpoints()方法
- 在Express中,app.router到底做了什么()
- 如何以编程方式从Symfony 3表单(表单类型)中删除字段
- 如何在你的Symfony 3表单中检索未映射字段的值