我正在使用terraform版本0.15.5(以及0.15.4(来提供Azure Web App资源。以下配置工作正常:
site_config {
http2_enabled = true
always_on = false
use_32_bit_worker_process = true
}
但是,当我使用use_32_bit_worker_process = false
获取64位web应用程序的脚本时,它失败了,我得到以下错误消息:
2021-06-03T18:06:55.6392592Z [31m│[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
2021-06-03T18:06:55.6411094Z [31m│[0m [0m
2021-06-03T18:06:55.6426506Z [31m│[0m [0m[0m with azurerm_app_service.gfgatewayapp,
2021-06-03T18:06:55.6427703Z [31m│[0m [0m on main.tf line 274, in resource "azurerm_app_service" "gfgatewayapp":
2021-06-03T18:06:55.6428766Z [31m│[0m [0m 274: resource "azurerm_app_service" "gfgatewayapp" [4m{[0m[0m
2021-06-03T18:06:55.6429584Z [31m│[0m [0m
2021-06-03T18:06:55.6430461Z [31m╵[0m[0m
2021-06-03T18:06:55.6534148Z ##[error]Error: The process '/opt/hostedtoolcache/terraform/0.15.4/x64/terraform' failed with exit code 1
2021-06-03T18:06:55.6548186Z ##[section]Finishing: Terraform approve and apply
在Azure上配置64位web应用程序资源时,是否有我遗漏的内容或terraform出现问题?
更新:完整的源代码级别为Standard,SKU大小为"F1";。
resource "azurerm_app_service_plan" "gfwebappserviceplan" {
name = var.gatewayserviceplanname
location = "${azurerm_resource_group.gf.location}"
resource_group_name = "${azurerm_resource_group.gf.name}"
sku {
tier = var.gatewayserviceplanskutier
size = var.gatewayserviceplanskusize
}
}
resource "azurerm_app_service" "gfgatewayapp" {
name = var.gatewayappname
location = "${azurerm_resource_group.gf.location}"
resource_group_name = "${azurerm_resource_group.gf.name}"
app_service_plan_id = azurerm_app_service_plan.gfwebappserviceplan.id
app_settings = {
APPINSIGHTS_INSTRUMENTATIONKEY = "${azurerm_application_insights.gfapplicationinsights.instrumentation_key}"
}
site_config {
http2_enabled = true
always_on = false
use_32_bit_worker_process = false
}
}
output "gfgatewayhostname" {
value = "${azurerm_app_service.gfgatewayapp.default_site_hostname}"
description = "Gateway default host name"
}
resource "azurerm_template_deployment" "webapp-corestack" {
# This will make it .NET CORE for Stack property, and add the dotnet core logging extension
name = "AspNetCoreStack"
resource_group_name = "${azurerm_resource_group.gf.name}"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string",
"metadata": {
"description": "The Azure App Service Name"
}
},
"extensionName": {
"type": "string",
"metadata": {
"description": "The Site Extension Name."
}
},
"extensionVersion": {
"type": "string",
"metadata": {
"description": "The Extension Version"
}
}
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"properties": {
"name": "[parameters('siteName')]",
"siteConfig": {
"appSettings": [],
"metadata": [
{
"name": "CURRENT_STACK",
"value": "dotnetcore"
}
]
}
}
},
{
"type": "Microsoft.Web/sites/siteextensions",
"name": "[concat(parameters('siteName'), '/', parameters('extensionName'))]",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"properties": {
"version": "[parameters('extensionVersion')]"
}
}
]
}
DEPLOY
parameters = {
"siteName" = azurerm_app_service.gfgatewayapp.name
"extensionName" = "Microsoft.AspNetCore.AzureAppServices.SiteExtension"
"extensionVersion" = "3.1.7"
}
deployment_mode = "Incremental"
depends_on = [azurerm_app_service.gfgatewayapp]
}
因为这是搜索时得到的第一个谷歌结果
"AppsClient#CreateOrUpdate:发送请求失败:StatusCode=0";
这是我的错误,我会尽力帮助其他可能遇到这个问题的人
我所做的是将一个函数从azure提供程序版本2.x迁移到3.x。由于terraform实际上将资源类型从azurerm_function_app更改为azurerm_windows_function_app,因此他们还更改了一些属性
对我来说,他们将属性application_insights_key
和application_insights_connection_string
添加到了site_config
中。在您必须手动(在app_settings
中(添加一个名为APPINSIGHTS_INSTRUMENTATIONKEY
的密钥之前。我使用了新的设置,但忘记了去掉手动添加的键,我的函数创建失败了,出现了上述错误(如果你问我的话,不是很详细(。
我花了一段时间才弄清楚,所以我在这里分享这个。
您收到此错误是因为您使用的是F1
层app service plan
。Free
或Shared
层没有64位选项。
Terraform AzureRM注册表
如果将use_32_bit_worker_process
或use_32_bit_worker
设置为true
没有帮助,请尝试运行带有日志的terraform。可以通过设置TF_LOG
环境变量来启用日志记录,例如:
$ TF_LOG=debug terraform apply
这将产生大量日志记录,包括来自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. [...]}