azure-functions-tests
Overview
Azure Functions Core Tools v4 (func.exe) provides a local runtime that
mirrors the Functions host on Azure. Per
learn.microsoft.com/azure/azure-functions/functions-run-local,
func start starts all triggers in the project directory and outputs the
URL of every HTTP-triggered function. Azurite emulates Blob, Queue, and
Table Storage locally so queue and timer triggers can be exercised without
a live storage account.
Nearest neighbours and how this skill differs:
aws-sam-local-testing wraps SAM Local for Lambda/API Gateway
(its references/dotnet.md covers the .NET Lambda test runner). This
skill is Azure-only and covers func start, Azurite, the .NET
isolated worker model (Microsoft.Azure.Functions.Worker), and
admin-endpoint invocation.
serverless-integration-test-builder builds multi-function integration
harnesses. This skill covers the per-function local invocation workflow.
When to use
- Local unit + integration tests for Azure Function handlers before deploy.
- Reproducing HTTP, queue, or timer trigger behaviour without deploying.
- CI gating on function handler logic in .NET, Node.js, or Python.
- Verifying binding configuration with Azurite instead of live Azure Storage.
How to use
- Install Core Tools v4 (
func --version shows 4.x) and Azurite, then
scaffold with func init and add triggers with func new - commands in
references/local-setup.md.
- Set
AzureWebJobsStorage to UseDevelopmentStorage=true in
local.settings.json so queue and timer triggers route to Azurite; keep
the file git-ignored.
- Start Azurite, then run
func start from the project root and note the
printed HTTP trigger URLs.
- Exercise HTTP triggers with
curl; fire non-HTTP (queue/timer) triggers
through the /admin/functions/<name> endpoint - see
references/triggering-functions.md.
- Unit-test handler logic directly (no running host) with the per-language
patterns in references/unit-testing-handlers.md.
- Wire Core Tools + Azurite +
dotnet test / pytest / npm test into CI
using the workflow in references/triggering-functions.md.
- Confirm binding config against Azurite; verify Managed Identity / RBAC in a
staging environment (see Limitations).
Reference files
- Install, project init,
local.settings.json, Azurite, and func start:
references/local-setup.md.
- Firing HTTP / queue / timer triggers and the CI workflow:
references/triggering-functions.md.
- Unit-testing handlers in .NET isolated, Node.js v4, and Python v2:
references/unit-testing-handlers.md.
Worked example
A .NET isolated function OrderProcessor is triggered by the orders
queue. To gate it locally before deploy:
func init OrderApp --worker-runtime dotnet-isolated, then
func new --template "Azure Queue Storage Trigger" --name OrderProcessor.
In local.settings.json, set
"AzureWebJobsStorage": "UseDevelopmentStorage=true".
Run azurite --silent --location ./azurite-data in one shell and
func start in another.
Fire the trigger through the admin endpoint:
curl --request POST -H "Content-Type: application/json" \
--data '{"input":"{\"orderId\":42}"}' \
http://localhost:7071/admin/functions/OrderProcessor
The host returns HTTP 202 (Accepted) and the function logs the processed order.
Unit-test OrderProcessor.Run with a mocked FunctionContext (xUnit),
asserting the parsed order id - no host required.
Result: queue-trigger wiring is verified against Azurite and handler logic is
gated in CI, with no live Azure Storage account.
Anti-patterns
| Anti-pattern |
Why it fails |
Fix |
| Skip Azurite for queue/timer triggers |
Queue and storage triggers require AzureWebJobsStorage; without it func start errors |
Start Azurite and set "AzureWebJobsStorage": "UseDevelopmentStorage=true" in local.settings.json |
| Use in-process model for new projects |
Support for in-process model ends 2026-11-10 per learn.microsoft.com/azure/azure-functions/dotnet-isolated-in-process-differences |
Use --worker-runtime dotnet-isolated |
| Hard-code connection strings in code |
Secrets leak to source control |
Use local.settings.json Values array; it is git-ignored by default |
Call admin endpoint without Content-Type: application/json |
Host rejects the request |
Always include Content-Type: application/json header and {"input":"..."} body |
Commit local.settings.json |
Contains secrets |
Verify .gitignore excludes it; use func settings to sync with Azure app settings |
Use func host start for Core Tools v4 |
Command removed in v4; it was v1.x syntax per Core Tools docs |
Use func start |
Limitations
- Azurite does not emulate Azure Files or Azure Data Lake Storage Gen2,
per
learn.microsoft.com/azure/storage/common/storage-use-azurite.
Functions that use these services must connect to live Azure Storage
during local testing.
- Event Grid triggers require extra configuration to run locally; the
admin-endpoint approach does not cover them. See
learn.microsoft.com/azure/azure-functions/functions-run-local#run-a-local-function
for the viewer web app approach.
- Managed Identity authentication and RBAC roles cannot be replicated
by
func start. Test with connection strings locally; verify RBAC
in a staging environment.
- Cold-start behaviour differs from production. For cold-start budgets see
serverless-integration-test-builder (its cold-start budget reference).
References
1---2name: azure-functions-tests3description: "Use when Azure Functions need testing before deploy: running them locally with Core Tools v4 and Azurite, unit tests for .NET isolated, Node v4 and Python v2 handlers, HTTP, queue and timer triggers, admin-endpoint calls and binding checks in local.settings.json."4metadata:5 source: https://skillmd.com/skills/testland/azure-functions-tests6 keywords: "azure-functions, func-start, azurite, isolated-worker, http-trigger, queue-trigger, timer-trigger, serverless, local-testing"7 version: "1.3.7"8---910# azure-functions-tests1112## Overview1314Azure Functions Core Tools v4 (`func.exe`) provides a local runtime that15mirrors the Functions host on Azure. Per16[learn.microsoft.com/azure/azure-functions/functions-run-local](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local),17`func start` starts all triggers in the project directory and outputs the18URL of every HTTP-triggered function. Azurite emulates Blob, Queue, and19Table Storage locally so queue and timer triggers can be exercised without20a live storage account.2122Nearest neighbours and how this skill differs:2324- `aws-sam-local-testing` wraps SAM Local for Lambda/API Gateway25 (its references/dotnet.md covers the .NET Lambda test runner). This26 skill is Azure-only and covers `func start`, Azurite, the .NET27 isolated worker model (`Microsoft.Azure.Functions.Worker`), and28 admin-endpoint invocation.29- `serverless-integration-test-builder` builds multi-function integration30 harnesses. This skill covers the per-function local invocation workflow.3132## When to use3334- Local unit + integration tests for Azure Function handlers before deploy.35- Reproducing HTTP, queue, or timer trigger behaviour without deploying.36- CI gating on function handler logic in .NET, Node.js, or Python.37- Verifying binding configuration with Azurite instead of live Azure Storage.3839## How to use40411. Install Core Tools v4 (`func --version` shows 4.x) and Azurite, then42 scaffold with `func init` and add triggers with `func new` - commands in43 [references/local-setup.md](references/local-setup.md).442. Set `AzureWebJobsStorage` to `UseDevelopmentStorage=true` in45 `local.settings.json` so queue and timer triggers route to Azurite; keep46 the file git-ignored.473. Start Azurite, then run `func start` from the project root and note the48 printed HTTP trigger URLs.494. Exercise HTTP triggers with `curl`; fire non-HTTP (queue/timer) triggers50 through the `/admin/functions/<name>` endpoint - see51 [references/triggering-functions.md](references/triggering-functions.md).525. Unit-test handler logic directly (no running host) with the per-language53 patterns in [references/unit-testing-handlers.md](references/unit-testing-handlers.md).546. Wire Core Tools + Azurite + `dotnet test` / `pytest` / `npm test` into CI55 using the workflow in [references/triggering-functions.md](references/triggering-functions.md).567. Confirm binding config against Azurite; verify Managed Identity / RBAC in a57 staging environment (see Limitations).5859## Reference files6061- Install, project init, `local.settings.json`, Azurite, and `func start`:62 [references/local-setup.md](references/local-setup.md).63- Firing HTTP / queue / timer triggers and the CI workflow:64 [references/triggering-functions.md](references/triggering-functions.md).65- Unit-testing handlers in .NET isolated, Node.js v4, and Python v2:66 [references/unit-testing-handlers.md](references/unit-testing-handlers.md).6768## Worked example6970A `.NET` isolated function `OrderProcessor` is triggered by the `orders`71queue. To gate it locally before deploy:72731. `func init OrderApp --worker-runtime dotnet-isolated`, then74 `func new --template "Azure Queue Storage Trigger" --name OrderProcessor`.752. In `local.settings.json`, set76 `"AzureWebJobsStorage": "UseDevelopmentStorage=true"`.773. Run `azurite --silent --location ./azurite-data` in one shell and78 `func start` in another.794. Fire the trigger through the admin endpoint:8081 ```bash82 curl --request POST -H "Content-Type: application/json" \83 --data '{"input":"{\"orderId\":42}"}' \84 http://localhost:7071/admin/functions/OrderProcessor85 ```8687 The host returns HTTP 202 (Accepted) and the function logs the processed order.885. Unit-test `OrderProcessor.Run` with a mocked `FunctionContext` (xUnit),89 asserting the parsed order id - no host required.9091Result: queue-trigger wiring is verified against Azurite and handler logic is92gated in CI, with no live Azure Storage account.9394## Anti-patterns9596| Anti-pattern | Why it fails | Fix |97|---|---|---|98| Skip Azurite for queue/timer triggers | Queue and storage triggers require `AzureWebJobsStorage`; without it `func start` errors | Start Azurite and set `"AzureWebJobsStorage": "UseDevelopmentStorage=true"` in `local.settings.json` |99| Use in-process model for new projects | Support for in-process model ends 2026-11-10 per [learn.microsoft.com/azure/azure-functions/dotnet-isolated-in-process-differences](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-differences) | Use `--worker-runtime dotnet-isolated` |100| Hard-code connection strings in code | Secrets leak to source control | Use `local.settings.json` `Values` array; it is git-ignored by default |101| Call admin endpoint without `Content-Type: application/json` | Host rejects the request | Always include `Content-Type: application/json` header and `{"input":"..."}` body |102| Commit `local.settings.json` | Contains secrets | Verify `.gitignore` excludes it; use `func settings` to sync with Azure app settings |103| Use `func host start` for Core Tools v4 | Command removed in v4; it was v1.x syntax per Core Tools docs | Use `func start` |104105## Limitations106107- Azurite does not emulate Azure Files or Azure Data Lake Storage Gen2,108 per109 [learn.microsoft.com/azure/storage/common/storage-use-azurite](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite).110 Functions that use these services must connect to live Azure Storage111 during local testing.112- Event Grid triggers require extra configuration to run locally; the113 admin-endpoint approach does not cover them. See114 [learn.microsoft.com/azure/azure-functions/functions-run-local#run-a-local-function](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local#run-a-local-function)115 for the viewer web app approach.116- Managed Identity authentication and RBAC roles cannot be replicated117 by `func start`. Test with connection strings locally; verify RBAC118 in a staging environment.119- Cold-start behaviour differs from production. For cold-start budgets see120 `serverless-integration-test-builder` (its cold-start budget reference).121122## References123124- Core Tools install and `func start`:125 [learn.microsoft.com/azure/azure-functions/functions-run-local](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local)126- Local development overview:127 [learn.microsoft.com/azure/azure-functions/functions-develop-local](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-local)128- .NET isolated worker model guide:129 [learn.microsoft.com/azure/azure-functions/dotnet-isolated-process-guide](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide)130- In-process vs isolated model comparison:131 [learn.microsoft.com/azure/azure-functions/dotnet-isolated-in-process-differences](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-differences)132- Azurite install and run:133 [learn.microsoft.com/azure/storage/common/storage-install-azurite](https://learn.microsoft.com/en-us/azure/storage/common/storage-install-azurite)134- Azurite emulator overview:135 [learn.microsoft.com/azure/storage/common/storage-use-azurite](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite)136- Manually run non-HTTP triggers:137 [learn.microsoft.com/azure/azure-functions/functions-manually-run-non-http](https://learn.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http)138- Sibling skills:139 `aws-sam-local-testing`,140 `serverless-integration-test-builder` (its cold-start budget reference),141 `cloudflare-workers-miniflare`,142 `serverless-integration-test-builder`