Cost Management scheduled action bicep modules
This article describes the Cost Management scheduled actions Bicep Registry modules that help you send an email on a schedule or when an anomaly is detected.
Scheduled actions allow you to configure email alerts on a daily, weekly, or monthly basis. Scheduled actions are configured based on a Cost Management view, which can be opened and edited in Cost analysis in the Azure portal. Email alerts include a picture of the selected view and optionally a link to a CSV file with the summarized cost data. You can also use scheduled actions to configure anomaly detection alerts for subscriptions.
To learn about scheduled alerts, see Save and share views. To learn about anomaly alerts, see Analyze unexpected charges.
Syntax
Version: 1.1 Scopes: Subscription, Resource group
module <string> 'br/public:cost/<scope>-scheduled-action:1.1' = {
name: <string>
params: {
name: <string>
kind: 'Email' | 'InsightAlert'
private: <bool>
builtInView: 'AccumulatedCosts' | 'CostByService' | 'DailyCosts'
viewId: <string>
displayName: <string>
status: 'Enabled' | 'Disabled'
notificationEmail: <string>
emailRecipients: [ <string>, <string>, ... ]
emailSubject: <string>
emailMessage: <string>
emailLanguage: <string>
emailRegionalFormat: <string>
includeCsv: <bool>
scheduleFrequency: 'Daily' | 'Weekly' | 'Monthly'
scheduleDaysOfWeek: [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]
scheduleDayOfMonth: <int>
scheduleWeeksOfMonth: [ 'First', 'Second', 'Third', 'Fourth', 'Last' ]
scheduleStartDate: 'yyyy-MM-ddTHH:miZ'
scheduleEndDate: 'yyyy-MM-dd'
}
}
Parameters
Here are the parameters for the scheduled action modules:
Name | Type | Description |
---|---|---|
name |
string |
Required. Name of the scheduled action used in the resource ID. |
kind |
string |
Optional. Indicates the kind of scheduled action. Default: Email. |
private |
bool |
Optional. Indicates whether the scheduled action is private and only editable by the current user. If false, the scheduled action is shared with other users in the same scope. Ignored if kind is InsightAlert . Default: false. |
builtInView |
string |
Optional. Specifies which built-in view to use. It's a shortcut for the full view ID. |
viewId |
string |
Optional. Required if kind is Email and builtInView isn't set. The resource ID of the view to which the scheduled action sends. The view must either be private (tenant level) or owned by the same scope as the scheduled action. Ignored if kind is InsightAlert or if builtInView is set. |
displayName |
string |
Optional. The display name to show in the portal when viewing the list of scheduled actions. Default: (scheduled action name). |
status |
string |
Optional. The status of the scheduled action. Default: Enabled. |
notificationEmail |
string |
Required. Email address of the person or team responsible for this scheduled action. This email address is included in emails. Default: (email address of user deploying the template). |
emailRecipients |
array |
Required. List of email addresses that should receive emails. At least one valid email address is required. |
emailSubject |
string |
Optional. The subject of the email that gets sent to the email recipients. Default: (view name). |
emailMessage |
string |
Optional. Include a message for recipients to add context about why they're getting the email, what to do, and/or who to contact. Default: "" (no message). |
emailLanguage |
string |
Optional. The language that is used for the email template. Default: en. |
emailRegionalFormat |
string |
Optional. The regional format that is used for dates, times, and numbers. Default: en-us. |
includeCsv |
bool |
Optional. Indicates whether to include a link to a CSV file with the backing data for the chart. Ignored if kind is InsightAlert . Default: false. |
scheduleFrequency |
string |
Optional. The frequency that the scheduled action runs. Default: Daily for Email and Weekly for InsightAlert . |
scheduleDaysOfWeek |
array |
Optional. Required if kind is Email and scheduleFrequency is Weekly . List of days of the week that emails should be delivered. Allowed: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. Default: Monday. |
scheduleDayOfMonth |
int |
Optional. Required if kind is Email and scheduleFrequency is Monthly . The day of the month that emails should be delivered. Monthly cost isn't final until the third day of the month. This value or scheduleWeeksOfMonth is required if scheduleFrequency is Monthly . Default: 0 (not set). |
scheduleWeeksOfMonth |
array |
Optional. List of weeks of the month that emails should be delivered. This value or scheduleDayOfMonth is required if scheduleFrequency is Monthly . Allowed: First, Second, Third, Fourth, Last. Default [] (not set). |
scheduleStartDate |
string |
Optional. The first day the schedule should run. Use the time to indicate when you want to receive emails. Must be in the format yyyy-MM-ddTHH:miZ. Default = Now. |
scheduleEndDate |
string |
Optional. The last day the schedule should run. Must be in the format yyyy-MM-dd. Default = 1 year from start date. |
Examples
The following examples help you send an email on a schedule or when an anomaly is detected.
Schedule an email for a built-in view
Subscription Resource group
Creates a shared scheduled action for the DailyCosts built-in view.
module dailyCostsAlert 'br/public:cost/subscription-scheduled-action:1.0.2' = {
name: 'dailyCostsAlert'
params: {
name: 'DailyCostsAlert'
displayName: 'My schedule'
builtInView: 'DailyCosts'
emailRecipients: [ 'ema@contoso.com' ]
notificationEmail: 'ema@contoso.com'
scheduleFrequency: 'Weekly'
scheduleDaysOfWeek: [ 'Monday' ]
}
}
Schedule an email with a custom start date
Subscription Resource group
Creates a private scheduled action for the DailyCosts built-in view with custom start/end dates.
module privateAlert 'br/public:cost/resourcegroup-scheduled-action:1.0.2' = {
name: 'privateAlert'
params: {
name: 'PrivateAlert'
displayName: 'My private schedule'
private: true
builtInView: 'DailyCosts'
emailRecipients: [ 'priya@contoso.com' ]
notificationEmail: 'priya@contoso.com'
scheduleFrequency: 'Monthly'
scheduleDayOfMonth: 1
scheduleStartDate: scheduleStartDate
scheduleEndDate: scheduleEndDate
}
}
Configure an anomaly alert
Subscription
Creates an anomaly alert for a subscription.
module anomalyAlert 'br/public:cost/subscription-scheduled-action:1.0.2' = {
name: 'anomalyAlert'
params: {
name: 'AnomalyAlert'
kind: 'InsightAlert'
displayName: 'My anomaly check'
emailRecipients: [ 'ana@contoso.com' ]
notificationEmail: 'ana@contoso.com'
}
}
Related content
Related resources:
- Bicep Registry: Scheduled actions for subscriptions
- Bicep Registry: Scheduled actions for resource groups
- ScheduledActions API reference
Related FinOps capabilities:
Related products:
Related solutions: