成本管理中的預算可協助您進行規劃並促進組織責任歸屬。 透過預算,您可以考慮您在特定期間取用或訂閱的 Azure 服務。 它們可協助您通知其他人其費用的相關資訊以主動管理成本,並監視費用在經過一段時間的進展方式。 超過您建立的預算閾值時,會觸發通知。 您的資源都會不受到影響,而您的使用量並不會停止。 當您分析成本時,您可以使用預算來比較及追蹤費用。 本快速入門說明如何使用三個不同的 Azure Resource Manager 範本建立預算(ARM 範本)。
檢閱範本
本快速入門中使用的範本是來自 Azure 快速入門範本。
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "10216192224502761212"
}
},
"parameters": {
"budgetName": {
"type": "string",
"defaultValue": "MyBudget",
"metadata": {
"description": "Name of the Budget. It should be unique within a resource group."
}
},
"amount": {
"type": "int",
"defaultValue": 1000,
"metadata": {
"description": "The total amount of cost or usage to track with the budget"
}
},
"timeGrain": {
"type": "string",
"defaultValue": "Monthly",
"allowedValues": [
"Monthly",
"Quarterly",
"Annually"
],
"metadata": {
"description": "The time covered by a budget. Tracking of the amount will be reset based on the time grain."
}
},
"startDate": {
"type": "string",
"metadata": {
"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."
}
},
"endDate": {
"type": "string",
"metadata": {
"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."
}
},
"firstThreshold": {
"type": "int",
"defaultValue": 90,
"metadata": {
"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."
}
},
"secondThreshold": {
"type": "int",
"defaultValue": 110,
"metadata": {
"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."
}
},
"contactEmails": {
"type": "array",
"metadata": {
"description": "The list of email addresses to send the budget notification to when the threshold is exceeded."
}
}
},
"resources": [
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2023-11-01",
"name": "[parameters('budgetName')]",
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]"
},
"NotificationForExceededBudget2": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('secondThreshold')]",
"contactEmails": "[parameters('contactEmails')]"
}
}
}
}
],
"outputs": {
"name": {
"type": "string",
"value": "[parameters('budgetName')]"
},
"resourceId": {
"type": "string",
"value": "[subscriptionResourceId('Microsoft.Consumption/budgets', parameters('budgetName'))]"
}
}
}
此範本中已定義一項 Azure 資源:
部署範本
選取以下影像來登入 Azure 並開啟範本。 範本會建立預算,而沒有任何篩選條件。
選取或輸入下列值。
- 訂用帳戶:選取 Azure 訂用帳戶。
- 資源群組:如有需要,請選取現有的資源群組,或 [新建]。
- 區域:選取 Azure 區域。 例如,美國中部。
- 預算名稱:輸入預算的名稱。 資源群組內應該是唯一的。 只允許英數位元、底線和連字元字元。
- 金額:輸入與預算一起追蹤的成本總計。
- 時間粒紋:輸入預算涵蓋的時間。 允許的值為每月、每季或每年。 預算會在時間粒紋結束時重設。
- 開始日期:以YYYY-MM-DD格式輸入月份第一天的開始日期。 從今天起,未來的開始日期不應該超過三個月。 您可以使用時間粒紋期間來指定過去的開始日期。
- 結束日期:以YYYY-MM-DD格式輸入預算的結束日期。
- 第一個閾值:輸入第一個通知的臨界值。 當成本超過閾值時,就會傳送通知。 一律為百分比,且必須介於 0.01 到 1000 之間。
- 第二個臨界值:輸入第二個通知的臨界值。 當成本超過閾值時,就會傳送通知。 一律為百分比,且必須介於 0.01 到 1000 之間。
- 聯繫人電子郵件 輸入電子郵件地址清單,以在超過閾值時傳送預算通知。 它會接受字串陣列。 預期的格式為
["user1@domain.com","user2@domain.com"]
。
根據您的 Azure 訂用帳戶類型,執行下列其中一個動作:
- 選取 [檢閱 + 建立]。
- 檢閱條款及條件,選取 [ 我同意上述條款及條件],然後選取 [ 購買]。
如果您選取 [ 檢閱 + 建立],則會驗證您的範本。 選取 建立。
Azure 入口網站用於部署範本。 除了 Azure 入口網站,您也可以使用 Azure PowerShell、Azure CLI 和 REST API。 若要瞭解其他部署範本,請參閱 部署範本。
檢閱範本
本快速入門中使用的範本是來自 Azure 快速入門範本。
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.5.6.12127",
"templateHash": "16839077498193926768"
}
},
"parameters": {
"budgetName": {
"type": "string",
"defaultValue": "MyBudget",
"metadata": {
"description": "Name of the Budget. It should be unique within a resource group."
}
},
"amount": {
"type": "int",
"defaultValue": 1000,
"metadata": {
"description": "The total amount of cost or usage to track with the budget"
}
},
"timeGrain": {
"type": "string",
"defaultValue": "Monthly",
"allowedValues": [
"Monthly",
"Quarterly",
"Annually"
],
"metadata": {
"description": "The time covered by a budget. Tracking of the amount will be reset based on the time grain."
}
},
"startDate": {
"type": "string",
"metadata": {
"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."
}
},
"endDate": {
"type": "string",
"metadata": {
"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."
}
},
"firstThreshold": {
"type": "int",
"defaultValue": 90,
"metadata": {
"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."
}
},
"secondThreshold": {
"type": "int",
"defaultValue": 110,
"metadata": {
"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."
}
},
"contactEmails": {
"type": "array",
"metadata": {
"description": "The list of email addresses to send the budget notification to when the threshold is exceeded."
}
},
"resourceGroupFilterValues": {
"type": "array",
"metadata": {
"description": "The set of values for the resource group filter."
}
}
},
"resources": [
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2021-10-01",
"name": "[parameters('budgetName')]",
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]"
},
"NotificationForExceededBudget2": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('secondThreshold')]",
"contactEmails": "[parameters('contactEmails')]"
}
},
"filter": {
"dimensions": {
"name": "ResourceGroupName",
"operator": "In",
"values": "[parameters('resourceGroupFilterValues')]"
}
}
}
}
]
}
此範本中已定義一項 Azure 資源:
部署範本
選取以下影像來登入 Azure 並開啟範本。 此範本會使用資源群組的篩選條件來建立預算。
選取或輸入下列值。
- 訂用帳戶:選取 Azure 訂用帳戶。
- 資源群組:如有需要,請選取現有的資源群組,或 [新建]。
- 區域:選取 Azure 區域。 例如,美國中部。
- 預算名稱:輸入預算的名稱。 資源群組內應該是唯一的。 只允許英數位元、底線和連字元字元。
- 金額:輸入與預算一起追蹤的成本總計。
- 時間粒紋:輸入預算涵蓋的時間。 允許的值為每月、每季或每年。 預算會在時間粒紋結束時重設。
- 開始日期:以YYYY-MM-DD格式輸入月份第一天的開始日期。 從今天起,未來的開始日期不應該超過三個月。 您可以使用時間粒紋期間來指定過去的開始日期。
- 結束日期:以YYYY-MM-DD格式輸入預算的結束日期。
- 第一個閾值:輸入第一個通知的臨界值。 當成本超過閾值時,就會傳送通知。 一律為百分比,且必須介於 0.01 到 1000 之間。
- 第二個臨界值:輸入第二個通知的臨界值。 當成本超過閾值時,就會傳送通知。 一律為百分比,且必須介於 0.01 到 1000 之間。
- 聯繫人電子郵件 輸入電子郵件地址清單,以在超過閾值時傳送預算通知。 它會接受字串陣列。 預期的格式為
["user1@domain.com","user2@domain.com"]
。
- 資源群組篩選值 輸入要篩選的資源組名清單。 它會接受字串陣列。 預期的格式為
["Resource Group Name1","Resource Group Name2"]
。 陣列不能是空的。
根據您的 Azure 訂用帳戶類型,執行下列其中一個動作:
- 選取 [檢閱 + 建立]。
- 檢閱條款及條件,選取 [ 我同意上述條款及條件],然後選取 [ 購買]。
如果您選取 [ 檢閱 + 建立],則會驗證您的範本。 選取 建立。
Azure 入口網站用於部署範本。 除了 Azure 入口網站,您也可以使用 Azure PowerShell、Azure CLI 和 REST API。 若要瞭解其他部署範本,請參閱 部署範本。
檢閱範本
本快速入門中使用的範本是來自 Azure 快速入門範本。
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.8.9.13224",
"templateHash": "16562188350105885076"
}
},
"parameters": {
"budgetName": {
"type": "string",
"defaultValue": "MyBudget",
"metadata": {
"description": "Name of the Budget. It should be unique within a resource group."
}
},
"amount": {
"type": "int",
"defaultValue": 1000,
"metadata": {
"description": "The total amount of cost or usage to track with the budget"
}
},
"timeGrain": {
"type": "string",
"defaultValue": "Monthly",
"allowedValues": [
"Monthly",
"Quarterly",
"Annually"
],
"metadata": {
"description": "The time covered by a budget. Tracking of the amount will be reset based on the time grain."
}
},
"startDate": {
"type": "string",
"metadata": {
"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."
}
},
"endDate": {
"type": "string",
"metadata": {
"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."
}
},
"firstThreshold": {
"type": "int",
"defaultValue": 90,
"metadata": {
"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."
}
},
"secondThreshold": {
"type": "int",
"defaultValue": 110,
"metadata": {
"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."
}
},
"contactRoles": {
"type": "array",
"defaultValue": [
"Owner",
"Contributor",
"Reader"
],
"metadata": {
"description": "The list of contact roles to send the budget notification to when the threshold is exceeded."
}
},
"contactEmails": {
"type": "array",
"metadata": {
"description": "The list of email addresses to send the budget notification to when the threshold is exceeded."
}
},
"contactGroups": {
"type": "array",
"metadata": {
"description": "The list of action groups to send the budget notification to when the threshold is exceeded. It accepts array of strings."
}
},
"resourceGroupFilterValues": {
"type": "array",
"metadata": {
"description": "The set of values for the resource group filter."
}
},
"meterCategoryFilterValues": {
"type": "array",
"metadata": {
"description": "The set of values for the meter category filter."
}
}
},
"resources": [
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2021-10-01",
"name": "[parameters('budgetName')]",
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"contactGroups": "[parameters('contactGroups')]"
},
"NotificationForExceededBudget2": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('secondThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"contactGroups": "[parameters('contactGroups')]",
"thresholdType": "Forecasted"
}
},
"filter": {
"and": [
{
"dimensions": {
"name": "ResourceGroupName",
"operator": "In",
"values": "[parameters('resourceGroupFilterValues')]"
}
},
{
"dimensions": {
"name": "MeterCategory",
"operator": "In",
"values": "[parameters('meterCategoryFilterValues')]"
}
}
]
}
}
}
]
}
此範本中已定義一項 Azure 資源:
部署範本
選取以下影像來登入 Azure 並開啟範本。 此範本會建立預算,其中包含資源群組的篩選條件,以及計量類別的篩選。
選取或輸入下列值。
- 訂用帳戶:選取 Azure 訂用帳戶。
- 資源群組:如有需要,請選取現有的資源群組,或 [新建]。
- 區域:選取 Azure 區域。 例如,美國中部。
- 預算名稱:輸入預算的名稱。 資源群組內應該是唯一的。 只允許英數位元、底線和連字元字元。
- 金額:輸入與預算一起追蹤的成本總計。
- 時間粒紋:輸入預算涵蓋的時間。 允許的值為每月、每季或每年。 預算會在時間粒紋結束時重設。
- 開始日期:以YYYY-MM-DD格式輸入月份第一天的開始日期。 從今天起,未來的開始日期不應該超過三個月。 您可以使用時間粒紋期間來指定過去的開始日期。
- 結束日期:以YYYY-MM-DD格式輸入預算的結束日期。
- 第一個閾值:輸入第一個通知的臨界值。 當成本超過閾值時,就會傳送通知。 一律為百分比,且必須介於 0.01 到 1000 之間。
- 第二個臨界值:輸入第二個通知的臨界值。 當成本超過閾值時,就會傳送通知。 一律為百分比,且必須介於 0.01 到 1000 之間。
- 聯繫人角色 輸入聯繫人角色清單,以在超過閾值時傳送預算通知。 預設值為擁有者、參與者和讀者。 預期的格式為
["Owner","Contributor","Reader"]
。
- 聯繫人電子郵件 輸入電子郵件地址清單,以在超過閾值時傳送預算通知。 它會接受字串陣列。 預期的格式為
["user1@domain.com","user2@domain.com"]
。
- 聯繫人群組 會輸入動作群組資源標識符清單,作為完整的資源 URI,以在超過閾值時傳送預算通知。 它會接受字串陣列。 預期的格式為
["action group resource ID1","action group resource ID2"]
。 如果不想使用動作群組,請輸入 []
。
- 資源群組篩選值 輸入要篩選的資源組名清單。 它會接受字串陣列。 預期的格式為
["Resource Group Name1","Resource Group Name2"]
。 陣列不能是空的。
- 計量類別篩選值 輸入 Azure 服務計量類別清單。 它會接受字串陣列。 預期的格式為
["Meter Category1","Meter Category2"]
。 陣列不能是空的。
根據您的 Azure 訂用帳戶類型,執行下列其中一個動作:
- 選取 [檢閱 + 建立]。
- 檢閱條款及條件,選取 [ 我同意上述條款及條件],然後選取 [ 購買]。
如果您選取 [ 檢閱 + 建立],則會驗證您的範本。 選取 建立。
Azure 入口網站用於部署範本。 除了 Azure 入口網站,您也可以使用 Azure PowerShell、Azure CLI 和 REST API。 若要瞭解其他部署範本,請參閱 部署範本。