Home > Enterprise >  Terraform - Feature Create Swift Virtual Network is not allowed for a free trial subscription - on P
Terraform - Feature Create Swift Virtual Network is not allowed for a free trial subscription - on P

Time:01-06

I'm trying to use azurerm_app_service_virtual_network_swift_connection with azurerm_linux_function_app but am getting this error even though I'm on a Pay As You Go sub.

│ 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 looks like this

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
}

Azure Portal Subscription enter image description here

CodePudding user response:

I tried to reproduce the same in my environment to Create Swift Virtual Network with Pay-as-You-Go subscription using terraform, As I got same error:

enter image description here

I also got same error with below App service Plan Sku on Pay-as-You-Go subscription Account.

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"
}

To resolve the error, kindly choose listed App service plan.

enter image description here

For testing I choose the Premium v2 P1V2 Plan.

Terraform code:

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 Apply:

enter image description here

Successfully created resources once ran the code.

enter image description here

Reference: azurerm_app_service_virtual_network_swift_connection

  • Related