Skip to content

Instantly share code, notes, and snippets.

@clarenceb
Last active April 9, 2019 21:42
Show Gist options
  • Save clarenceb/0234748f6ebd6689688886895b270571 to your computer and use it in GitHub Desktop.
Save clarenceb/0234748f6ebd6689688886895b270571 to your computer and use it in GitHub Desktop.
Lab 6: Block releases when there are active alerts
Note: The Azure DevOps Pipelines release gates for Azure Monitor alerts appear to (currently) only support Classic Alerts.
# Guidance/Steps:
Pre-requisites (Lab 5) – app insights enable, server delay introduced
## Setup the alert
- From App Insights (prod), go to Configure / Alerts, then click “View classic alerts” from the top nav bar
- Click “Add metric alert (classic)”
- Enter name “slow-server”
- Select the prod App Insights instance
- Select metric “Server response time”, condition: Greater than, Threshold value: 10, Period: Over the last 5 mins
- Enter your email address for notificaitons
- Click OK
- Ensure the alert is in Active status
- Visit Azure Monitor (from left resource nav) and click Alerts then “View classic alerts”
- Reload the web app home page a few times until you see the “slow-server” alert appear in the list of alerts (classic alerts) and you’ll get a notification too
- Click the alert to see more info
## Add gate to prevent deployment on active alerts
- Edit your release pipeline
- Click Pre-Deployment Conditions icon for the Prod stage
- Enable “Gates”
- Set delay before evaluation for gates to 0 mins
- Add “Query Azure Monitor alerts” – Resource type ”Application Insights”, Resource name (choose the prod app insights instance), Alert rules: select “slow-server”
- Set the evaluation options for your alert gate to 5 mins
- Save changes
- Create a new release manually using the last build
- Verify the prod stage fails on the query azure monitor alerts gate and the deploy is blocked
- In Azure Monitor, disable the alert
- After the release gate re-evaluation period (< 5 mins), the deployment should be allowed to proceed (if not set alert threshold to much higher, e.g. 10 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment