Created
November 11, 2019 10:50
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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