title | description | author | ms.topic | ms.author | ms.custom | ms.date |
---|---|---|---|---|---|---|
Create Azure Advisor alerts for new recommendations using Bicep |
Learn how to set up an alert for new recommendations from Azure Advisor using Bicep. |
schaffererin |
quickstart |
v-eschaffer |
subject-armqs, devx-track-azurepowershell, mode-arm |
04/26/2022 |
This article shows you how to set up an alert for new recommendations from Azure Advisor using Bicep.
[!INCLUDE About Bicep]
Whenever Azure Advisor detects a new recommendation for one of your resources, an event is stored in Azure Activity log. You can set up alerts for these events from Azure Advisor using a recommendation-specific alerts creation experience. You can select a subscription and optionally select a resource group to specify the resources that you want to receive alerts on.
You can also determine the types of recommendations by using these properties:
- Category
- Impact level
- Recommendation type
You can also configure the action that will take place when an alert is triggered by:
- Selecting an existing action group
- Creating a new action group
To learn more about action groups, see Create and manage action groups.
Note
Advisor alerts are currently only available for High Availability, Performance, and Cost recommendations. Security recommendations are not supported.
- If you don't have an Azure subscription, create a free account before you begin.
- To run the commands from your local computer, install Azure CLI or the Azure PowerShell modules. For more information, see Install the Azure CLI and Install Azure PowerShell.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.insights/insights-alertrules-servicehealth/main.bicep":::
The Bicep file defines two resources:
-
Save the Bicep file as main.bicep to your local computer.
-
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
az group create --name exampleRG --location eastus az deployment group create --resource-group exampleRG --template-file main.bicep --parameters alertName=<alert-name>
New-AzResourceGroup -Name exampleRG -Location eastus New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -alertName "<alert-name>"
[!NOTE] Replace <alert-name> with the name of the alert.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.
az resource list --resource-group exampleRG
Get-AzResource -ResourceGroupName exampleRG
When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group.
az group delete --name exampleRG
Remove-AzResourceGroup -Name exampleRG
- Get an overview of activity log alerts, and learn how to receive alerts.
- Learn more about action groups.