01 logo

Install Dynatrace Extension On Azure Function & App Service using Terraform

azapi_resource

By tarun bhattPublished 6 months ago 4 min read
Like
Made using draw.io

Terraform is a programming language to provision cloud infrastructure (Infrastructure as Code). IaC is all about deploying infrastructure through software. It helps achieve consistent and predictable environments.

The most significant advantage of Terraform is the concept of state files. The state file allows Terraform to deploy the differential. In this way, the provisioning of resources is faster than using other IaC toolsets like ARM or Az Cli.

Dynatrace is a monitoring tool. It provides an in-depth analysis and reporting of the health of enterprise systems.

In this article, I will show how to install the Dynatrace extension via Terraform. Dynatrace is a monitoring tool. It provides an in-depth analysis and reporting of the health of enterprise systems. To enable the monitoring of Azure functions & Azure app service, we can install the Dynatrace extension.

Dynatrace extension on Azure function

We can install the extension from the Azure portal as well. View the link below for detailed steps.

Monitor Azure Functions on App Service Plan for Windows - Dynatrace Docs

Please note that the below solution will work only for Azure function on Windows.

Step 1 – Create an Azure Resource Group

Code snippet to create a resource group

Code snippet using snappify

Step 2 – Create a Storage account

Azure function needs a storage account. It's used for triggers, bindings, and states but there are other usages as well. In case you need detailed information on why Azure function needs a storage account. Read Storage considerations for Azure Functions | Microsoft Learn

Code snippet using snappify

Step 3 – Create an App Service Plan(ASP)

An Azure service plan provides the compute for the Azure function.

Code snippet to create an app service plan.

Code snippet using snappify

Step 4 – Create an Azure function

The next step is to create an azure function

Code snippet using snappify

We can see a couple of configurations. These are Dynatrace environment-specific configurations to send monitoring information to the Dynatrace server. The configurations are:

  • "DT_API_TOKEN"    - PaaS token
  • "DT_TENANT"    - Environment ID          

Step 6 – Install DT extension

The last step is to install the DT extension using azapi_resource. azapi_resource does not come as part of azurerm provider. It comes as part of azapi provider. Hence our provider block will look like the below:

Code snippet using snappify

The resource block to install the Dynatrace extension is below:

Code snippet using snappify

The AzAPI provider is a very thin layer on top of the Azure ARM REST APIs. It complements the AzureRM provider for Azure resources that are not yet supported. If you want to read more on this. See link below:

Docs overview | Azure/azapi | Terraform | Terraform Registry

Final Code

The final code will look like

Code snippet using snappify

Dynatrace extension on Azure App Service

In this section, I will cover installation for an Azure App service. We can install the extension from the Azure portal as well. View the link below for detailed steps.

Monitor Azure App Service on App Service Plan for Windows - Dynatrace Docs

Please note that the below solution will work only for Azure app service on Windows.

Step 1 — Create an Azure Resource Group

Code snippet to create a resource group

Code snippet using snappify

Step 2 — Create an app service plan(ASP)

An Azure service plan provides the compute for the Azure app service.

Use the code snippet below to create an app service plan.

Code snippet using snappify

Step 3— Create an Azure app service

The next step is to create an app service.

Code snippet using snappify

We can see a couple of configurations. These are Dynatrace environment-specific configurations to send monitoring information to the Dynatrace server. The configurations are:

  • DT_API_TOKEN — PaaS token
  • DT_TENANT— Environment ID

Step 4— Install DT extension

The last step is to install the DT extension using azapi_resource. azapi_resource does not come as part of azurerm provider. It comes as part of azapi provider. Hence our provider block will look like the below:

Code snippet using snappify

The resource block to install the Dynatrace extension is below:

Code snippet using snappify

The AzAPI provider is a very thin layer on top of the Azure ARM REST APIs. It complements the AzureRM provider for Azure resources that are not yet supported. If you want to read more on this. See link below

AzAPI Provider

Final Code

The final code will look like:

Code snippet using snappify

Let me know if there are any questions.

Regards Tarun

how tolistinterview
Like

About the Creator

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.