Terraform 无法创建 64 位 Azure 应用服务(Web 应用)

Ara*_*ash 5 azure terraform azure-web-app-service azure-devops terraform-provider-azure

我正在使用 terraform 版本 0.15.5(以及 0.15.4)来预配 Azure Web App 资源。以下配置工作正常:

\n
 site_config {\n    http2_enabled             = true\n    always_on                 = false\n    use_32_bit_worker_process = true\n  }\n
Run Code Online (Sandbox Code Playgroud)\n

但是,当我使用use_32_bit_worker_process = false64 位 Web 应用程序获取脚本配置时,它失败并收到以下错误消息:

\n
2021-06-03T18:06:55.6392592Z [31m\xe2\x94\x82[0m [0m[1m[31mError: [0m[0m[1mError creating App Service "gfdemogatewayapp" (Resource Group "MASKED"): web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>[0m\n2021-06-03T18:06:55.6411094Z [31m\xe2\x94\x82[0m [0m\n2021-06-03T18:06:55.6426506Z [31m\xe2\x94\x82[0m [0m[0m  with azurerm_app_service.gfgatewayapp,\n2021-06-03T18:06:55.6427703Z [31m\xe2\x94\x82[0m [0m  on main.tf line 274, in resource "azurerm_app_service" "gfgatewayapp":\n2021-06-03T18:06:55.6428766Z [31m\xe2\x94\x82[0m [0m 274: resource "azurerm_app_service" "gfgatewayapp" [4m{[0m[0m\n2021-06-03T18:06:55.6429584Z [31m\xe2\x94\x82[0m [0m\n2021-06-03T18:06:55.6430461Z [31m\xe2\x95\xb5[0m[0m\n2021-06-03T18:06:55.6534148Z ##[error]Error: The process \'/opt/hostedtoolcache/terraform/0.15.4/x64/terraform\' failed with exit code 1\n2021-06-03T18:06:55.6548186Z ##[section]Finishing: Terraform approve and apply\n
Run Code Online (Sandbox Code Playgroud)\n

是否有我遗漏的内容或者 terraform 在 Azure 上配置 64 位 Web 应用程序资源时出现问题?

\n

更新:完整源代码\n层级为标准,SKU 大小为“F1”。

\n
resource "azurerm_app_service_plan" "gfwebappserviceplan" {\n  name                = var.gatewayserviceplanname\n  location            = "${azurerm_resource_group.gf.location}"\n  resource_group_name = "${azurerm_resource_group.gf.name}"\n\n  sku {\n    tier = var.gatewayserviceplanskutier\n    size = var.gatewayserviceplanskusize\n  }\n}\nresource "azurerm_app_service" "gfgatewayapp" {\n  name                = var.gatewayappname\n  location            = "${azurerm_resource_group.gf.location}"\n  resource_group_name = "${azurerm_resource_group.gf.name}"\n  app_service_plan_id = azurerm_app_service_plan.gfwebappserviceplan.id\n  app_settings = {\n    APPINSIGHTS_INSTRUMENTATIONKEY = "${azurerm_application_insights.gfapplicationinsights.instrumentation_key}"\n  }\n\n  site_config {\n    http2_enabled             = true\n    always_on                 = false\n    use_32_bit_worker_process = false\n  }\n}\n\noutput "gfgatewayhostname" {\n  value = "${azurerm_app_service.gfgatewayapp.default_site_hostname}"\n  description = "Gateway default host name"\n}\n\nresource "azurerm_template_deployment" "webapp-corestack" {\n  # This will make it .NET CORE for Stack property, and add the dotnet core logging extension\n  name                = "AspNetCoreStack"\n  resource_group_name = "${azurerm_resource_group.gf.name}"\n  template_body       = <<DEPLOY\n{\n    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",\n    "contentVersion": "1.0.0.0",\n    "parameters": {\n        "siteName": {\n            "type": "string",\n            "metadata": {\n                "description": "The Azure App Service Name"\n            }\n        },\n        "extensionName": {\n            "type": "string",\n            "metadata": {\n                "description": "The Site Extension Name."\n            }\n        },\n        "extensionVersion": {\n            "type": "string",\n            "metadata": {\n                "description": "The Extension Version"\n            }\n        }\n    },\n    "resources": [\n        {\n            "apiVersion": "2018-02-01",\n            "name": "[parameters(\'siteName\')]",\n            "type": "Microsoft.Web/sites",\n            "location": "[resourceGroup().location]",\n            "properties": {\n                "name": "[parameters(\'siteName\')]",\n                "siteConfig": {\n                    "appSettings": [],\n                    "metadata": [\n                        {\n                            "name": "CURRENT_STACK",\n                            "value": "dotnetcore"\n                        }\n                    ]\n                }\n            }\n        },\n        {\n            "type": "Microsoft.Web/sites/siteextensions",\n            "name": "[concat(parameters(\'siteName\'), \'/\', parameters(\'extensionName\'))]",\n            "apiVersion": "2018-11-01",\n            "location": "[resourceGroup().location]",\n            "properties": {\n                "version": "[parameters(\'extensionVersion\')]"\n            }\n        }\n    ]\n}\n  DEPLOY\n  parameters = {\n    "siteName"         = azurerm_app_service.gfgatewayapp.name\n    "extensionName"    = "Microsoft.AspNetCore.AzureAppServices.SiteExtension"\n    "extensionVersion" = "3.1.7"\n  }\n  deployment_mode = "Incremental"\n  depends_on      = [azurerm_app_service.gfgatewayapp]\n}\n
Run Code Online (Sandbox Code Playgroud)\n

小智 11

因为这是您搜索时得到的第一个谷歌结果

“AppsClient#CreateOrUpdate:发送请求失败:StatusCode=0”

这是我的错误,我会尽力帮助其他可能遇到这个问题的人。
我所做的是将函数从 azure 提供程序版本 2.x 迁移到 3.x。由于 terraform 实际上将资源类型从 azurerm_function_app 更改为 azurerm_windows_function_app,因此它们还更改了一些属性。
对我来说发生的事情是他们将属性application_insights_keyapplication_insights_connection_string添加到了site_config. 之前您必须手动(在 中app_settings)添加一个名为 的密钥APPINSIGHTS_INSTRUMENTATIONKEY。我使用了新设置,但忘记删除手动添加的密钥,并且我的函数创建因上述错误(如果你问我,不是很详细)而失败。

我花了一段时间才弄清楚这一点,所以这就是我在这里分享的原因。

  • 并非所有英雄都穿着斗篷,感谢您指出正确的方向!以下是 APPINSIGHTS_INSTRUMENTATIONKEY、FUNCTIONS_WORKER_RUNTIME、FUNCTIONS_WORKER_RUNTIME_VERSION、FUNCTIONS_EXTENSION_VERSION 应用设置 (3认同)

Sam*_*ink 9

您收到此错误是因为您正在使用F1tier app service planFree或者Shared层没有 64 位选项。

Terraform AzureRM 注册表


Sup*_*upr 7

如果设置use_32_bit_worker_processuse_32_bit_workertotrue没有帮助,请尝试运行带有日志记录的 terraform。可以通过设置TF_LOG环境变量来启用日志记录,例如:

$ TF_LOG=debug terraform apply
Run Code Online (Sandbox Code Playgroud)

这将产生大量日志记录,包括来自 Azure 的 HTTP 响应。最后记录的响应之一应包含有关原因的更多详细信息。就我而言,这是因为always_on免费计划不支持,但默认情况下启用:

HTTP/2.0 409 Conflict
<snip>
{"Code":"Conflict","Message":"There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it. [...]}
Run Code Online (Sandbox Code Playgroud)