Testland
Browse all skills & agents

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-tests
View source

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 (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:

  • 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

  1. 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.
  2. Set AzureWebJobsStorage to UseDevelopmentStorage=true in local.settings.json so queue and timer triggers route to Azurite; keep the file git-ignored.
  3. Start Azurite, then run func start from the project root and note the printed HTTP trigger URLs.
  4. Exercise HTTP triggers with curl; fire non-HTTP (queue/timer) triggers through the /admin/functions/<name> endpoint - see references/triggering-functions.md.
  5. Unit-test handler logic directly (no running host) with the per-language patterns in references/unit-testing-handlers.md.
  6. Wire Core Tools + Azurite + dotnet test / pytest / npm test into CI using the workflow in references/triggering-functions.md.
  7. Confirm binding config against Azurite; verify Managed Identity / RBAC in a staging environment (see Limitations).

Reference files

Worked example

A .NET isolated function OrderProcessor is triggered by the orders queue. To gate it locally before deploy:

  1. func init OrderApp --worker-runtime dotnet-isolated, then func new --template "Azure Queue Storage Trigger" --name OrderProcessor.

  2. In local.settings.json, set "AzureWebJobsStorage": "UseDevelopmentStorage=true".

  3. Run azurite --silent --location ./azurite-data in one shell and func start in another.

  4. 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.

  5. 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-patternWhy it failsFix
Skip Azurite for queue/timer triggersQueue and storage triggers require AzureWebJobsStorage; without it func start errorsStart Azurite and set "AzureWebJobsStorage": "UseDevelopmentStorage=true" in local.settings.json
Use in-process model for new projectsSupport 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 codeSecrets leak to source controlUse local.settings.json Values array; it is git-ignored by default
Call admin endpoint without Content-Type: application/jsonHost rejects the requestAlways include Content-Type: application/json header and {"input":"..."} body
Commit local.settings.jsonContains secretsVerify .gitignore excludes it; use func settings to sync with Azure app settings
Use func host start for Core Tools v4Command removed in v4; it was v1.x syntax per Core Tools docsUse 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

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.