Share via


Continuous monitoring

Azure Pipelines integrates with Application Insights to provide continuous monitoring across your release pipeline. The pipeline evaluates alerts and gates promotions automatically. When alerts resolve, the pipeline promotes releases without manual action.

Configure a pipeline with continuous monitoring

  1. Open your organization and project in Azure DevOps.

  2. On the project page, navigate to Pipelines > Releases.

  3. Select the dropdown next to New, and then select New release pipeline. If no pipeline exists, select New pipeline.

  4. In Select a template, search for and select Azure App Service deployment with continuous monitoring, and then select Apply.

  5. In the Stage 1 box, select the hyperlink to View stage tasks.

  6. In the Stage 1 configuration pane, set the following values:

    Parameter Value
    Stage name Provide a stage name or keep Stage 1.
    Azure subscription Select the linked Azure subscription.
    App type Select your app type.
    App Service name Enter the name of the Azure App Service.
    Resource Group name for Application Insights Select the resource group for Application Insights.
    Application Insights resource name Select the Application Insights resource in the selected resource group.
  7. To save the pipeline with default alert rules, select Save. Enter a descriptive comment and then select OK.

Modify alert rules

The Azure App Service deployment with continuous monitoring template defines four alert rules by default: Availability, Failed requests, Server response time, and Server exceptions. You can add rules, change thresholds, or remove rules to match your service-level objectives.

The template creates rules by using an inline script similar to the following Azure CLI commands:

$subscription = az account show --query "id";$subscription.Trim("`"");$resource="/subscriptions/$subscription/resourcegroups/"+"$(Parameters.AppInsightsResourceGroupName)"+"/providers/microsoft.insights/components/" + "$(Parameters.ApplicationInsightsResourceName)";
az monitor metrics alert create -n 'Availability_$(Release.DefinitionName)' -g $(Parameters.AppInsightsResourceGroupName) --scopes $resource --condition 'avg availabilityResults/availabilityPercentage < 99' --description "created from Azure DevOps";
az monitor metrics alert create -n 'FailedRequests_$(Release.DefinitionName)' -g $(Parameters.AppInsightsResourceGroupName) --scopes $resource --condition 'count requests/failed > 5' --description "created from Azure DevOps";
az monitor metrics alert create -n 'ServerResponseTime_$(Release.DefinitionName)' -g $(Parameters.AppInsightsResourceGroupName) --scopes $resource --condition 'avg requests/duration > 5' --description "created from Azure DevOps";
az monitor metrics alert create -n 'ServerExceptions_$(Release.DefinitionName)' -g $(Parameters.AppInsightsResourceGroupName) --scopes $resource --condition 'count exceptions/server > 5' --description "created from Azure DevOps";

Add deployment gates

Use deployment gates to prevent promotion when alerts exceed thresholds. After you resolve the alert, the deployment proceeds automatically.

  1. On the pipeline page, under Stages, select the Pre-deployment conditions or Post-deployment conditions symbol for the stage that needs a gate.
  2. In Pre-deployment conditions, set Gates to Enabled.
  3. Next to Deployment gates, select Add.
  4. From the dropdown, select Query Azure Monitor alerts to evaluate Azure Monitor and Application Insights alerts.
  5. Under Evaluation options, enter values for settings such as The time between re-evaluation of gates and The timeout after which gates fail.

View release logs

Review gate evaluations and deployment steps in release logs.

  1. Open Releases in the left menu.
  2. Select a release.
  3. Under Stages, select a stage to open the release summary.
  4. To open logs, use View logs in the summary, select the Succeeded or Failed hyperlink in a stage, or hover over a stage and then select Logs.