Budgets - Create Or Update
用于创建或更新预算的作。 如果需要,可以选择提供 eTag 作为并发控制的形式。 若要获取给定预算的最新 eTag,请在放置作之前执行 get作。
PUT https://management.azure.com/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}?api-version=2024-08-01
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
budget
|
path | True |
string |
预算名称。 |
|
scope
|
path | True |
string |
资源的完全限定的 Azure 资源管理器标识符。 |
|
api-version
|
query | True |
string minLength: 1 |
要用于此操作的 API 版本。 |
请求正文
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| properties.amount | True |
number (decimal) |
用于跟踪预算的总成本 |
| properties.category | True |
预算类别,无论是预算跟踪成本还是使用情况。 |
|
| properties.timeGrain | True |
预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual |
|
| properties.timePeriod | True |
预算的开始日期和结束日期。 开始日期必须是月份的第一个,并且应小于结束日期。 预算开始日期必须在 2017 年 6 月 1 日或之后。 未来的开始日期不应超过 12 个月。 应在时间段内选择过去的开始日期。 结束日期没有限制。 |
|
| eTag |
string |
资源的 eTag。 若要处理并发更新方案,此字段将用于确定用户是否正在更新最新版本。 |
|
| properties.filter |
可用于按用户指定的维度和/或标记筛选预算。 |
||
| properties.notifications |
<string, Notification> |
与预算关联的通知字典。 预算最多可以有五个通知。 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
资源“预算”更新作成功 |
|
| 201 Created |
资源“预算”创建作成功 |
|
| Other Status Codes |
意外错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| user_impersonation | 模拟用户帐户 |
示例
CreateOrUpdateBudget
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/TestBudget?api-version=2024-08-01
{
"eTag": "\"1d34d016a593709\"",
"properties": {
"amount": 100.65,
"category": "Cost",
"filter": {
"and": [
{
"dimensions": {
"name": "ResourceId",
"operator": "In",
"values": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"
]
}
},
{
"tags": {
"name": "category",
"operator": "In",
"values": [
"Dev",
"Prod"
]
}
},
{
"tags": {
"name": "department",
"operator": "In",
"values": [
"engineering",
"sales"
]
}
}
]
},
"notifications": {
"Actual_GreaterThan_80_Percent": {
"contactEmails": [
"johndoe@contoso.com",
"janesmith@contoso.com"
],
"contactGroups": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"
],
"contactRoles": [
"Contributor",
"Reader"
],
"enabled": true,
"locale": "en-us",
"operator": "GreaterThan",
"threshold": 80,
"thresholdType": "Actual"
}
},
"timeGrain": "Monthly",
"timePeriod": {
"endDate": "2018-10-31T00:00:00Z",
"startDate": "2017-10-01T00:00:00Z"
}
}
}
示例响应
{
"name": "TestBudget",
"type": "Microsoft.Consumption/budgets",
"eTag": "\"1d34d012214157f\"",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/TestBudget",
"properties": {
"amount": 100.65,
"category": "Cost",
"currentSpend": {
"amount": 80.89,
"unit": "USD"
},
"filter": {
"and": [
{
"dimensions": {
"name": "ResourceId",
"operator": "In",
"values": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"
]
}
},
{
"tags": {
"name": "category",
"operator": "In",
"values": [
"Dev",
"Prod"
]
}
},
{
"tags": {
"name": "department",
"operator": "In",
"values": [
"engineering",
"sales"
]
}
}
]
},
"notifications": {
"Actual_GreaterThan_80_Percent": {
"contactEmails": [
"johndoe@contoso.com",
"janesmith@contoso.com"
],
"contactGroups": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"
],
"contactRoles": [
"Contributor",
"Reader"
],
"enabled": true,
"locale": "en-us",
"operator": "GreaterThan",
"threshold": 80,
"thresholdType": "Actual"
}
},
"timeGrain": "Monthly",
"timePeriod": {
"endDate": "2018-10-31T00:00:00Z",
"startDate": "2017-10-01T00:00:00Z"
}
}
}
{
"name": "TestBudget",
"type": "Microsoft.Consumption/budgets",
"eTag": "\"1d34d012214157f\"",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/TestBudget",
"properties": {
"amount": 100.65,
"category": "Cost",
"currentSpend": {
"amount": 80.89,
"unit": "USD"
},
"filter": {
"and": [
{
"dimensions": {
"name": "ResourceId",
"operator": "In",
"values": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"
]
}
},
{
"tags": {
"name": "category",
"operator": "In",
"values": [
"Dev",
"Prod"
]
}
},
{
"tags": {
"name": "department",
"operator": "In",
"values": [
"engineering",
"sales"
]
}
}
]
},
"notifications": {
"Actual_GreaterThan_80_Percent": {
"contactEmails": [
"johndoe@contoso.com",
"janesmith@contoso.com"
],
"contactGroups": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"
],
"contactRoles": [
"Contributor",
"Reader"
],
"enabled": true,
"locale": "en-us",
"operator": "GreaterThan",
"threshold": 80,
"thresholdType": "Actual"
}
},
"timeGrain": "Monthly",
"timePeriod": {
"endDate": "2018-10-31T00:00:00Z",
"startDate": "2017-10-01T00:00:00Z"
}
}
}
定义
| 名称 | 说明 |
|---|---|
| Budget |
预算资源。 |
|
Budget |
要用于预算的比较表达式。 |
|
Budget |
可用于按资源组、资源或计量筛选预算。 |
|
Budget |
要按其筛选预算的维度或标记。 |
|
Budget |
要用于比较的运算符。 |
|
Budget |
预算的开始日期和结束日期。 |
|
Category |
预算类别,无论是预算跟踪成本还是使用情况。 |
|
created |
创建资源的标识的类型。 |
|
Culture |
收件人接收通知的语言 |
|
Current |
正在跟踪预算的当前成本量。 |
|
Error |
资源管理错误附加信息。 |
|
Error |
错误详细信息。 |
|
Error |
错误响应 |
|
Forecast |
正在跟踪预算的预测成本。 |
| Notification |
与预算关联的通知。 |
|
Operator |
比较运算符。 |
|
system |
与创建和上次修改资源相关的元数据。 |
|
Threshold |
阈值的类型 |
|
Time |
预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual |
Budget
预算资源。
| 名称 | 类型 | 说明 |
|---|---|---|
| eTag |
string |
资源的 eTag。 若要处理并发更新方案,此字段将用于确定用户是否正在更新最新版本。 |
| id |
string |
资源的完全限定资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
| name |
string |
资源的名称 |
| properties.amount |
number (decimal) |
用于跟踪预算的总成本 |
| properties.category |
预算类别,无论是预算跟踪成本还是使用情况。 |
|
| properties.currentSpend |
正在跟踪预算的当前成本量。 |
|
| properties.filter |
可用于按用户指定的维度和/或标记筛选预算。 |
|
| properties.forecastSpend |
正在跟踪预算的预测成本。 |
|
| properties.notifications |
<string, Notification> |
与预算关联的通知字典。 预算最多可以有五个通知。 |
| properties.timeGrain |
预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual |
|
| properties.timePeriod |
预算的开始日期和结束日期。 开始日期必须是月份的第一个,并且应小于结束日期。 预算开始日期必须在 2017 年 6 月 1 日或之后。 未来的开始日期不应超过 12 个月。 应在时间段内选择过去的开始日期。 结束日期没有限制。 |
|
| systemData |
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。 |
|
| type |
string |
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts” |
BudgetComparisonExpression
要用于预算的比较表达式。
| 名称 | 类型 | 说明 |
|---|---|---|
| name |
string |
要进行比较的列的名称。 |
| operator |
要用于比较的运算符。 |
|
| values |
string[] |
要用于比较的值数组 |
BudgetFilter
可用于按资源组、资源或计量筛选预算。
| 名称 | 类型 | 说明 |
|---|---|---|
| and |
逻辑“AND”表达式。 必须至少有 2 个项目。 |
|
| dimensions |
具有维度的比较表达式 |
|
| tags |
具有标记的比较表达式 |
BudgetFilterProperties
要按其筛选预算的维度或标记。
| 名称 | 类型 | 说明 |
|---|---|---|
| dimensions |
具有维度的比较表达式 |
|
| tags |
具有标记的比较表达式 |
BudgetOperatorType
要用于比较的运算符。
| 值 | 说明 |
|---|---|
| In |
BudgetTimePeriod
预算的开始日期和结束日期。
| 名称 | 类型 | 说明 |
|---|---|---|
| endDate |
string (date-time) |
预算的结束日期。 如果未提供,则从开始日期默认为 10 年。 |
| startDate |
string (date-time) |
预算的开始日期。 |
CategoryType
预算类别,无论是预算跟踪成本还是使用情况。
| 值 | 说明 |
|---|---|
| Cost |
createdByType
创建资源的标识的类型。
| 值 | 说明 |
|---|---|
| User | |
| Application | |
| ManagedIdentity | |
| Key |
CultureCode
收件人接收通知的语言
| 值 | 说明 |
|---|---|
| en-us | |
| ja-jp | |
| zh-cn | |
| de-de | |
| es-es | |
| fr-fr | |
| it-it | |
| ko-kr | |
| pt-br | |
| ru-ru | |
| zh-tw | |
| cs-cz | |
| pl-pl | |
| tr-tr | |
| da-dk | |
| en-gb | |
| hu-hu | |
| nb-no | |
| nl-nl | |
| pt-pt | |
| sv-se |
CurrentSpend
正在跟踪预算的当前成本量。
| 名称 | 类型 | 说明 |
|---|---|---|
| amount |
number (decimal) |
预算跟踪的总成本量。 |
| unit |
string |
预算金额的度量单位。 |
ErrorAdditionalInfo
资源管理错误附加信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| info |
object |
其他信息。 |
| type |
string |
其他信息类型。 |
ErrorDetail
错误详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalInfo |
错误附加信息。 |
|
| code |
string |
错误代码。 |
| details |
错误详细信息。 |
|
| message |
string |
错误消息。 |
| target |
string |
错误目标。 |
ErrorResponse
错误响应
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误对象。 |
ForecastSpend
正在跟踪预算的预测成本。
| 名称 | 类型 | 说明 |
|---|---|---|
| amount |
number (decimal) |
预算跟踪的总时间段的预测成本。 仅当预算包含预测警报类型时,才提供此值。 |
| unit |
string |
预算金额的度量单位。 |
Notification
与预算关联的通知。
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| contactEmails |
string[] |
用于在超出阈值时将预算通知发送到的电子邮件地址。 必须在订阅或资源组范围内至少指定一个联系人电子邮件或联系人组。 所有其他范围必须至少指定一个联系人电子邮件。 |
|
| contactGroups |
string[] |
要向超出阈值时发送预算通知的操作组。 必须以完全限定的 Azure 资源 ID 的形式提供。仅在订阅或资源组范围内受支持。 |
|
| contactRoles |
string[] |
联系角色,将预算通知发送到超出阈值时。 |
|
| enabled |
boolean |
通知已启用或不启用。 |
|
| locale |
收件人接收通知的语言 |
||
| operator |
比较运算符。 |
||
| threshold |
number (decimal) |
与通知关联的阈值。 当成本超出阈值时发送通知。 它始终是百分比,必须介于 0 到 1000 之间。 |
|
| thresholdType | Actual |
阈值的类型 |
OperatorType
比较运算符。
| 值 | 说明 |
|---|---|
| EqualTo |
如果评估的成本与阈值相同,将触发警报。 注意:不建议使用此 OperatorType,因为成本与阈值完全相同,从而导致警报缺失。 将来将弃用此 OperatorType。 |
| GreaterThan |
如果评估的成本大于阈值,将触发警报。 注意:这是配置预算警报时建议的 OperatorType。 |
| GreaterThanOrEqualTo |
如果评估的成本大于或等于阈值,将触发警报。 |
systemData
与创建和上次修改资源相关的元数据。
| 名称 | 类型 | 说明 |
|---|---|---|
| createdAt |
string (date-time) |
资源创建时间戳(UTC)。 |
| createdBy |
string |
创建资源的标识。 |
| createdByType |
创建资源的标识的类型。 |
|
| lastModifiedAt |
string (date-time) |
上次修改的资源时间戳(UTC) |
| lastModifiedBy |
string |
上次修改资源的标识。 |
| lastModifiedByType |
上次修改资源的标识的类型。 |
ThresholdType
阈值的类型
| 值 | 说明 |
|---|---|
| Actual |
实际成本预算警报通知实际应计成本超过已分配预算的时间。 |
| Forecasted |
预测成本预算警报提供高级通知,指出支出趋势可能超过分配的预算,因为它依赖于预测的成本预测。 |
TimeGrainType
预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual
| 值 | 说明 |
|---|---|
| Monthly | |
| Quarterly | |
| Annually | |
| BillingMonth | |
| BillingQuarter | |
| BillingAnnual |