0
votes

I am facing the below error with azure function app blob trigger deployed with terraform

D:\a\1\s\src\RequestProcessor.cs:line 196 2021-01-08T14:24:46.222 [Error] Executed 'Functions.BlobTrigger1' (Failed, Id=973f1e27-3dc2-43d3-9463-7cac64bf56b7, Duration=6625ms)Result: FailureException: Failed to install function app dependencies. Error: 'No 'requirements.psd1' is found at the function app root folder: C:\home\site\wwwroot.

I have used this https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app for creating terraform code, by using the above document and other reference in google, i have written the below code in main.tf

app_settings = {
        FUNCTIONS_WORKER_RUNTIME = var.FUNCTIONS_WORKER_RUNTIME
        FUNCTIONS_WORKER_RUNTIME_VERSION = var.FUNCTIONS_WORKER_RUNTIME_VERSION

Assigned the variable in variable.tf as below

variable "FUNCTIONS_WORKER_RUNTIME"{
    default = "PowerShell" 
}

variable "FUNCTIONS_WORKER_RUNTIME_VERSION" {
    default = "~7"
}

But still could not able to see PowerShell Core Version in the app.

2
Which Terraform version do you use? All the code works fine on my side.Charles Xu

2 Answers

1
votes

After my validation, you could set the value of FUNCTIONS_WORKER_RUNTIME to "powershell" instead of "PowerShell" and add the version = "~3". It will automatically install the function app dependencies requirements.psd1.

resource "azurerm_function_app" "example" {
  name                       = "urewwwwfunctiona"
  location                   = azurerm_resource_group.example.location
  resource_group_name        = azurerm_resource_group.example.name
  app_service_plan_id        = azurerm_app_service_plan.example.id
  storage_account_name       = azurerm_storage_account.example.name
  storage_account_access_key = azurerm_storage_account.example.primary_access_key

  app_settings = {
        FUNCTIONS_WORKER_RUNTIME = "powershell"
        FUNCTIONS_WORKER_RUNTIME_VERSION = "~7"
       
  }

  version = "~3"

}

enter image description here

enter image description here

0
votes

Hi I was able to deploy a Powershell Function App in Azure with azurerm_function_app, but Powershell Core Version is blank.

I followed Nancy Xiong suggestion, but with no success:

resource "azurerm_function_app" "example" {
  name                       = "functionapptest"
  location                   = azurerm_resource_group.example.location
  resource_group_name        = azurerm_resource_group.example.name
  app_service_plan_id        = azurerm_app_service_plan.example.id
  storage_account_name       = azurerm_storage_account.example.name
  storage_account_access_key = azurerm_storage_account.example.primary_access_key
  version = "~3"
  app_settings = {
        FUNCTIONS_WORKER_RUNTIME = "powershell"
        FUNCTIONS_WORKER_RUNTIME_VERSION = "~7"
       
  }
}

I was able to set the Python version for a Linux Function App using linux_fx_version, but I want to do the same for Powershell:

site_config {
    linux_fx_version = "PYTHON|3.9"
}

The Terraform documentation is not clear about Powershell Function Apps.