Send and verify events with Azure Functions telemetry
Use Azure Functions telemetry where your app knows the final result. Collect only the fields you need, then verify a test event before building charts.
- 1
Choose the outcome
Serverless function reliability
- 2
Define the contract
invocation_id, function_name, trigger_type, workflow, region, and release
- 3
Log the final result
Azure Functions retry behavior varies by trigger, so record the trigger type and use the invocation context available to the handler.
- 4
Check the stored event
Exercise a known fixture, then inspect azure_function_completed for one correctly typed terminal row.
Before you start
Before you start
- An Azure Functions app with telemetry-sh initialized outside the invocation handler
- Stable function, trigger, workflow, release, and environment names
- A reviewed retry policy for each trigger type and idempotent downstream work
Delivery setup
Install and initialize server-side
Import telemetry-sh in server-only code and initialize it once with process.env.TELEMETRY_API_KEY. Keep ingestion credentials out of browser bundles, client-visible environment variables, source control, logs, and exception messages.
npm installation
npm install telemetry-sh- 1Create one reusable server-side client. Set its timeout and retry limit.
- 2Log an event when the operation succeeds, fails, retries, or times out.
- 3Send test events with known results and inspect the stored rows before enabling an alert.
Snippet
Start with one structured event
Add this shape where the workflow completes, fails, or retries. Then build the dashboard from real fields.
Azure Functions telemetry event
await telemetry.log("azure_function_completed", {
invocation_id: context.invocationId,
function_name: "processBillingSync",
trigger_type: "service_bus",
workflow: "billing_sync",
status: "success",
attempt: deliveryCount,
duration_ms: Math.round(performance.now() - startedAt),
item_count: processedItems,
retry_scheduled: false,
environment: process.env.AZURE_FUNCTIONS_ENVIRONMENT,
release: process.env.APP_RELEASE,
});Event schema
invocation_id, function_name, trigger_type, workflow, region, and release
status, attempt, duration_ms, item_count, retry_scheduled, and error_type
message_id, route_template, account_id, dependency, and environment
Check your setup
Checkpoint 1
Azure Functions retry behavior varies by trigger, so record the trigger type and use the invocation context available to the handler.
Checkpoint 2
Emit the final application outcome in a finally path without turning a telemetry-delivery failure into a function failure.
Checkpoint 3
Keep trigger payloads, binding data, connection strings, authorization values, and unrestricted exception messages out of events.
Verification
Prove the event arrived
Run this after exercising known success and failure cases. Replace the fallback table name if your final event contract differs from the snippet.
Azure Functions telemetry verification query
SELECT *
FROM azure_function_completed
ORDER BY timestamp_utc DESC
LIMIT 20;Implementation references
Review the event contract, data-safety guidance, and upstream primary documentation before enabling a new production path.
Where to log
Keep the outcome event small and recoverable
This pattern provides
- Record the outcome as an event you can query with SQL.
- Stable fields for dashboards, alerts, and cross-event correlation.
- Test events for checking success, failure, retries, and timeouts.
This pattern does not provide
- An OTLP exporter, automatic collection pipeline, or replacement for detailed traces and diagnostic logs.
- Exactly-once delivery merely because the payload contains an event ID.
- Permission to collect raw provider payloads, user content, credentials, or regulated data.
Example event schemas
Event schemas for this workflow
Check what each event records, when to send it, and which field types it needs. Review the example payload and privacy checklist before using it in production.
Use these queries in Telemetry
Learn about Alerts
Add a threshold and recipients to your reliability query to get alerts.
Related SQL recipes
More SQL recipes
Run the query using this workflow's event fields and check the example result. Save the result to a dashboard or set up an alert.
Compare API reliability by release
Which releases coincide with worse API errors or tail latency?
Open recipeCalculate API error rate by route
Which API routes have the highest 5xx error rate with at least 20 requests?
Open recipeMeasure background job retry and failure rate
Which background jobs consume the most retries or still fail?
Open recipeDetect missing service heartbeats
Which expected telemetry sources have stopped sending heartbeats?
Open recipeBrowse by implementation family
Compare related integration patterns
Templates to pair with this integration
Background job failure monitor
Capture queue, cron, import, billing sync, and webhook job health from the first run through retries and failures.
Open templateAPI error and latency monitor
Watch request volume, status codes, route latency, failed endpoints, and customer-impacting API incidents.
Open templateMore integrations
Google Cloud Run telemetry
Track Cloud Run request and job outcomes, cold-start context, instance concurrency, retries, latency, and releases with application-owned structured events.
Open guideAWS ECS and Fargate telemetry integration
Add ECS task family, revision, availability zone, and release context to application outcomes using the local task metadata endpoint.
Open guideGo HTTP server structured logging
Add typed request-outcome events to Go HTTP services for route error rates, latency percentiles, and release comparisons.
Open guide