# How to create a function inside an Azure function app?

**URL:** <https://discuss.hashicorp.com/t/how-to-create-a-function-inside-an-azure-function-app/76140>\
**Category:** Terraform\
**Created:** [August 8, 2025, 3:04pm UTC](https://discuss.hashicorp.com/t/how-to-create-a-function-inside-an-azure-function-app/76140 "2025-08-08T15:04:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![khalid.hajjouji](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@khalid.hajjouji](https://discuss.hashicorp.com/u/khalid.hajjouji)\
**Post date:** [August 8, 2025, 3:04pm UTC](https://discuss.hashicorp.com/t/how-to-create-a-function-inside-an-azure-function-app/76140/1 "2025-08-08T15:04:34Z")

</div>

I created an Terraform pipeline in Azure DevOps with the code below. How can I add an function inside the Azure function app?

**Azureresources.tf**

```auto
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_windows_function_app" "example7" {

  name = "az-func-app-terform-poc-m365-G"
  location = var.location
  resource_group_name = data.azurerm_resource_group.this.name
  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

  site_config {}

  app_settings = {
        FUNCTIONS_WORKER_RUNTIME = "powershell"
        FUNCTIONS_WORKER_RUNTIME_VERSION = "7.4"
  }

  depends_on = [azurerm_storage_account.storageAccount, azurerm_app_service_plan.functionApp]
}

```

**Run.ps1**

```auto
# Input bindings are passed in via param block.
param($Timer)

# Get the current universal time in the default string format.
$currentUTCtime = (Get-Date).ToUniversalTime()

# The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.
if ($Timer.IsPastDue) {
    Write-Host "PowerShell timer is running late!"
}

# Write an information log with the current time.
Write-Host "PowerShell timer trigger function ran! TIME: $currentUTCtime"

```

**Function.ps1**

```auto
{
  "bindings": [
    {
      "name": "Timer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */5 * * * *"
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [February 4, 2026, 3:04pm UTC](https://discuss.hashicorp.com/t/how-to-create-a-function-inside-an-azure-function-app/76140/2 "2026-02-04T15:04:54Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
