Set up OpenTelemetry monitoring for Azure Functions on Consumption Plan
Dynatrace uses OpenTelemetry to monitor Azure Functions invocations.
For that purpose, Dynatrace provides language-specific packages, such as
Dynatrace.OpenTelemetry.Instrumentation.AzureFunctions.Core for .NET, that can be used in combination with default OpenTelemetry SDKs and APIs.
- Dynatrace version 1.240+
- OneAgent version 1.193+ for all OneAgents participating in a trace
- In the Dynatrace menu, go to Settings > Preferences > OneAgent features and activate the Forward Tag 4 trace context extension OneAgent feature.
Select a configuration method
- In the Dynatrace menu, go to Deploy Dynatrace and select Start installation.
- On the Install OneAgent page, select Azure Functions.
- On Enable Monitoring for Azure Functions, under How will you configure your Azure Functions?, select your preferred configuration method from the dropdown menu.
Specify a Dynatrace API endpoint optional
If you don't want to use the default public Dynatrace endpoint, specify a custom Dynatrace API endpoint where you want to receive monitoring data.
Note: To reduce network latency, you typically deploy a Dynatrace ActiveGate close to (in the same region as) the Azure Function that you want to monitor.
Apply the configuration to your function app
To apply the configuration, select one of the options below, depending on your configuration method.
Copy the JSON snippet into a file named
dtconfig.json located in the root folder of your Azure Functions deployment.
On Enable Monitoring for Azure Functions, under Use the following values to configure your monitored Azure Functions, there's a snippet with all required environment variables. Be sure to add these environment variables and their values to your function app configuration:
- In Azure Portal, go to your function app.
- In Settings, select Configuration.
- Edit any existing environment variables so that the names and values match those in the Dynatrace web UI, or, if your function app doesn't have any existing variables, select New application setting and add the names and values for all the variables in the Dynatrace web UI.
Note: Leave the settings not listed by Dynatrace unchanged.
Instrument the function code
Adding the required API calls to monitor function invocations via OpenTelemetry is specific to languages and their respective OpenTelemetry distribution:
- .NET (C#): Trace Azure Functions written in .NET
- Python: Trace Azure Functions written in Python
The Dynatrace Azure Functions integration doesn't capture the IP addresses of outgoing HTTP requests. If the called service isn't monitored with Dynatrace OneAgent, this results in unmonitored hosts.