How to set the PowerShell stack in an Function app by Terraform ?

Khalid Hajjouji 50 Reputation points
2025-08-07T14:04:52.1466667+00:00

I succesfully provisioned a Azure Function App by terraform. How can I define that the Azure Function App should be of Stack "PowerShell"?

This is my current Terraform code:

resource "azurerm_storage_account" "storageAccount" {
  name                     = "funcappterformpocm365"
  resource_group_name      = data.azurerm_resource_group.this.name
  location                 = var.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "functionApp" {
  name                = "azure-functions-test-service-plan"
  location            = var.location
  resource_group_name = data.azurerm_resource_group.this.name

  sku {
    tier = "Standard"
    size = "S1"
  }
}

resource "azurerm_function_app" "example" {
  name                       = "az-func-app-terform-poc-m365"
  location                   = var.location
  resource_group_name        = data.azurerm_resource_group.this.name
  app_service_plan_id        = azurerm_app_service_plan.functionApp.id
  storage_account_name       = azurerm_storage_account.storageAccount.name
  storage_account_access_key = azurerm_storage_account.storageAccount.primary_access_key
  depends_on = [azurerm_storage_account.storageAccount, azurerm_app_service_plan.functionApp]
}


Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Krishna Chowdary Paricharla 2,080 Reputation points Microsoft External Staff Moderator
    2025-08-07T15:57:30.25+00:00

    Hello Khalid Hajjouji •,

    1. Provisioning Multiple Functions:

    Azure Function App is a container for multiple functions.

    Terraform doesn’t define individual functions.

    Use zip deployment with multiple function folders inside one .zip file.

    Set WEBSITE_RUN_FROM_PACKAGE to deploy the zip.

    2. Setting Stack to PowerShell:

    Set FUNCTIONS_WORKER_RUNTIME = "powershell" in app_settings.

    Use site_configapplication_stack to specify PowerShell version.

    Ensure os_type = "windows" and functions_extension_version = "~4".

    `app_settings = { FUNCTIONS_WORKER_RUNTIME = "powershell" WEBSITE_RUN_FROM_PACKAGE = "<zip URL or 1>" }

    site_config { application_stack { powershell_core_version = "7.2" } }`

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.