From qa-serverless
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.
How this skill is triggered — by the user, by Claude, or both
Slash command
/qa-serverless:azure-functions-testThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Azure Functions Core Tools v4 (`func.exe`) provides a local runtime that
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.
This skill is Azure-only and covers func start, Azurite, the .NET
isolated worker model, and admin-endpoint invocation.lambda-test-tools-net covers the .NET Lambda test runner. This
skill covers the .NET isolated worker model (Microsoft.Azure.Functions.Worker).serverless-integration-test-builder builds multi-function integration
harnesses. This skill covers the per-function local invocation workflow.# 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:
npm install -g azurite
# .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
Per
learn.microsoft.com/azure/azure-functions/functions-develop-local,
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.
Azurite emulates Blob (port 10000), Queue (port 10001), and Table (port 10002)
per
learn.microsoft.com/azure/storage/common/storage-install-azurite.
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
From the project root, per learn.microsoft.com/azure/azure-functions/functions-run-local#start-the-functions-runtime:
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.
# GET
curl http://localhost:7071/api/HttpExample?name=World
# POST
curl --request POST http://localhost:7071/api/HttpExample \
--data '{"name":"World"}'
Per learn.microsoft.com/azure/azure-functions/functions-manually-run-non-http, 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.
Testing handler code directly avoids the overhead of a running host. The approach differs by language.
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.
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);
}
// 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!');
});
# 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()
jobs:
azure-functions-test:
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
| 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 |
func start. Test with connection strings locally; verify RBAC
in a staging environment.cold-start-budget-reference.func start:
learn.microsoft.com/azure/azure-functions/functions-run-localaws-sam-local-testing,
lambda-test-tools-net,
cold-start-budget-reference,
netlify-functions-test,
vercel-edge-runtime-testing,
serverless-integration-test-buildernpx claudepluginhub testland/qa --plugin qa-serverlessGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.