Skip to content

Instantly share code, notes, and snippets.

@andrewmatveychuk
Created November 11, 2019 10:50
Show Gist options
  • Select an option

  • Save andrewmatveychuk/2ffe3bd1a7d168cdb611128f3bfbb6fc to your computer and use it in GitHub Desktop.

Select an option

Save andrewmatveychuk/2ffe3bd1a7d168cdb611128f3bfbb6fc to your computer and use it in GitHub Desktop.
Sample snippet for an Azure DevOps release pipeline to enable Application Insights web tests
steps:
- task: AzurePowerShell@4
displayName: 'Enable Application Insights web avaliability tests'
inputs:
azureSubscription: <your_service_connection> # Your service connection, i.g., a subscription or resource group name
ScriptType: InlineScript
Inline: |
# Define the resource group as a variable in your library and reference it as an environment variable
$alertResourceIds = Get-AzResource -ResourceGroupName $env:resourceGroupName | Where-Object -Property ResourceType -EQ "microsoft.insights/webtests" | Select-Object -ExpandProperty ResourceId
ForEach ($Id in $alertResourceIds) {
$alerts = Get-AzResource -ResourceId $Id
$alerts.Properties.Enabled = "True"
$alerts | Set-AzResource -Force
}
azurePowerShellVersion: LatestVersion
pwsh: true
condition: always()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment