The Atatus .NET APM Agent enables you to monitor Azure Functions app by tracing HTTP-triggered executions, automatically capturing performance data and errors, and sending telemetry to your Atatus dashboard.

Prerequisites

  1. An active Atatus account with APM enabled. If not set up yet, follow the Atatus APM Setup guide if you have not set one up yet.
  2. An Azure Functions project built with the .NET isolated worker model (Functions 4.x). If you don’t already have one, you can create it by following Azure guide.

Azure Functions isolated worker model

Step 1: Install the Atatus .NET package

Add the Atatus Azure Functions middleware package to the Functions project:

Step 2: Add tracing middleware

Configure the Functions isolated worker host to use the Atatus middleware. This ensures function executions are traced and distributed context is propagated automatically.

Step 3: Configure the APM agent

The agent requires configuration via environment variables. These can be set in local.settings.json for local development or in Application Settings within the Azure Portal for production deployments. Required variables:
If ATATUS_APP_NAME is not set:
  • Local development: Entry assembly name is used.
  • Azure: Function App name (WEBSITE_SITE_NAME) is used.

Local Development Example

While developing your Function locally, you can configure the agent by providing the environment variables via the local.settings.json file.

Configure in Azure

Using environment variables allows you to use application settings in the Azure Portal, enabling you to update settings without needing to re-deploy code. To set configuration in production:
  1. Open your function app in the Azure Portal
  2. Navigate to Settings > Environment variables.
  3. Add or update the Atatus environment variables.
  4. Save and restart the Function App.

Limitations

Background system metrics are not collected by the agent within Azure Functions Consumption plans to avoid unintended cost impact.

Step 4: Advanced setup to capture ILogger errors and outbound spans (optional)

Steps 1-3 trace function executions only. To also capture LogError and LogCritical calls as Atatus error logs and to trace outbound HTTP, database, Service Bus, Cosmos DB, and other operations, add the Atatus.Extensions.Hosting package and register the specific subscribers your function uses.

Install Atatus.Extensions.Hosting

Install the integration packages

Install a package per integration you want to trace. The commonly used integrations are shown below. Skip the ones your function does not use to keep the deployed app small and cold starts fast.
HttpClient and SqlClient ship in the core Atatus package and do not require a separate install. For MongoDB, gRPC client, or Elasticsearch, install the matching package from the Supported integrations table below and register its subscriber the same way.

Register subscribers with AddAtatus

The snippet below registers the commonly used subscribers. Remove the lines for integrations your function does not use, and add any others from the Supported integrations table.
The host.Services.GetRequiredService<IApmAgent>() call is required. AddAtatus registers IApmAgent as a lazy DI singleton, so subscribers and the ApmErrorLoggingProvider only get wired up the first time IApmAgent is resolved. If ApmMiddleware runs first on an HTTP request, it bootstraps the agent from environment variables and the DI factory short-circuits, leaving your subscribers and error log capture inactive. Resolving IApmAgent before host.Run() prevents this.

Supported integrations

Every integration has its own package and diagnostics subscriber, documented in detail on its assembly page. The commonly used ones are configured in the setup above; add any others (MongoDB, gRPC client, Elasticsearch) the same way.

Enable log capture

To send LogError and LogCritical calls to Atatus, set ATATUS_CAPTURE_LOGS to true in local.settings.json or in the Function App Application Settings.