你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Budgets - Get

按预算名称获取范围的预算。

GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}?api-version=2023-05-01

URI 参数

名称 必需 类型 说明
budgetName
path True

string

预算名称。

scope
path True

string

与预算操作关联的范围。 这包括订阅范围的“/subscriptions/{subscriptionId}/” “/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}”表示 resourceGroup 范围,“/providers/Microsoft.Billing/billingAccounts/{billingAccountId}”表示计费帐户范围,“/providers/Microsoft.Billing/billingAccounts/{billingAccounts/{billingAccounts/{billingAccountId}/{billingAccountId}/departments/departmentId}”表示部门范围,“/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, “/providers/Microsoft.Management/managementGroups/{managementGroupId}”表示管理组范围,“/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}”表示 billingProfile 范围,“/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSectionId}”表示 invoiceSection 范围。

api-version
query True

string

要与客户端请求一起使用的 API 的版本。 当前版本为 2023-03-01。

响应

名称 类型 说明
200 OK

Budget

没问题。 请求已成功。

Other Status Codes

ErrorResponse

描述操作失败原因的错误响应。

安全性

azure_auth

Azure Active Directory OAuth2 流。

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名称 说明
user_impersonation 模拟用户帐户

示例

Budget

Sample Request

GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/TestBudget?api-version=2023-05-01

Sample Response

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/TestBudget",
  "name": "TestBudget",
  "type": "Microsoft.Consumption/budgets",
  "eTag": "\"1d34d012214157f\"",
  "properties": {
    "category": "Cost",
    "amount": 100.65,
    "timeGrain": "Monthly",
    "timePeriod": {
      "startDate": "2017-10-01T00:00:00Z",
      "endDate": "2018-10-31T00:00:00Z"
    },
    "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"
            ]
          }
        }
      ]
    },
    "currentSpend": {
      "amount": 80.89,
      "unit": "USD"
    },
    "notifications": {
      "Actual_GreaterThan_80_Percent": {
        "enabled": true,
        "operator": "GreaterThan",
        "threshold": 80,
        "contactEmails": [
          "johndoe@contoso.com",
          "janesmith@contoso.com"
        ],
        "contactRoles": [
          "Contributor",
          "Reader"
        ],
        "contactGroups": [
          "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"
        ],
        "thresholdType": "Actual"
      }
    }
  }
}

定义

名称 说明
Budget

预算资源。

BudgetComparisonExpression

要用于预算的比较表达式。

BudgetFilter

可用于按资源组、资源或计量筛选预算。

BudgetFilterProperties

用于筛选预算的维度或标记。

BudgetOperatorType

用于比较的运算符。

BudgetTimePeriod

预算的开始和结束日期。

CategoryType

预算的类别,无论预算是跟踪成本还是使用情况。

CultureCode

接收方接收通知时使用的语言

CurrentSpend

正在为预算跟踪的当前成本量。

ErrorDetails

错误的详细信息。

ErrorResponse

错误响应指示服务无法处理传入请求。 错误消息中提供了原因。

某些错误响应:

  • 429 TooManyRequests - 请求受到限制。 等待“x-ms-ratelimit-microsoft.consumption-retry-after”标头中指定的时间后重试。

  • 503 ServiceUnavailable - 服务暂时不可用。 等待“Retry-After”标头中指定的时间后重试。

ForecastSpend

正在跟踪预算的预测成本。

Notification

与预算关联的通知。

OperatorType

比较运算符。

ThresholdType

阈值的类型

TimeGrainType

预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual

Budget

预算资源。

名称 类型 说明
eTag

string

资源的 eTag。 为了处理并发更新方案,此字段将用于确定用户是否正在更新最新版本。

id

string

资源 ID。

name

string

资源名称。

properties.amount

number

与预算一起跟踪的总成本

properties.category

CategoryType

预算的类别,无论预算是跟踪成本还是使用情况。

properties.currentSpend

CurrentSpend

正在为预算跟踪的当前成本量。

properties.filter

BudgetFilter

可用于按用户指定的维度和/或标记筛选预算。

properties.forecastSpend

ForecastSpend

正在跟踪预算的预测成本。

properties.notifications

<string,  Notification>

与预算关联的通知字典。 预算最多可以有五个通知。

properties.timeGrain

TimeGrainType

预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual

properties.timePeriod

BudgetTimePeriod

具有预算的开始和结束日期。 开始日期必须是当月的第一个日期,并且应小于结束日期。 预算开始日期必须在 2017 年 6 月 1 日或之后。 将来的开始日期不应超过 12 个月。 应在时间段内选择过去的开始日期。 结束日期没有限制。

type

string

资源类型。

BudgetComparisonExpression

要用于预算的比较表达式。

名称 类型 说明
name

string

要用于比较的列的名称。

operator

BudgetOperatorType

用于比较的运算符。

values

string[]

要用于比较的值数组

BudgetFilter

可用于按资源组、资源或计量筛选预算。

名称 类型 说明
and

BudgetFilterProperties[]

逻辑“AND”表达式。 必须至少有 2 个项。

dimensions

BudgetComparisonExpression

具有维度的比较表达式

tags

BudgetComparisonExpression

具有标记的比较表达式

BudgetFilterProperties

用于筛选预算的维度或标记。

名称 类型 说明
dimensions

BudgetComparisonExpression

具有维度的比较表达式

tags

BudgetComparisonExpression

具有标记的比较表达式

BudgetOperatorType

用于比较的运算符。

名称 类型 说明
In

string

BudgetTimePeriod

预算的开始和结束日期。

名称 类型 说明
endDate

string

预算的结束日期。 如果未提供,则默认为自开始日期起的 10 年。

startDate

string

预算的开始日期。

CategoryType

预算的类别,无论预算是跟踪成本还是使用情况。

名称 类型 说明
Cost

string

CultureCode

接收方接收通知时使用的语言

名称 类型 说明
cs-cz

string

da-dk

string

de-de

string

en-gb

string

en-us

string

es-es

string

fr-fr

string

hu-hu

string

it-it

string

ja-jp

string

ko-kr

string

nb-no

string

nl-nl

string

pl-pl

string

pt-br

string

pt-pt

string

ru-ru

string

sv-se

string

tr-tr

string

zh-cn

string

zh-tw

string

CurrentSpend

正在为预算跟踪的当前成本量。

名称 类型 说明
amount

number

预算跟踪的总成本。

unit

string

预算金额的度量单位。

ErrorDetails

错误的详细信息。

名称 类型 说明
code

string

错误代码。

message

string

指示操作失败原因的错误消息。

ErrorResponse

错误响应指示服务无法处理传入请求。 错误消息中提供了原因。

某些错误响应:

  • 429 TooManyRequests - 请求受到限制。 等待“x-ms-ratelimit-microsoft.consumption-retry-after”标头中指定的时间后重试。

  • 503 ServiceUnavailable - 服务暂时不可用。 等待“Retry-After”标头中指定的时间后重试。

名称 类型 说明
error

ErrorDetails

错误的详细信息。

ForecastSpend

正在跟踪预算的预测成本。

名称 类型 说明
amount

number

预算跟踪的总时间段的预测成本。 仅当预算包含预测警报类型时,才提供此值。

unit

string

预算金额的度量单位。

Notification

与预算关联的通知。

名称 类型 默认值 说明
contactEmails

string[]

Email地址,以在超出阈值时向发送预算通知。 必须在订阅或资源组范围内至少指定一个联系人电子邮件或联系人组。 所有其他范围必须至少指定一个联系人电子邮件。

contactGroups

string[]

在超出阈值时将预算通知发送到的操作组。 必须作为完全限定的 Azure 资源 ID 提供。仅在订阅或资源组范围内受支持。

contactRoles

string[]

联系角色,在超出阈值时向其发送预算通知。

enabled

boolean

通知已启用或未启用。

locale

CultureCode

接收方接收通知时使用的语言

operator

OperatorType

比较运算符。

threshold

number

与通知关联的阈值。 当成本超过阈值时,将发送通知。 它始终为百分比,并且必须介于 0 和 1000 之间。

thresholdType

ThresholdType

Actual

阈值的类型

OperatorType

比较运算符。

名称 类型 说明
EqualTo

string

如果评估的成本与阈值相同,则会触发警报。 注意:不建议使用此 OperatorType,因为成本与阈值完全相同的可能性很小,从而导致缺少警报。 此 OperatorType 将来将弃用。

GreaterThan

string

如果评估的成本大于阈值,则会触发警报。 注意:这是配置预算警报时建议的 OperatorType。

GreaterThanOrEqualTo

string

如果评估的成本大于或等于阈值,则会触发警报。

ThresholdType

阈值的类型

名称 类型 说明
Actual

string

实际成本预算警报在实际应计成本超过分配的预算时发出通知。

Forecasted

string

预测成本预算警报提供高级通知,指示支出趋势可能超过分配的预算,因为它依赖于预测的成本预测。

TimeGrainType

预算涵盖的时间。 将根据时间粒度重置对金额的跟踪。 仅 WD 客户支持 BillingMonth、BillingQuarter 和 BillingAnnual

名称 类型 说明
Annually

string

BillingAnnual

string

BillingMonth

string

BillingQuarter

string

Monthly

string

Quarterly

string