Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Budgets in Cost Management help you plan for and drive organizational accountability. With budgets, you can account for the Azure services you consume or subscribe to during a specific period. They help you inform others about their spending to proactively manage costs and monitor how spending progresses over time. When the budget thresholds you've created are exceeded, notifications are triggered. None of your resources are affected and your consumption isn't stopped. You can use budgets to compare and track spending as you analyze costs. This quickstart shows you how to create a budget named 'MyBudget' using Bicep.
Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.
If you don't have an Azure subscription, create a free account before you begin.
If you have a new subscription, you can't immediately create a budget or use other Cost Management features. It might take up to 48 hours before you can use all Cost Management features.
Budgets are supported for the following types of Azure account types and scopes:
To view budgets, you need at least read access for your Azure account.
For Azure EA subscriptions, you must have read access to view budgets. To create and manage budgets, you must have contributor permission.
The following Azure permissions, or scopes, are supported per subscription for budgets by user and group. For more information about scopes, see Understand and work with scopes.
For more information about assigning permission to Cost Management data, see Assign access to Cost Management data.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
targetScope = 'subscription'
@description('Name of the Budget. It should be unique within a resource group.')
param budgetName string = 'MyBudget'
@description('The total amount of cost or usage to track with the budget')
param amount int = 1000
@description('The time covered by a budget. Tracking of the amount will be reset based on the time grain.')
@allowed([
'Monthly'
'Quarterly'
'Annually'
])
param timeGrain string = 'Monthly'
@description('The start date must be first of the month in YYYY-MM-DD format. Future start date should not be more than three months. Past start date should be selected within the timegrain preiod.')
param startDate string
@description('The end date for the budget in YYYY-MM-DD format. If not provided, we default this to 10 years from the start date.')
param endDate string
@description('Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0.01 and 1000.')
param firstThreshold int = 90
@description('Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0.01 and 1000.')
param secondThreshold int = 110
@description('The list of email addresses to send the budget notification to when the threshold is exceeded.')
param contactEmails array
resource budget 'Microsoft.Consumption/budgets@2023-11-01' = {
name: budgetName
properties: {
timePeriod: {
startDate: startDate
endDate: endDate
}
timeGrain: timeGrain
amount: amount
category: 'Cost'
notifications: {
NotificationForExceededBudget1: {
enabled: true
operator: 'GreaterThan'
threshold: firstThreshold
contactEmails: contactEmails
}
NotificationForExceededBudget2: {
enabled: true
operator: 'GreaterThan'
threshold: secondThreshold
contactEmails: contactEmails
}
}
}
}
output name string = budget.name
output resourceId string = budget.id
One Azure resource is defined in the Bicep file:
Save the Bicep file as main.bicep to your local computer.
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
myContactEmails ='("user1@contoso.com", "user2@contoso.com")'
az deployment sub create --name demoSubDeployment --location centralus --template-file main.bicep --parameters startDate=<start-date> endDate=<end-date> contactEmails=$myContactEmails
You need to enter the following parameters:
Note
When the deployment finishes, you should see a message indicating the deployment succeeded.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
targetScope = 'subscription'
@description('Name of the Budget. It should be unique within a resource group.')
param budgetName string = 'MyBudget'
@description('The total amount of cost or usage to track with the budget')
param amount int = 1000
@description('The time covered by a budget. Tracking of the amount will be reset based on the time grain.')
@allowed([
'Monthly'
'Quarterly'
'Annually'
])
param timeGrain string = 'Monthly'
@description('The start date must be first of the month in YYYY-MM-DD format. Future start date should not be more than three months. Past start date should be selected within the timegrain preiod.')
param startDate string
@description('The end date for the budget in YYYY-MM-DD format. If not provided, we default this to 10 years from the start date.')
param endDate string
@description('Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0.01 and 1000.')
param firstThreshold int = 90
@description('Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0.01 and 1000.')
param secondThreshold int = 110
@description('The list of email addresses to send the budget notification to when the threshold is exceeded.')
param contactEmails array
@description('The set of values for the resource group filter.')
param resourceGroupFilterValues array
resource budget 'Microsoft.Consumption/budgets@2021-10-01' = {
name: budgetName
properties: {
timePeriod: {
startDate: startDate
endDate: endDate
}
timeGrain: timeGrain
amount: amount
category: 'Cost'
notifications: {
NotificationForExceededBudget1: {
enabled: true
operator: 'GreaterThan'
threshold: firstThreshold
contactEmails: contactEmails
}
NotificationForExceededBudget2: {
enabled: true
operator: 'GreaterThan'
threshold: secondThreshold
contactEmails: contactEmails
}
}
filter: {
dimensions: {
name: 'ResourceGroupName'
operator: 'In'
values: resourceGroupFilterValues
}
}
}
}
One Azure resource is defined in the Bicep file:
Save the Bicep file as main.bicep to your local computer.
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
myContactEmails ='("user1@contoso.com", "user2@contoso.com")'
myRgFilterValues ='("resource-group-01", "resource-group-02")'
az deployment sub create --name demoSubDeployment --location centralus --template-file main.bicep --parameters startDate=<start-date> endDate=<end-date> contactEmails=$myContactEmails resourceGroupFilterValues=$myRgFilterValues
You need to enter the following parameters:
Note
When the deployment finishes, you should see a message indicating the deployment succeeded.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
targetScope = 'subscription'
@description('Name of the Budget. It should be unique within a resource group.')
param budgetName string = 'MyBudget'
@description('The total amount of cost or usage to track with the budget')
param amount int = 1000
@description('The time covered by a budget. Tracking of the amount will be reset based on the time grain.')
@allowed([
'Monthly'
'Quarterly'
'Annually'
])
param timeGrain string = 'Monthly'
@description('The start date must be first of the month in YYYY-MM-DD format. Future start date should not be more than three months. Past start date should be selected within the timegrain preiod.')
param startDate string
@description('The end date for the budget in YYYY-MM-DD format. If not provided, we default this to 10 years from the start date.')
param endDate string
@description('Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0.01 and 1000.')
param firstThreshold int = 90
@description('Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0.01 and 1000.')
param secondThreshold int = 110
@description('The list of contact roles to send the budget notification to when the threshold is exceeded.')
param contactRoles array = [
'Owner'
'Contributor'
'Reader'
]
@description('The list of email addresses to send the budget notification to when the threshold is exceeded.')
param contactEmails array
@description('The list of action groups to send the budget notification to when the threshold is exceeded. It accepts array of strings.')
param contactGroups array
@description('The set of values for the resource group filter.')
param resourceGroupFilterValues array
@description('The set of values for the meter category filter.')
param meterCategoryFilterValues array
resource budget 'Microsoft.Consumption/budgets@2021-10-01' = {
name: budgetName
properties: {
timePeriod: {
startDate: startDate
endDate: endDate
}
timeGrain: timeGrain
amount: amount
category: 'Cost'
notifications: {
NotificationForExceededBudget1: {
enabled: true
operator: 'GreaterThan'
threshold: firstThreshold
contactEmails: contactEmails
contactRoles: contactRoles
contactGroups: contactGroups
}
NotificationForExceededBudget2: {
enabled: true
operator: 'GreaterThan'
threshold: secondThreshold
contactEmails: contactEmails
contactRoles: contactRoles
contactGroups: contactGroups
thresholdType: 'Forecasted'
}
}
filter: {
and: [
{
dimensions: {
name: 'ResourceGroupName'
operator: 'In'
values: resourceGroupFilterValues
}
}
{
dimensions: {
name: 'MeterCategory'
operator: 'In'
values: meterCategoryFilterValues
}
}
]
}
}
}
One Azure resource is defined in the Bicep file:
Save the Bicep file as main.bicep to your local computer.
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
myContactEmails ='("user1@contoso.com", "user2@contoso.com")'
myContactGroups ='("/subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/microsoft.insights/actionGroups/groupone", "/subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/microsoft.insights/actionGroups/grouptwo")'
myRgFilterValues ='("resource-group-01", "resource-group-02")'
myMeterCategoryFilterValues ='("meter-category-01", "meter-category-02")'
az deployment sub create --name demoSubDeployment --location centralus --template-file main.bicep --parameters startDate=<start-date> endDate=<end-date> contactEmails=$myContactEmails contactGroups=$myContactGroups resourceGroupFilterValues=$myRgFilterValues meterCategoryFilterValues=$myMeterCategoryFilterValues
You need to enter the following parameters:
Note
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 consumption budget list
When you no longer need the budget, use the Azure portal, Azure CLI, or Azure PowerShell to delete it:
az consumption budget delete --budget-name MyBudget
In this quickstart, you created a budget and deployed it using Bicep. To learn more about Cost Management and Billing and Bicep, continue on to the articles below.
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayTraining
Module
Introduction to analyzing costs and creating budgets with Microsoft Cost Management - Training
Learn how to use cost analysis to understand how your costs accrue each month.
Certification
Microsoft Certified: Azure Administrator Associate - Certifications
Demonstrate key skills to configure, manage, secure, and administer key professional functions in Microsoft Azure.