How to upload many files in resource azurerm_function_app_function

I can upload only one file with file { } block for my resource “azurerm_function_app_function”

but i need more upload that only one file for my function app function (httpTrigger)

so how can you do that ?

funApp.tf :

resource "random_string" "uni_nam" {
  length  = 8
  special = false
  upper   = false
}

resource "azurerm_windows_function_app" "win_fun_app" {
  # fun. have to a unique name & available
  name                = "${var.fun_app_nam}-${random_string.uni_nam.result}"
  resource_group_name = azurerm_resource_group.rg_lab.name
  location            = var.location

  storage_account_name       = azurerm_storage_account.sto_acc.name
  storage_account_access_key = azurerm_storage_account.sto_acc.primary_access_key
  service_plan_id            = azurerm_service_plan.svc_pla.id

  site_config {
    application_stack {
      dotnet_version = var.fun_app_dot_ver
    }
  }

  app_settings = {
    "APPINSIGHTS_INSTRUMENTATIONKEY" = "azurerm_application_insights.app_ins.instrumentation_key"
  }

  depends_on = [
    azurerm_application_insights.app_ins
  ]
}


resource "azurerm_function_app_function" "httpTrigger" {
  name            = var.appFun_fun_name
  function_app_id = azurerm_windows_function_app.win_fun_app.id
  language        = "CSharp"

  # Changing this forces a new resource to be created
  # so can't use more that one file for contents different
  # e.g. readme.md & run.csx
  # workAround : upload_files
  file {
    name    = "run.csx"
    content = file("./run.csx")
  }


  config_json = jsonencode({
    "bindings" : [
      {
        "authLevel" : "function",
        "name" : "req",
        "type" : "httpTrigger",
        "direction" : "in",
        "methods" : [
          "get",
          "post"
        ]
      },
      {
        "name" : "$return",
        "type" : "http",
        "direction" : "out"
      }
    ]
  })
}

Hi @izq37532,

I’m not familiar with this particular provider feature but based on how providers typically represent situations like this I would guess that you might be able to write multiple file blocks, each one describing one file, like this:

  file {
    name    = "run.csx"
    content = file("${path.module}/run.csx")
  }

  file {
    name    = "README.md"
    content = file("${path.module}/README.md")
  }

I’d suggest trying this if you didn’t already try it. This particular resource type might not actually support multiple file blocks, but I’d try this first to see and then if this doesn’t work then hopefully someone else will have another idea.

Hi, thank you for your reply. However, if you put two files, the second file will be copied from the first one. You can test it to see for yourself.

hi, have you try on your side ?