azureterraformazure-rmazapi

How to create ASEV3 resource using AzAPI terraform provider


I Was trying to create a ASEv3 resource using the AzAPI Terraform provider using

resource "azapi_resource" "ase" {
  type      = "Microsoft.Web/hostingEnvironments@2024-04-01"
  name      = "my-app-service-environment"
 location  = "eastus2"
 parent_id = data.azurerm_resource_group.example.id
 schema_validation_enabled = false
 body = jsonencode({
   properties = {
     internalLoadBalancingMode = "None"
    virtualNetwork = {
    id = "/subscriptions/{subscriptionid}/resourceGroups/{resourcegroupid}/providers/Microsoft.Network/virtualNetworks/{vnetname}/subnets/{subnetname}"
  }
  frontEndScaleFactor       = 15
  multiSize                 = "Standard_D1_V2"
  ipsslAddressCount         = 2
   }
 })
}

but unfortunately it is failing saying the below issue

           RESPONSE 400: 400 Bad Request
         │ ERROR CODE UNAVAILABLE
         │ --------------------------------------------------------------------------------
        │ {
        │   "Code": "BadRequest",
        │   "Message": "App Service Environment v1 is not supported for your 
        subscription. Please create using App Service Environment v3.",
       │   "Target": null,
      │   "Details": [
      │     {
      │       "Message": "App Service Environment v1 is not supported for your 
    subscription. Please create using App Service Environment v3."
     │     },
         │     {
       │       "Code": "BadRequest"
        │     },
       │     {
       │       "ErrorEntity": {
        │         "ExtendedCode": "55944",
        │         "MessageTemplate": "App Service Environment v{0} is not supported for 
   your subscription. Please create using App Service Environment v3.",
       │         "Parameters": [
       │           "1"
       │         ],
       │         "Code": "BadRequest",
       │         "Message": "App Service Environment v1 is not supported for your 
    subscription. Please create using App Service Environment v3."
       │       }
       │     }
       │   ],
      │   "Innererror": null
     │ }
       │ --------------------------------------------------------------------------------

I couldn't find a way to choose the APP service Environemnt Version to V3 in AZAPI terraform provider

Note:

The reason why i'm trying the AzAPI provider is because the ASE resource creation with AzureRM provider is timing out in 2 hours when running from Terraform workspace and here I'm trying to find out any difference with AzAPI provider


Solution

  • You need to specify "kind": "ASEV3" in the request body at least. I don't use Terraform, but I'm guessing it would be something like this:

    resource "azapi_resource" "ase" {
      type      = "Microsoft.Web/hostingEnvironments@2024-04-01"
      name      = "my-app-service-environment"
     location  = "eastus2"
     parent_id = data.azurerm_resource_group.example.id
     schema_validation_enabled = false
     body = jsonencode({
       kind = "ASEV3"
       properties = {
         internalLoadBalancingMode = "None"
        virtualNetwork = {
        id = "/subscriptions/{subscriptionid}/resourceGroups/{resourcegroupid}/providers/Microsoft.Network/virtualNetworks/{vnetname}/subnets/{subnetname}"
      }
      frontEndScaleFactor       = 15
      multiSize                 = "Standard_D1_V2"
      ipsslAddressCount         = 2
       }
     })
    }