azure-functions-tests
Runs Azure Functions locally using Azure Functions Core Tools v4 (`func start`), Azurite storage emulation, and framework-native unit tests for handler code (.NET isolated worker model, Node.js v4, Python v2). Covers HTTP, queue, and timer trigger testing, admin-endpoint invocation for non-HTTP triggers, and binding verification via local.settings.json. Use when testing Azure Functions before deployment, reproducing trigger behaviour without live Azure services, or gating function handler logic in CI.
Install with skills.sh (any agent)
npx skills add testland/qa --skill azure-functions-testsazure-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 (opens in new window), 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:
When to use
How to use
Reference files
Worked example
A .NET isolated function OrderProcessor is triggered by the orders queue. To gate it locally before deploy:
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 (opens in new window) | 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
References
Local environment setup
View source (opens in new window)Local environment setup
Install Azure Functions Core Tools v4 and Azurite, scaffold the app, and start the local host. Companion to the azure-functions-tests skill.
Install
# macOS
brew tap azure/functions
brew install azure-functions-core-tools@4
# Ubuntu/Debian (see full APT steps at learn.microsoft.com/azure/azure-functions/functions-run-local#install-the-azure-functions-core-tools)
sudo apt-get install azure-functions-core-tools-4
# Windows: download the MSI from
# https://go.microsoft.com/fwlink/?linkid=2174087 (64-bit) per the Core Tools docs
Verify:
func --version # must be 4.x
Install Azurite via npm, per learn.microsoft.com/azure/storage/common/storage-install-azurite (opens in new window):
npm install -g azurite
Project initialisation
# .NET isolated worker model (recommended; in-process support ends 2026-11-10
# per learn.microsoft.com/azure/azure-functions/dotnet-isolated-in-process-differences)
func init MyApp --worker-runtime dotnet-isolated
# Node.js (v4 programming model)
func init MyApp --worker-runtime javascript --model V4
# Python (v2 programming model)
func init MyApp --worker-runtime python --model V2
# Add a trigger template
func new --template "Http Trigger" --name HttpExample
func new --template "Azure Queue Storage Trigger" --name QueueExample
func new --template "Timer trigger" --name TimerExample
local.settings.json
Per learn.microsoft.com/azure/azure-functions/functions-develop-local (opens in new window), local.settings.json holds app settings used only when running locally. Set AzureWebJobsStorage to UseDevelopmentStorage=true to route storage triggers to Azurite:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
}
}
Never commit local.settings.json to source control; it may contain connection strings.
Start Azurite
Azurite emulates Blob (port 10000), Queue (port 10001), and Table (port 10002) per learn.microsoft.com/azure/storage/common/storage-install-azurite (opens in new window). Start it before func start:
azurite --silent --location ./azurite-data
For Docker:
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
mcr.microsoft.com/azure-storage/azurite
Start the local Functions host
From the project root, per learn.microsoft.com/azure/azure-functions/functions-run-local#start-the-functions-runtime (opens in new window):
func start
Output includes HTTP trigger URLs, e.g.:
Http Function HttpExample: http://localhost:7071/api/HttpExample
By default, HTTP authorization is not enforced locally (all requests are treated as authLevel = "anonymous"). Pass --enableAuth to require authorization during local testing.
Triggering functions and CI
View source (opens in new window)Triggering functions and CI
How to fire HTTP, queue, and timer triggers against the local host, and how to wire the local runtime into CI. Companion to the azure-functions-tests skill.
HTTP trigger
# GET
curl http://localhost:7071/api/HttpExample?name=World
# POST
curl --request POST http://localhost:7071/api/HttpExample \
--data '{"name":"World"}'
Non-HTTP triggers (admin endpoint)
Per learn.microsoft.com/azure/azure-functions/functions-manually-run-non-http (opens in new window), non-HTTP triggers can be fired via the admin endpoint. Authorization is bypassed locally:
# Queue trigger named QueueExample
curl --request POST \
-H "Content-Type: application/json" \
--data '{"input":"sample queue payload"}' \
http://localhost:7071/admin/functions/QueueExample
# Timer trigger named TimerExample (empty input is valid)
curl --request POST \
-H "Content-Type: application/json" \
--data '{}' \
http://localhost:7071/admin/functions/TimerExample
The endpoint returns HTTP 202 (Accepted) on success.
CI integration
jobs:
azure-functions-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Core Tools
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update && sudo apt-get install -y azure-functions-core-tools-4
- name: Start Azurite
run: npx azurite --silent &
- name: Run unit tests
run: dotnet test # or: pytest / npm test
Unit-testing handlers
View source (opens in new window)Unit-testing handlers
Testing handler code directly avoids the overhead of a running host. The approach differs by language. Companion to the azure-functions-tests skill.
.NET isolated worker model
The .NET isolated worker model runs function code in a separate worker process from the Functions host, per learn.microsoft.com/azure/azure-functions/dotnet-isolated-in-process-differences (opens in new window). The core packages are Microsoft.Azure.Functions.Worker and Microsoft.Azure.Functions.Worker.Sdk. HTTP triggers use HttpRequestData / HttpResponseData (not HttpRequest/IActionResult) unless ASP.NET Core integration is enabled.
Because handler classes can use dependency injection, extract service dependencies behind interfaces and substitute test doubles. The FunctionContext can be mocked with any standard mock library.
// Handler under test
public class HttpExample
{
[Function("HttpExample")]
public HttpResponseData Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
FunctionContext context)
{
var response = req.CreateResponse(HttpStatusCode.OK);
response.WriteString("Hello from Azure Functions");
return response;
}
}
// xUnit test - construct HttpRequestData via a mock FunctionContext
// (use Moq, NSubstitute, or similar for FunctionContext and HttpRequestData)
[Fact]
public async Task Run_ReturnsOk()
{
var context = new Mock<FunctionContext>();
var request = CreateMockHttpRequest(context.Object, HttpMethod.Get);
var function = new HttpExample();
var response = function.Run(request, context.Object);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
Node.js (v4 programming model)
// handler.js
const { app } = require('@azure/functions');
app.http('HttpExample', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
const name = request.query.get('name') || 'World';
return { body: `Hello, ${name}!` };
},
});
// handler.test.js (Jest)
const { handler } = require('./handler');
test('returns greeting', async () => {
const req = { query: new URLSearchParams('name=Test'), text: async () => '' };
const ctx = { log: jest.fn() };
const res = await handler(req, ctx);
expect(res.body).toBe('Hello, Test!');
});
Python (v2 programming model)
# function_app.py
import azure.functions as func
app = func.FunctionApp()
@app.route(route="HttpExample")
def http_example(req: func.HttpRequest) -> func.HttpResponse:
name = req.params.get('name', 'World')
return func.HttpResponse(f"Hello, {name}!")
# test_function_app.py (pytest)
import azure.functions as func
from function_app import http_example
def test_http_example():
req = func.HttpRequest(
method='GET',
url='/api/HttpExample',
params={'name': 'Test'},
body=b''
)
resp = http_example(req)
assert resp.status_code == 200
assert 'Test' in resp.get_body().decode()
Related skills
aws-sam-local-testing
Wraps AWS SAM (Serverless Application Model) Local CLI for testing Lambda functions locally: `sam local invoke` (single invocation with event payload), `sam local start-api` (local API Gateway emulator), `sam local start-lambda` (local Lambda invoke endpoint for AWS SDK clients), and event-payload generation (`sam local generate-event`). For C#/.NET Lambdas, references/dotnet.md covers handler-direct testing with Amazon.Lambda.TestUtilities (TestLambdaContext, TestLambdaLogger) and the dotnet-lambda CLI. Use when testing Lambda + API Gateway + integrated AWS services locally.
cloudflare-workers-miniflare
Wraps Miniflare 3 (the official Cloudflare Workers simulator) and Wrangler dev for testing Workers locally. Covers Miniflare's getMiniflare() programmatic API (workerd-backed simulation matching prod), the wrangler dev local-mode (live-reload during dev), KV / Durable Objects / R2 / D1 bindings emulation, and Vitest + @cloudflare/vitest-pool-workers for in-process tests. Use when testing Cloudflare Workers code locally.
cold-start-budget-reference
Pure-reference catalog of latency budgets across serverless runtimes: cold starts AND timeouts. Covers AWS Lambda's three-phase cold start (Init: download+unzip+runtime-bootstrap; Init code: imports + module load; Invoke: handler execution), Cloudflare Workers' isolate model (sub-millisecond cold starts via V8 isolates per developers.cloudflare.com), Vercel Edge Runtime, Lambda SnapStart for JVM (snapshot-restore for Java), and provisioned-concurrency trade-offs, plus Lambda timeout + billing budgets in references/timeout-budgets.md (the 15-minute hard limit, getRemainingTimeInMillis, per-ms billing, memory-CPU scaling, the API Gateway 29s / SQS visibility-timeout integration cascade). Use when designing latency or timeout budgets, choosing a runtime, sizing memory, or auditing cold-start variance in production.
serverless-integration-test-builder
Workflow-driven skill that builds the integration-test suite for a serverless application from its IaC definition (SAM template / serverless.yml / Wrangler config / Vercel functions / Netlify functions). Walks through: identifying the function inventory + event sources, picking the right local-emulator per function (sam local / Miniflare / netlify dev / vercel dev / serverless-offline), generating test events per event source, asserting on cold-start + timeout budgets, and emitting the test directory + CI config. Use when introducing integration tests to a serverless project.