Search code examples
azurepowershellazure-functionsterraformazure-blob-trigger

Issue in deploying Azure powershell function app with terraform


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.


Solution

  • 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