Function Apps
Introduction
Section titled “Introduction”Azure Function Apps are serverless compute resources that host and execute Azure Functions in response to events. They support multiple runtime environments including Python, Node.js, and .NET, and integrate with a wide range of trigger sources such as HTTP requests, queues, and timers. Function Apps are commonly used to build event-driven microservices, scheduled background jobs, and lightweight API backends. For more information, see Introduction to Azure Functions.
LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Function Apps. The supported APIs are available on our API Coverage section, which provides information on the extent of Function Apps’ integration with LocalStack.
Getting started
Section titled “Getting started”This guide walks you through creating a Function App backed by a Storage Account, deploying a Python HTTP-trigger function, and invoking it.
Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:
azlocal start-interceptionThis command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
To revert this configuration, run:
azlocal stop-interceptionThis reconfigures the az CLI to send commands to the official Azure management REST API.
Create a resource group
Section titled “Create a resource group”Create a resource group to hold all resources created in this guide:
az group create --name rg-func-demo --location westeurope{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-func-demo", "location": "eastus", "name": "rg-func-demo", "properties": { "provisioningState": "Succeeded" }, "type": "Microsoft.Resources/resourceGroups"}Create a storage account
Section titled “Create a storage account”Function Apps require a Storage Account for internal bookkeeping.
az storage account create \ --name safuncdemo \ --resource-group rg-func-demo \ --location westeurope \ --sku Standard_LRS{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-func-demo/providers/Microsoft.Storage/storageAccounts/safuncdemo", "kind": "StorageV2", "location": "eastus", "name": "safuncdemo", "provisioningState": "Succeeded", "resourceGroup": "rg-func-demo", "sku": { "name": "Standard_LRS", "tier": "Standard" }, "type": "Microsoft.Storage/storageAccounts", ...}Create a function app
Section titled “Create a function app”Create a function app and associate it with the storage account and App Service plan:
az functionapp create \ --name my-func-app \ --resource-group rg-func-demo \ --consumption-plan-location eastus \ --runtime python \ --runtime-version 3.13 \ --functions-version 4 \ --os-type linux \ --storage-account safuncdemo{ "defaultHostName": "my-func-app.azurewebsites.azure.localhost.localstack.cloud:4566", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-func-demo/providers/Microsoft.Web/sites/my-func-app", "kind": "functionapp,linux", "location": "eastus", "name": "my-func-app", "resourceGroup": "rg-func-demo", "state": "Running", "type": "Microsoft.Web/sites", ...}Configure app settings
Section titled “Configure app settings”Add environment variables as application settings on the function app:
az functionapp config appsettings set \ --name my-func-app \ --resource-group rg-func-demo \ --settings \ FUNCTIONS_WORKER_RUNTIME=python \ MY_CUSTOM_SETTING=hello-world[ { "name": "FUNCTIONS_WORKER_RUNTIME", "slotSetting": false, "value": "python" }, { "name": "MY_CUSTOM_SETTING", "slotSetting": false, "value": "hello-world" }, { "name": "AzureWebJobsStorage", "slotSetting": false, "value": "DefaultEndpointsProtocol=https;..." }, ...]List application settings
Section titled “List application settings”List all application settings currently configured on the function app:
az functionapp config appsettings list \ --name my-func-app \ --resource-group rg-func-demo[ { "name": "FUNCTIONS_WORKER_RUNTIME", "slotSetting": false, "value": "python" }, { "name": "FUNCTIONS_EXTENSION_VERSION", "slotSetting": false, "value": "~4" }, { "name": "AzureWebJobsStorage", "slotSetting": false, "value": "DefaultEndpointsProtocol=https;..." }, { "name": "MY_CUSTOM_SETTING", "slotSetting": false, "value": "hello-world" }, ...]Create the function package
Section titled “Create the function package”Create a directory for the function source and add the required files:
mkdir my_func && cd my_funcCreate function_app.py with an HTTP-triggered function:
import azure.functions as func
app = func.FunctionApp()
@app.function_name(name="HelloWorld")@app.route(route="public", methods=["GET"], auth_level=func.AuthLevel.ANONYMOUS)def public(req: func.HttpRequest) -> func.HttpResponse: name = req.params.get("name", "World") return func.HttpResponse(f"Hello, {name}!")Create host.json:
{ "version": "2.0"}Create requirements.txt:
azure-functionsPackage everything into a zip archive and return to the parent directory:
zip my_func.zip function_app.py host.json requirements.txtcd ..Deploy function code
Section titled “Deploy function code”Deploy the zip package to the function app:
az functionapp deploy \ --resource-group rg-func-demo \ --name my-func-app \ --src-path ./my_func/my_func.zip \ --type zipInvoke an HTTP-trigger function
Section titled “Invoke an HTTP-trigger function”After deployment, invoke the function via its default hostname:
curl "http://my-func-app.azurewebsites.azure.localhost.localstack.cloud:4566/api/public?name=LocalStack"Hello, LocalStack!List and inspect function apps
Section titled “List and inspect function apps”List all function apps in the resource group in table format and retrieve the full configuration of the app:
az functionapp list --resource-group rg-func-demo --output tableName Location State ResourceGroup DefaultHostName AppServicePlan----------- ---------- ------- --------------- ---------------------------------------------------------------- ----------------my-func-app East US Running rg-func-demo my-func-app.azurewebsites.azure.localhost.localstack.cloud:4566 Default1pnThen retrieve the full configuration of the function app:
az functionapp show --name my-func-app --resource-group rg-func-demo{ "defaultHostName": "my-func-app.azurewebsites.azure.localhost.localstack.cloud:4566", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-func-demo/providers/Microsoft.Web/sites/my-func-app", "kind": "functionapp,linux", "location": "East US", "name": "my-func-app", "resourceGroup": "rg-func-demo", "state": "Running", "type": "Microsoft.Web/sites"...}Delete and verify
Section titled “Delete and verify”Delete the resource and confirm it no longer appears in the list:
az functionapp delete --name my-func-app --resource-group rg-func-demoThen list all function apps to confirm the resource group is now empty:
az functionapp list --resource-group rg-func-demo[]Features
Section titled “Features”- Full CRUD lifecycle: Create, read, update, and delete Function App resources using the Azure CLI or ARM API.
- App settings management: Set and list application settings via
az functionapp config appsettings. - Site configuration: Configure site properties including
linuxFxVersion,use32BitWorkerProcess, andalwaysOn. - Publishing credentials: Retrieve deployment credentials via the
listPublishingCredentialsaction. - Publishing profile: Download publish profiles via the
listPublishingProfileXmlWithSecretsaction. - SCM access control: Get and configure source control manager (SCM) access policy.
- Diagnostic logs: Configure logging via
az functionapp log config. - Consumption plan auto-provisioning: An App Service Plan is automatically created for the Function App when using a consumption plan location.
- Docker container execution: Actual function execution is backed by a Docker container spawned on deploy.
- HTTP trigger invocation: HTTP-triggered functions are accessible via the default host name after deployment.
- Multiple runtimes: Python, Node.js, and .NET function runtimes are supported for execution.
Limitations
Section titled “Limitations”- Docker required for execution: Function code execution requires Docker to be running. Without Docker, the Function App resource can be created and managed, but code will not run.
- Durable Functions not supported: Stateful orchestration via Durable Functions is not emulated.
- Timer and non-HTTP triggers: Timer, Blob, Queue, Service Bus, Event Hub, Event Grid, and Cosmos DB triggers are not automatically fired by LocalStack. They must be invoked manually or by external tooling.
- Deployment slots: Staging slots and slot swaps are not supported.
- Log streaming: Live log streaming via
az functionapp log tailis not supported. - Managed identities for functions: Assigning a managed identity to a Function App is accepted at the ARM level but authentication tokens are not issued for bindings.
Samples
Section titled “Samples”The following sample demonstrates how to use Azure Function Apps with LocalStack for Azure:
- Function App and Storage
- Function App and Front Door
- Function App and Managed Identities
- Function App and Service Bus
API Coverage
Section titled “API Coverage”| Operation ▲ | Implemented ▼ |
|---|