使用Terraform创建Azure Standard Logic App时遇请求发送失败错误求助
Terraform部署Azure Standard Logic App时创建失败
错误信息
Error: creating Logic App Standard: (Site Name "shd-sbx-spikeecrime-sla" / Resource Group "shd-sbx-uks-spikeecrime-rg"): web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>
Terraform配置
resource "azurerm_app_service_plan" "main" { name = "${local.business_unit}-${local.environment}-${local.identifier}-asp" location = module.resource_group.location resource_group_name = module.resource_group.name kind = "elastic" sku { tier = "WorkflowStandard" size = "WS1" } } resource "azurerm_storage_account" "main" { name = "${local.business_unit}0${local.environment}0${local.identifier}0sa" location = module.resource_group.location resource_group_name = module.resource_group.name account_tier = "Standard" account_replication_type = "LRS" } resource "azurerm_logic_app_standard" "main" { name = "${local.business_unit}-${local.environment}-${local.identifier}-sla" location = module.resource_group.location resource_group_name = module.resource_group.name app_service_plan_id = azurerm_app_service_plan.main.id storage_account_name = azurerm_storage_account.main.name storage_account_access_key = azurerm_storage_account.main.primary_access_key app_settings = { FUNCTIONS_WORKER_RUNTIME = "node" WEBSITE_NODE_DEFAULT_VERSION = "~18" } }
Terraform Apply执行输出
terraform apply --auto-approve module.resource_group.azurerm_resource_group.main: Refreshing state... [id=/subscriptions/ad0af8a3-80b9-4d65-a992-339cf04886f1/resourceGroups/shd-sbx-uks-spikeecrime-rg] azurerm_app_service_plan.main: Refreshing state... [id=/subscriptions/ad0af8a3-80b9-4d65-a992-339cf04886f1/resourceGroups/shd-sbx-uks-spikeecrime-rg/providers/Microsoft.Web/serverfarms/shd-sbx-spikeecrime-asp] azurerm_storage_account.main: Refreshing state... [id=/subscriptions/ad0af8a3-80b9-4d65-a992-339cf04886f1/resourceGroups/shd-sbx-uks-spikeecrime-rg/providers/Microsoft.Storage/storageAccounts/shd0sbx0spikeecrime0sa] Note: Objects have changed outside of Terraform Terraform detected the following changes made outside of Terraform since the last "terraform apply": # azurerm_storage_account.main has changed ~ resource "azurerm_storage_account" "main" { id = "/subscriptions/ad0af8a3-80b9-4d65-a992-339cf04886f1/resourceGroups/shd-sbx-uks-spikeecrime-rg/providers/Microsoft.Storage/storageAccounts/shd0sbx0spikeecrime0sa" name = "shd0sbx0spikeecrime0sa" + tags = {} # (37 unchanged attributes hidden) # (4 unchanged blocks hidden) } Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes. ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # azurerm_logic_app_standard.main will be created + resource "azurerm_logic_app_standard" "main" { + app_service_plan_id = "/subscriptions/ad0af8a3-80b9-4d65-a992-339cf04886f1/resourceGroups/shd-sbx-uks-spikeecrime-rg/providers/Microsoft.Web/serverfarms/shd-sbx-spikeecrime-asp" + app_settings = { + "FUNCTIONS_WORKER_RUNTIME" = "node" + "WEBSITE_NODE_DEFAULT_VERSION" = "~18" } + bundle_version = "[1.*, 2.0.0)" + client_affinity_enabled = (known after apply) + custom_domain_verification_id = (known after apply) + default_hostname = (known after apply) + enabled = true + https_only = false + id = (known after apply) + kind = (known after apply) + location = "uksouth" + name = "shd-sbx-spikeecrime-sla" + outbound_ip_addresses = (known after apply) + possible_outbound_ip_addresses = (known after apply) + resource_group_name = "shd-sbx-uks-spikeecrime-rg" + site_credential = (known after apply) + storage_account_access_key = (sensitive value) + storage_account_name = "shd0sbx0spikeecrime0sa" + storage_account_share_name = (known after apply) + use_extension_bundle = true + version = "~3" + connection_string { + name = (known after apply) + type = (known after apply) + value = (sensitive value) } + site_config { + always_on = (known after apply) + app_scale_limit = (known after apply) + auto_swap_slot_name = (known after apply) + dotnet_framework_version = (known after apply) + elastic_instance_minimum = (known after apply) + ftps_state = (known after apply) + health_check_path = (known after apply) + http2_enabled = (known after apply) + ip_restriction = (known after apply) + linux_fx_version = (known after apply) + min_tls_version = (known after apply) + pre_warmed_instance_count = (known after apply) + public_network_access_enabled = (known after apply) + runtime_scale_monitoring_enabled = (known after apply) + scm_ip_restriction = (known after apply) + scm_min_tls_version = (known after apply) + scm_type = (known after apply) + scm_use_main_ip_restriction = (known after apply) + use_32_bit_worker_process = (known after apply) + vnet_route_all_enabled = (known after apply) + websockets_enabled = (known after apply) + cors { + allowed_origins = (known after apply) + support_credentials = (known after apply) } } } Plan: 1 to add, 0 to change, 0 to destroy. azurerm_logic_app_standard.main: Creating... azurerm_logic_app_standard.main: Still creating... [10s elapsed] ╷ │ Warning: Deprecated Resource │ │ with azurerm_app_service_plan.main, │ on standard_logic_app.tf line 2, in resource "azurerm_app_service_plan" "main": │ 2: resource "azurerm_app_service_plan" "main" { │ │ The `azurerm_app_service_plan` resource has been superseded by the `azurerm_service_plan` resource. Whilst this resource will continue to be available in the 2.x and 3.x releases it is │ feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider. │ │ (and one more similar warning elsewhere) ╵ ╷ │ Error: creating Logic App Standard: (Site Name "shd-sbx-spikeecrime-sla" / Resource Group "shd-sbx-uks-spikeecrime-rg"): web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil> │ │ with azurerm_logic_app_standard.main, │ on standard_logic_app.tf line 24, in resource "azurerm_logic_app_standard" "main": │ 24: resource "azurerm_logic_app_standard" "main" {
排查与解决建议
- 替换废弃资源:将
azurerm_app_service_plan替换为azurerm_service_plan,原资源已被标记为废弃,可能存在API兼容性问题,新资源配置示例:resource "azurerm_service_plan" "main" { name = "${local.business_unit}-${local.environment}-${local.identifier}-asp" location = module.resource_group.location resource_group_name = module.resource_group.name os_type = "Windows" sku_name = "WS1" } - 验证权限:确保Terraform使用的服务主体对目标存储账户拥有
Storage Account Contributor权限,或至少具备读取访问密钥、创建文件共享的权限 - 显式依赖声明:在
azurerm_logic_app_standard资源中添加depends_on = [azurerm_service_plan.main, azurerm_storage_account.main],强制确保应用服务计划和存储账户完全创建后再部署逻辑应用 - 检查区域支持:确认uksouth区域支持WorkflowStandard SKU的逻辑应用服务
- 查看Azure活动日志:登录Azure门户,进入目标资源组的活动日志,筛选逻辑应用创建相关事件,获取更详细的错误详情(StatusCode=0通常是底层API调用的隐性错误,活动日志会暴露具体原因)
- 更新AzureRM Provider:确保使用的azurerm provider版本为最新稳定版,旧版本可能存在已知的API调用bug
内容的提问来源于stack exchange,提问作者user2128849
相关产品推荐
相关产品推荐

