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
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
# 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
{
"bindings": [
{
"name": "Timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
}
]
}