Microsoft Azure Deployment Manager

Overview

Azure Deployment Manager (ADM) allows you to manage a staged roll-out for safely deploying complex applications.

Use Datadog to create a health check for the Azure Deployment Manager, and to stop your deployment if issues are detected.

Setup

Installation

To use Datadog as a health check for ADM, you need an active Datadog account and an active instance of Azure Deployment Manager.

Configuration

  1. Start by setting up monitors in Datadog for your deployment. Start with a monitor for each region. Depending on the complexity of your application, you may want to have monitors for different parts of the deployment in each region. Completing the Tutorial: Use Azure Deployment Manager with Resource Manager templates may help you decide where to monitor. For monitor ideas, check out the blog.
  2. If you end up with multiple monitors for each region, create a composite monitor for each rollout step or region. Each composite monitor is a logical combination of other monitors that together indicate the overall status of a deployment step.
  3. Next, configure Datadog as a health check within the Azure Deployment Manager topology as a part of the rollout. Set these health check steps as dependencies between the deployment steps. Use the template, and replace <API_KEY> and <APP_KEY> with your Datadog API and application keys. Create a section in resources for each monitor (or composite monitor) you just created and replace <MONITOR_ID> with the monitor IDs. It is possible to add multiple checks within a health check step, but Datadog recommends you create one check per health check step, and then create additional health check steps for each composite monitor. If you are setting the check with something besides a composite monitor, be sure to update the regex accordingly.
  4. Follow the Microsoft documentation to initiate the deployment.

Example health check

The following is the part of the Azure Deployment Manager rollout template that is considered the health check.

{
    "healthChecks": [
        {
            "name": "datadogCompositeMonitor1",
            "request": {
                "method": "GET",
                "uri": "https://api.datadoghq.com/api/v1/monitor/<MONITOR_ID>?application_key=<APP_KEY>",
                "authentication": {
                    "type": "ApiKey",
                    "name": "apikey",
                    "in": "Query",
                    "value": "<API_KEY>"
                }
            },
            "response": {
                "successStatusCodes": ["200"],
                "regex": {
                    "matches": ["\"overall_state\"\\s*:\\s*\"OK\""],
                    "matchQuantifier": "All"
                }
            }
        }
    ]
}

Example health check step

The following is the part of the Azure Deployment Manager rollout template that is considered the health check step.

{
    "apiVersion": "2018-09-01-preview",
    "type": "Microsoft.DeploymentManager/steps",
    "name": "datadogHealthCheckStep1",
    "location": "Central US",
    "tags": {},
    "properties": {
        "stepType": "healthCheck",
        "attributes": {
            "waitDuration": "PT5M",
            "maxElasticDuration": "PT10M",
            "healthyStateDuration": "PT10M",
            "type": "REST",
            "properties": {
                "healthChecks": [
                    {
                        "name": "datadogCompositeMonitor1",
                        "request": {
                            "method": "GET",
                            "uri": "https://api.datadoghq.com/api/v1/monitor/<MONITOR_ID>?application_key=<APP_KEY>",
                            "authentication": {
                                "type": "ApiKey",
                                "name": "apikey",
                                "in": "Query",
                                "value": "<API_KEY>"
                            }
                        },
                        "response": {
                            "successStatusCodes": ["200"],
                            "regex": {
                                "matches": ["\"overall_state\"\\s*:\\s*\"OK\""],
                                "matchQuantifier": "All"
                            }
                        }
                    }
                ]
            }
        }
    }
}

Full configuration example

The following is a full template for an Azure Deployment Manager rollout step.

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": [
        {
            "apiVersion": "2018-09-01-preview",
            "type": "Microsoft.DeploymentManager/steps",
            "name": "datadogHealthCheckStep1",
            "location": "Central US",
            "tags": {},
            "properties": {
                "stepType": "healthCheck",
                "attributes": {
                    "waitDuration": "PT5M",
                    "maxElasticDuration": "PT10M",
                    "healthyStateDuration": "PT10M",
                    "type": "REST",
                    "properties": {
                        "healthChecks": [
                            {
                                "name": "datadogCompositeMonitor1",
                                "request": {
                                    "method": "GET",
                                    "uri": "https://api.datadoghq.com/api/v1/monitor/<MONITOR_ID>?application_key=<APP_KEY>",
                                    "authentication": {
                                        "type": "ApiKey",
                                        "name": "apikey",
                                        "in": "Query",
                                        "value": "<API_KEY>"
                                    }
                                },
                                "response": {
                                    "successStatusCodes": ["200"],
                                    "regex": {
                                        "matches": [
                                            "\"overall_state\"\\s*:\\s*\"OK\""
                                        ],
                                        "matchQuantifier": "All"
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        }
    ]
}

Results

When performing the health check step for a phase of the rollout, Azure Deployment Manager queries the Datadog Monitor API for the status of the composite monitor identified in the health check step for that phase of the deployment.

Azure Deployment Manager parses the response using the regex provided in the template to identify if it contains the phrase overall_status: OK.

If overall_status: OK is found, the check is considered healthy. If the status is Warn, No Data, or Alert, then the check is considered unhealthy, and Azure Deployment Manager stops the deployment.

Data Collected

Metrics

The Azure Deployment Manager does not report any metrics.

Events

The Azure Deployment Manager does not include any events.

Service Checks

The Azure Deployment Manager does not include any service checks.

Troubleshooting

Need help? Contact Datadog support.

PREVIEWING: rtrieu/product-analytics-ui-changes