hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.51k stars 4.6k forks source link

can't create azurerm_function_app_function in python with programming model v2 #25460

Open mdameda opened 5 months ago

mdameda commented 5 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.6.6

AzureRM Provider Version

3.97.1

Affected Resource(s)/Data Source(s)

azurerm_function_app_function

Terraform Configuration Files

resource azurerm_linux_function_app "events_func_app" {
  name                       = "events-fun-app"
  resource_group_name        = var.general.resource_group_name
  location                   = var.region

  service_plan_id            = var.app_device_events_plan_id

  storage_account_name       = var.storage_account_device_events_name
  storage_account_access_key = var.storage_account_device_events_primary_access_key

  app_settings = {
    SERVICE_BUS_CONNECTION   = var.service_bus_primary_connection
    APPINSIGHTS_INSTRUMENTATIONKEY = var.app_insights_instrumentation_key
  }

  site_config {

    application_stack {
      python_version = "3.10"
    }
  }
}

resource "azurerm_function_app_function" "ota_updates_function" {
  name            = "${var.general.prefix}-${var.general.region.main}-ota-upd-func"
  function_app_id = azurerm_linux_function_app.events_func_app.id
  language        = "Python"

  config_json = jsonencode({
    "bindings" = [
      {
        "direction" = "in",
        "name" = "sbTrigger",
        "type" = "serviceBusTrigger",
        "queueName": var.ota_events_queue_name,
        "connection": "SERVICE_BUS_CONNECTION",
        "accessRights": "manage"
      }
    ]
  })

}

resource "azurerm_function_app_function" "dev_events_function" {
  name            = "dev_events-func"
  function_app_id = azurerm_linux_function_app.events_func_app.id
  language        = "Python"

  config_json = jsonencode({
    "bindings" = [
      {
        "type": "eventGridTrigger",
        "name": "event",
        "direction": "in"
      }
    ]
  })

}

Debug Output/Panic Output

creating Function (Subscription: "xxxxxxxxxxxxxxxxxxxxxxx"
│ Resource Group Name: "xxx-test"
│ Site Name: "xxx-test-westeurope-events-fun-app"
│ Function Name: "faber-test-westeurope-dev_events-func"): performing CreateFunction: unexpected status 400 (400 Bad Request) with response: {"Code":"BadRequest","Message":"Encountered an error (InternalServerError) from host
│ runtime.","Target":null,"Details":[{"Message":"Encountered an error (InternalServerError) from host runtime."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","Message":"Encountered an error (InternalServerError) from
│ host runtime."}}],"Innererror":null}

Expected Behaviour

If the function of type Event Grid Trigger, will be created as second (not for first) i've a BadRequestError.

Expected behaviour is that the app function App dev_events_function (python v1 programming model) will be created. So i tried to create this app using python programming model v2 (that don't require function.json configuration file, but use python decorators), but is now currently impossible because on terraform , the config_json is a REQUIRED param (but in v2 isn't required).

Actual Behaviour

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

vrumiantsev commented 1 month ago

Any progress on this? I'm also facing same kind of issue