Monitor Azure Functions on App Service Plan for Windows
Capabilities
- Full-stack monitoring powered by OneAgent
- Extension for easy deployment of OneAgent
- Support for Azure Functions that are written in .NET (in-process) and hosted on an App Service Plan on Windows
- Enhanced support for Azure App Service metadata such as compute mode, SKU, and more
- Automatic service detection for functions written in any language for Azure Function Runtime v2+
- Automatic tracing and code-profiling for .NET/.NET Core based functions
- End-to-end tracing across multiple functions for http-based triggers and other instrumented services and applications. Other triggers such as QueueTriggers require custom trace propagation.
Dynatrace provides an Azure Site-Extension to install OneAgent on Azure Functions. Azure Site Extensions are the native extension mechanism provided via Kudu, which is the deployment management engine behind Azure App Services.
The extension doesn't include the OneAgent installer. Instead, the extension uses the Dynatrace REST API to download the latest installer from the cluster, unless a OneAgent default version is configured.
Prerequisites
-
Create a PaaS token.
-
Determine your environment ID.
-
Determine your server URL if required.
The server URL is required only if you use either of the following:
- a Dynatrace Managed endpoint
- an ActiveGate for a Dynatrace Managed or Dynatrace SaaS endpoint
(If you use Dynatrace SaaS, the URL is automatically generated from the environment ID.)
- Dynatrace Managed server URL:
https://{your-domain}/e/{your-environment-id}/api
- ActiveGate server URL:
https://<your-active-gate-IP-or-hostname>:9999/e/<your-environment-id>/api
(the ActiveGate port is configurable)
Note: If you're using Dynatrace Managed, or if your cluster traffic should be routed through an ActiveGate, you need to configure the API endpoint used by the extension for downloading OneAgent.
Install Dynatrace OneAgent site extension
There are two ways to install the Dynatrace OneAgent site extension: via Azure Portal or using an ARM template. Follow the steps below for instructions.
Install Dynatrace OneAgent site extension via Azure Portal
- In Azure Portal, go to the App Service where you want to add the OneAgent extension.
- In the left menu, scroll down to Development Tools and select Extensions.
- Select Add.
- Select Choose extension.
- From the list of extensions, select Dynatrace OneAgent.
- Select Accept legal terms and then select OK to accept the legal terms.
- Select OK to add the extension.
- In the left menu select Advanced Tools and press Go.
- Select Site extensions.
- Select Launch on the Dynatrace tile.
- On the Start monitoring your App Service instance page, enter your environment ID, your PaaS token, and your server URL. See Prerequisites section for details.
- optional You can select Accept all self-signed SSL certificates to automatically accept all self-signed TLS certificates.
- Select Install OneAgent.
- To check the deployment status, in your Dynatrace environment, go to Manage and select Deployment status.
- After installation is complete, go to Site extension tab in Kudu and select Restart Site.
- Restart the App Service application to recycle the application's worker process
After restart, OneAgent starts monitoring your application automatically.
Install Dynatrace OneAgent site extension using an ARM template
Alternatively to the main installation method via Azure Portal, you can make the Dynatrace site extension part of your ARM templates.
Example configuration:
{
"apiVersion": "2016-08-01",
"name": "[parameters('resourceName')]",
"type": "Microsoft.Web/sites",
"properties": {
"name": "[parameters('resourceName')]",
"siteConfig": {
"alwaysOn": true,
"appSettings": [
{ "Name": "DT_TENANT", "Value": "<Environment-ID>" },
{ "Name": "DT_API_TOKEN", "Value": "<PaaS-Token>" },
{ "Name": "DT_API_URL", "Value": "<Server-Url>" },
{ "Name": "DT_SSL_MODE", "Value": "default" }
]
},
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('resourceName'))]"
},
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('resourceName'))]"
],
"location": "[parameters('location')]",
"resources": [
{
"apiVersion": "2016-08-01",
"name": "Dynatrace",
"type": "siteextensions",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('resourceName'))]"
],
"properties": { }
}
]
}
Parameter | Requirement | Description |
---|---|---|
DT_TENANT | required | The environment ID as described in Prerequisites. |
DT_API_TOKEN | required | The PaaS token as described in Prerequisites. |
DT_API_URL | optional | The server URL, if you want to configure an alternative communication endpoint as described in Prerequisites. |
DT_SSL_MODE | optional | To automatically accept all self-signed TLS certificates, set the value to all . |
Note: If AlwaysOn
isn't set to true
, the installation of OneAgent is triggered on the start-up/first request to Kudu.
To check the deployment status, in your Dynatrace environment, go to Manage and select Deployment status.
After installation is complete, go to Azure Portal and restart the App Function application to recycle the application's worker process. Immediately after restart, OneAgent will begin monitoring your application.
Automate the installation and update of Dynatrace OneAgent site extension with Kudu REST API
After you install the Dynatrace OneAgent site extension, you can use the Kudu REST API to automate installation and update of the Dynatrace OneAgent site extension. See the automation setup page on GitHub for details.
The root URL to access the REST API is https://<Your-AppService-Subdomain>.scm.azurewebsites.net/dynatrace/
, where you need to replace <Your-AppService-Subdomain>
with your own value. To authenticate, you can use either the user publishing credentials or the site-level credentials. See Accessing the Kudu service for details.
Method | Endpoint | Description | Response |
---|---|---|---|
GET |
| Returns the current status of the OneAgent installation. The returned "state" field can be:
For automation, use isAgentInstalled and isUpgradeAvailable to determine whether OneAgent is installed and whether an upgrade is available. |
|
GET |
| Returns the current settings, including Dynatrace credentials. Note: The value for |
|
PUT |
| Starts OneAgent installation with the given settings. These settings are stored only if the installation finishes successfully. In the payload, you need to send the data in the format received by the If an update is available in the status request, this | Empty response |
Override OneAgent configuration
To override the default configuration, you can use the following parameters.
Parameter | Description |
---|---|
DT_CONNECTION_POINT | Semicolon-separated list of communication-endpoints |
Update OneAgent
Dynatrace doesn't provide OneAgent updates on Azure Functions automatically. To update OneAgent on Azure Functions, go to Azure Portal, browse to your site extension, and, if an update is available, select Update. You can monitor the progress until the update is finished.
Then restart Azure Functions to recycle the application worker process.
Note: The extension provides its own REST API for automating OneAgent updates. See REST API for details.
Update the site extension
To update the site extension on Azure App Service, go to the Azure Portal, browse to your site extension, and, if an update is available, select Update.
Note: An update to the site extension doesn't force an update to OneAgent.
When upgrading the extension from version 1.x to version 2.x, if you have Always On selected on your App Service, the upgrade of OneAgent is either triggered automatically or on the first request to the UI extension. If you don't have Always On selected, you must restart App Service, so that the extension process starts.
Uninstall OneAgent
Removing the extension also removes OneAgent.
If the application is running at the time of removal, the extension recognizes the running application, taking care to not remove any Dynatrace artifacts to prevent issues with the application. Instead, only the extension including the configuration is removed, so that, on the next restart of the application, OneAgent is no longer active.
Monitoring consumption
See Serverless monitoring for details on monitoring consumption for Azure Functions.