Bicep Module for an Anomaly Alert

In our CAF Landing Zone Starter Kit, the implementation of the Anomaly Alert on the subscription was missing until now. This is almost complete. Here is a possible implementation of the Anomaly Alert as a Bicep module. Anomaly Alert Bicep targetScope = 'subscription' @description('Name of the Anomaly Alert') param aaName string = 'myAnomalyAlert' @description('Display Name of the Anomaly Alert') param aaDisplayName string = 'Anomaly Alert' @description('Subject of the Anomaly Alert email notification') param aaNotificationSubject string = 'Anomaly Alert detected for your Subscription' @description('Email address to send the Anomaly Alert notification to') param aaNotificationTo string @description('Message of the Anomaly Alert email notification') param aaNotificationMessage string = 'The Anomaly Alert has been triggered for your Subscription ${subscription().subscriptionId}. Please check the Cost Management Dashboard for more details.' @description('Start date of the Anomaly Alert (default: now)') param aaStartDate string = utcNow('u') @description('End date of the Anomaly Alert (default: 1 year from now)') param aaEndDate string = dateTimeAdd(utcNow('u'), 'P1Y') // The kind of the Anomaly Alert must be 'InsightAlert' var aaKind = 'InsightAlert' resource myAnomalyAlert 'Microsoft.CostManagement/scheduledActions@2022-10-01' = { name: aaName kind: aaKind properties: { displayName: aaDisplayName scope: '/subscriptions/${subscription().subscriptionId}' notification: { subject: aaNotificationSubject to: [ aaNotificationTo ] message: aaNotificationMessage } status: 'Enabled' viewId: resourceId('Microsoft.CostManagement/views/','ms:DailyAnomalyByResourceGroup') schedule: { endDate: aaEndDate frequency: 'Daily' startDate: aaStartDate } } } Deploying the Module The module can be applied using the Azure CLI. The important thing is to verify that you are in the correct subscription first. Then the deployment is straightforward: ...

05.05.2023 · 2 min · Niels Ophey

Azure - New Project Bicep

What is Bicep? Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. So, get out of ARM Templates and use a more declarative way to describe what you want to deploy to Azure. You can read more about the project on the GitHub page. My first step was to deploy the tooling for Bicep and the extension for Visual Studio Code. You find the installing instruction also in the GitHub project site. As soon as you have installed everything your VS Code will have support for *.bicep files: ...

11.09.2020 · 2 min · Niels Ophey