我尝试将 azurerm_app_service_virtual_network_swift_connection
与 azurerm_linux_function_app
结合使用,但即使我使用的是即用即付子系统,但仍收到此错误。
│ Error: creating/updating App Service VNet association between "rd-func8-func" (Resource Group "rg-rd-func8") and Virtual Network "rdfunc8-vnet": web.AppsClient#CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Feature Create Swift Virtual Network is not allowed for a free trial subscription." Details=[{"Message":"Feature Create Swift Virtual Network is not allowed for a free trial subscription."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","ExtendedCode":"52018","Message":"Feature Create Swift Virtual Network is not allowed for a free trial subscription.","MessageTemplate":"Feature {0} is not allowed for a free trial subscription.","Parameters":["Create Swift Virtual Network"]}}]
│
│ with module.function.azurerm_app_service_virtual_network_swift_connection.example,
│ on modules/function/function.tf line 28, in resource "azurerm_app_service_virtual_network_swift_connection" "example":
│ 28: resource "azurerm_app_service_virtual_network_swift_connection" "example" {
TF 看起来像这样
resource "azurerm_linux_function_app" "this" {
name = lower(format("%s-%s-func", var.client_name, var.project_name))
resource_group_name = var.resource_group_name
location = var.resource_group_location
storage_account_name = var.storage_account_name
storage_account_access_key = var.storage_account_access_key
service_plan_id = var.service_plan_id
app_settings = {
FUNCTIONS_WORKER_RUNTIME = "node"
}
site_config {
application_stack {
node_version = 18
}
}
}
resource "azurerm_app_service_virtual_network_swift_connection" "example" {
app_service_id = azurerm_linux_function_app.this.id
subnet_id = var.virtual_network_subnet_id
}
最佳答案
我尝试在我的环境中重现相同的内容,以使用 terraform 通过即用即付订阅创建 Swift 虚拟网络,因为我遇到了相同的错误:
我在即用即付订阅帐户上的以下应用服务计划 Sku 中也遇到了同样的错误。
resource "azurerm_service_plan" "example" {
name = "example-app-service-plan"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
os_type = "Linux"
sku_name = "Y1"
}
要解决该错误,请选择列出的应用服务计划。
为了进行测试,我选择了Premium v2 P1V2 计划。
Terraform 代码:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_storage_account" "example" {
name = "thejalinuxstorage1"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_virtual_network" "example" {
name = "example-virtual-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "example" {
name = "example-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.1.0/24"]
delegation {
name = "example-delegation"
service_delegation {
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}
resource "azurerm_service_plan" "example" {
name = "example-app-service-plan"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
os_type = "Linux"
sku_name = "P1v2"
}
resource "azurerm_linux_function_app" "venkat" {
name = "venkat-linux-function-app"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
service_plan_id = azurerm_service_plan.example.id
site_config {}
}
resource "azurerm_app_service_virtual_network_swift_connection" "thejaswiftconnection" {
app_service_id = azurerm_linux_function_app.venkat.id
subnet_id = azurerm_subnet.example.id
}
Terraform 应用:
运行代码后成功创建资源。
关于azure - Terraform - 功能创建 Swift 虚拟网络不允许用于免费试用订阅 - 在即用即付订阅中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75013496/