Open WTSParadigm opened 1 month ago
Hi @WTSParadigm,
Thank you for taking time to report this issue.
Indeed the error message returns from the API is not helpful. I tried to create a site resource with flex consumption plan, and it works. Here's my complete config, hope it could help you.
resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2021-04-01"
name = "acctesthenglu925"
location = "eastus"
body = {} # Resource group does not require additional properties in the body
}
resource "azapi_resource" "plan" {
type = "Microsoft.Web/serverfarms@2023-12-01"
parent_id = azapi_resource.resourceGroup.id
name = "henglufarm"
location = "eastus"
body = {
properties = {
hyperV = false
perSiteScaling = false
reserved = true
zoneRedundant = false
}
sku = {
tier = "FlexConsumption"
name = "FC1"
}
}
}
resource "azurerm_storage_account" "example" {
location = azapi_resource.resourceGroup.location
name = "henglufunction"
resource_group_name = azapi_resource.resourceGroup.name
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azapi_resource" "digest_processor" {
type = "Microsoft.Web/sites@2023-12-01"
location = azapi_resource.resourceGroup.location
name = "henglufunction"
parent_id = azapi_resource.resourceGroup.id
identity {
type = "SystemAssigned"
identity_ids = []
}
body = {
kind = "functionapp,linux"
properties = {
siteConfig = {
appSettings = [
{
name = "storageAccountConnectionString"
value = azurerm_storage_account.example.primary_blob_connection_string
}
]
}
serverFarmId = azapi_resource.plan.id
httpsOnly = true
functionAppConfig = {
deployment = {
storage = {
type = "blobContainer"
authentication = {
type = "StorageAccountConnectionString"
storageAccountConnectionStringName = "storageAccountConnectionString"
}
value = azurerm_storage_account.example.primary_blob_endpoint
}
}
scaleAndConcurrency = {
maximumInstanceCount = 40
instanceMemoryMB = 2048
}
runtime = {
name = "java"
version = "11"
}
}
# siteConfig = {
# appSettings = setunion(local.shared_function_appsettings, local.digest_appsettings)
# }
# keyVaultReferenceIdentity = azurerm_user_assigned_identity.event_processor_identity.id
# virtualNetworkSubnetId = azurerm_subnet.event_processor_subnet.id
}
}
}
So based on your example I went back and started commenting out/adding back in each of my settings that were extra and it seems like the error is because of the virtualNetworkSubnetId property. I was basing the setting off of this page https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites?pivots=deployment-language-terraform so I'm not sure what could be wrong with it, or if it's missing some other needed property.
It turned out my subnet was missing the Microsoft.Web service endpoint
I spoke too soon, I assumed since I could add the VNet in the portal once it had the correct service endpoint that it would then work in terraform, but I was wrong. Still the same error, but it's definitely related to the virtual network subnet id.
I updated my original comment with the subnet resource
I'm trying to create an azure function in a flex consumption plan. The terraform plan seems to work fine but the apply gives an error with nothing helpful even with diagnostics on.
Terraform code (let me know if you need any of the variable values):
Error: