Lesson 2 of 5 Monitoring a DevOps Environment

Integrating Azure Monitor with DevOps Tools

This lesson explains how operational signals connect with pipelines and work tracking.

Learning outcomes

After completing this lesson, you will be able to:

  • Gate a release on Azure Monitor alerts.
  • Query telemetry from a pipeline.
  • Create work items from alerts.
  • Stream audit events to Azure Monitor Logs.

Closing the DevOps loop

A DevOps process is a loop: plan, build, release, operate and learn. Azure Monitor sits at the operate stage, and integration connects it back to the rest. Signals from production should be able to stop a release, create a work item, or show that a deployment caused a change.

From monitoring into pipelines

Query Azure Monitor Alerts check

The Query Azure Monitor Alerts check, on an environment or other resource, evaluates alerts for a chosen subscription and resource group, along with filters on severity and state. It passes when no matching alerts are active. A check can be retried at intervals, which suits a post-deployment hold: if a release in test triggers alerts, promotion to the next stage stops.

Telemetry queries in a pipeline

A pipeline step can query telemetry directly to decide whether a release is healthy. The following step runs a KQL query with the Azure CLI, and fails if the failure rate is too high.

- task: AzureCLI@2
  displayName: Check the failure rate
  inputs:
    azureSubscription: sc-azure-prod
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      az extension add --name log-analytics --only-show-errors
      rate=$(az monitor log-analytics query \
        --workspace "$WORKSPACE_ID" \
        --analytics-query "AppRequests | where TimeGenerated > ago(10m) | summarize failed = 100.0 * countif(Success == false) / count()" \
        --query "[0].failed" -o tsv)
      echo "Failure rate: $rate"
      awk "BEGIN { exit !($rate < 2) }"

Release annotations

Annotations mark deployments on Application Insights charts, so that a change in behaviour can be matched with a release. A pipeline step can create one through the Azure CLI, using the Application Insights annotation API.

Scenario questions

Telemetry that gates a release

Exam skills 5.1.1

Choose how monitoring signals should affect a pipeline.

Log in to try this activity Interactive activities are free with an account.

From monitoring into work tracking

An alert can start a process, through an action group. The usual pattern is an action group that calls an Azure Function or logic app, which then creates a work item in Azure Boards through the REST API, or a GitHub issue. The Azure Logic Apps connectors for Azure DevOps and GitHub make this simple, with no code.

Duplicates need thought, since a flapping alert could create many work items. The function should search for an open item for that alert first, and add a comment instead. The action group's common alert schema gives a consistent payload for all alert types. Teams can then track production defects as planned work.

Put in order

From alert to work item

Exam skills 5.1.1

Arrange how a production alert becomes a tracked work item.

Log in to try this activity Interactive activities are free with an account.

From DevOps tools into Azure Monitor

Data also flows the other way, so delivery events can be analysed with operational data.

Audit streaming

Azure DevOps auditing records security-relevant actions, such as permission changes. Events are retained for 90 days, and audit streaming sends them to Azure Monitor Logs, Splunk or Azure Event Grid, for longer retention and correlation. Streams are set up in Organization settings, and auditing is available for organizations backed by Microsoft Entra ID.

GitHub audit log streaming

GitHub Enterprise Cloud can stream its audit log to destinations including Azure Event Hubs and Azure Blob Storage, and an event hub can feed Azure Monitor or Microsoft Sentinel.

Custom pipeline data

A pipeline can write custom events to a workspace through the Logs Ingestion API, or a service hook can send events to a function that stores them, so that a workbook can show deployments next to errors.

The following diagram follows Azure DevOps audit events to a Log Analytics workspace that keeps them for a year.

Keeping Azure DevOps permission changes for a year. Azure DevOps keeps audit events for 90 days; an audit stream to Azure Monitor Logs sends them to a Log Analytics workspace whose retention is at least one year, where they can be searched with KQL.
The scenario is illustrative.
True or false

Streaming delivery events

Exam skills 5.1.1

Check how DevOps tool events reach Azure Monitor.

Log in to try this activity Interactive activities are free with an account.

Viewing telemetry beside code

Azure Boards can receive work items from Application Insights directly: a failure or exception view offers a way to create a work item, once a work item template links the Application Insights resource to a project. The following table recaps the integrations.

GoalMechanism
Stop a release during an incidentQuery Azure Monitor Alerts check
Fail a pipeline on poor telemetryKQL query in a pipeline step
Show releases on chartsApplication Insights annotations
Create work items from alertsAction group with a logic app or function
Keep audit events for longerAudit streaming to Azure Monitor Logs
Worked example

Long-term audit

Compliance requires that Azure DevOps permission changes are retained for one year, and are searchable with KQL. What should you configure?

Create an audit stream to Azure Monitor Logs, with a Log Analytics workspace retention of at least one year. Azure DevOps retains audit events for only 90 days. Exporting audit logs by hand each month does not give KQL search without additional steps. Service hooks do not provide audit events.

Check yourself

How long does Azure DevOps keep audit events, and how can they be kept for longer?

Show answer

90 days. Audit streaming sends them to Azure Monitor Logs or another destination.

Exam Tips

Remember for the exam

  • The Query Azure Monitor Alerts check stops a release when alerts are active.
  • A pipeline can run KQL to verify a release.
  • Annotations show releases on Application Insights charts.
  • Action groups can start a logic app that creates a work item.
  • Audit streaming keeps Azure DevOps events beyond 90 days.