简体   繁体   中英

How to build an empty Azure Function with terraform?

I'm creating an Azure Function App and would like to create an empty functions inside it (it's a requirement for eventgrid subscription).

i created a null resource:

resource "null_resource" "functions" {

  triggers = {
    functions = "${var.FUNCTION_VERSION}_${join("+", [for value in var.FUNCTIONS : value])}"
  }

  provisioner "local-exec" {
command = <<-EOT
            func azure functionapp publish ${var.FUNCTION_NAME} --dotnet;
          EOT
  }
}

But it doesn't work, I get the following error:

╷
│ Error: local-exec provisioner error
│
│   with null_resource.functions,
│   on az-function.tf line 55, in resource "null_resource" "functions":
│   55:   provisioner "local-exec" {
│

│ Error running command 'func azure functionapp publish gm-asset-pm --dotnet;
│ ': exit status 127. Output: Getting site publishing info...
│ Uploading package...
│ Uploading 34.43 MB [Upload completed successfully.----------------------------]
│ Deployment completed successfully.
│ Syncing triggers...
│ Functions in gm-asset-pm:
: not found1:

Any idea ? appreciate your help.

you can set the app_settings.WEBSITE_RUN_FROM_PACKAGE pointing to a zip file with the function you want to deploy.

eg

WEBSITE_RUN_FROM_PACKAGE = "https://${azurerm_storage_account.storage.name}.blob.core.windows.net/${azurerm_storage_container.deployments.name}/${azurerm_storage_blob.appcode.name}${data.azurerm_storage_account_sas.sas.sas}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM