Skip to content

MaarkssDN/Birthub-360 / .agents/skills/azure-functions-tests

azure-functions-tests

Verified

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.

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

  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-differencesUse --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

  • 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

finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall