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

Generate Cost Details Report - Create Operation

此 API 是以前发布的所有使用情况详细信息 API 的替代项。 请求为提供的日期范围、计费周期 (仅在特定范围内异步) 或发票 ID 的企业客户生成成本详细信息报表。 请求报告的初始调用将返回带有“Location”和“Retry-After”标头的 202。 “Location”标头将提供用于轮询的终结点,以获取报表生成的结果。 “Retry-After”提供轮询生成的报表之前等待的持续时间。 如果操作仍在进行中,则轮询报表操作的调用将提供带有“Location”标头的 202 响应。 报告生成操作完成后,轮询终结点将提供 200 响应以及报表 blob (可供下载) 的详细信息。 轮询响应正文中将提供可供下载的文件 () 的详细信息。 若要了解成本详细信息 (以前称为使用情况详细信息) 在文件中找到的字段,请参阅 https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields

POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

URI 参数

名称 必需 类型 说明
scope
path True

string

订阅、计费帐户或其他计费范围的 ARM 资源 ID。目前不支持资源组和管理组。 有关详细信息,请参阅 https://aka.ms/costmgmt/scopes

api-version
query True

string

要用于此操作的 API 版本。

请求正文

名称 类型 说明
billingPeriod

string

此参数只能由企业协议客户使用。 使用 YearMonth (例如202008) 格式。 此参数不能与 invoiceId 或 timePeriod 参数一起使用。 如果在请求正文中未提供 timePeriod、invoiceId 或 billingPeriod 参数,API 将返回当月的成本。

invoiceId

string

此参数只能由 Microsoft 客户协议客户使用。 此外,它只能在计费配置文件或客户范围内使用。 此参数不能与 billingPeriod 或 timePeriod 参数一起使用。 如果在请求正文中未提供 timePeriod、invoiceId 或 billingPeriod 参数,API 将返回当月的成本。

metric

CostDetailsMetricType

详细报表的类型。 默认提供 ActualCost

timePeriod

CostDetailsTimePeriod

为报表请求的成本详细信息的特定日期范围。 此参数不能与 invoiceId 或 billingPeriod 参数一起使用。 如果在请求正文中未提供 timePeriod、invoiceId 或 billingPeriod 参数,API 将返回当月的成本。 API 仅允许拉取 1 个月或更短且不超过 13 个月的数据。 如果未提供 timePeriod 或 billingPeriod 或 invoiceId,则 API 默认为开放月份时间段

响应

名称 类型 说明
200 OK

CostDetailsOperationResults

请求处理已完成。

202 Accepted

已接受。 将处理请求。 使用 Location 标头检查状态。

Headers

  • Location: string
  • Retry-After: integer
204 No Content

无内容。 请求已成功,但未返回任何结果。

Other Status Codes

GenerateCostDetailsReportErrorResponse

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

安全性

azure_auth

Azure Active Directory OAuth2 流。

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

Scopes

名称 说明
user_impersonation 模拟用户帐户

示例

GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod
GenerateCostDetailsReportByBillingProfileAndInvoiceId
GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId
GenerateCostDetailsReportByCustomerAndTimePeriod
GenerateCostDetailsReportByDepartmentsAndTimePeriod
GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod
GenerateCostDetailsReportBySubscriptionAndTimePeriod

GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "billingPeriod": "202205"
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "providers/Microsoft.Billing/billingAccounts/12345",
      "requestBody": {
        "metric": "ActualCost",
        "billingPeriod": "202205"
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

GenerateCostDetailsReportByBillingProfileAndInvoiceId

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "invoiceId": "M1234567"
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579",
      "requestBody": {
        "metric": "ActualCost",
        "billingPeriod": "202205"
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "invoiceId": "M1234567"
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579",
      "requestBody": {
        "metric": "ActualCost",
        "billingPeriod": "202205"
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

GenerateCostDetailsReportByCustomerAndTimePeriod

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "timePeriod": {
    "start": "2020-03-01",
    "end": "2020-03-15"
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579",
      "requestBody": {
        "metric": "ActualCost",
        "timePeriod": {
          "start": "2020-03-01",
          "end": "2020-03-15"
        }
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

GenerateCostDetailsReportByDepartmentsAndTimePeriod

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/departments/12345/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "timePeriod": {
    "start": "2020-03-01",
    "end": "2020-03-15"
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/departments/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "providers/Microsoft.Billing/departments/12345",
      "requestBody": {
        "metric": "ActualCost",
        "timePeriod": {
          "start": "2020-03-01",
          "end": "2020-03-15"
        }
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/providers/Microsoft.Billing/departments/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/enrollmentAccounts/1234/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "timePeriod": {
    "start": "2020-03-01",
    "end": "2020-03-15"
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/enrollmentAccounts/1234/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "providers/Microsoft.Billing/enrollmentAccounts/1234",
      "requestBody": {
        "metric": "ActualCost",
        "timePeriod": {
          "start": "2020-03-01",
          "end": "2020-03-15"
        }
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/providers/Microsoft.Billing/enrollmentAccounts/1234/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

GenerateCostDetailsReportBySubscriptionAndTimePeriod

Sample Request

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01

{
  "metric": "ActualCost",
  "timePeriod": {
    "start": "2020-03-01",
    "end": "2020-03-15"
  }
}

Sample Response

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000",
  "name": "00000000-0000-0000-0000-000000000000",
  "status": "Completed",
  "manifest": {
    "manifestVersion": "2023-11-01",
    "dataFormat": "Csv",
    "blobCount": 1,
    "byteCount": 32741,
    "compressData": false,
    "requestContext": {
      "requestScope": "subscriptions/00000000-0000-0000-0000-000000000000",
      "requestBody": {
        "metric": "ActualCost",
        "timePeriod": {
          "start": "2020-03-01",
          "end": "2020-03-15"
        }
      }
    },
    "blobs": [
      {
        "blobLink": "https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd",
        "byteCount": 32741
      }
    ]
  },
  "validTill": "2022-05-10T08:08:46.1973252Z"
}
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000?api-version=2023-11-01
Retry-After: 60

定义

名称 说明
BlobInfo

此操作生成的 Blob 信息。

CostDetailsDataFormat

报表的数据格式

CostDetailsMetricType

详细报表的类型。 默认提供 ActualCost

CostDetailsOperationResults

成本详细信息 Api 的长时间运行操作的结果。

CostDetailsStatusType

成本详细信息操作的状态

CostDetailsTimePeriod

拉取成本详细报表数据的开始和结束日期。 API 仅允许拉取 1 个月或更短且不超过 13 个月的数据。

ErrorDetails

错误的详细信息。

GenerateCostDetailsReportErrorResponse

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

某些错误响应:

  • 400 错误请求 - 请求有效负载无效。 提供的请求有效负载不是 json 格式,或者请求有效负载中未接受无效成员。

  • 400 错误请求 - 请求有效负载无效:只能具有 timePeriod 或 invoiceId 或 billingPeriod。 API 仅允许拉取 timePeriod 或 invoiceId 或 billingPeriod 的数据。 客户应仅提供其中一个参数。

  • 400 错误请求 - 开始日期必须晚于 。 API 仅允许拉取数据的时间不超过 13 个月。

  • 400 错误请求 - 允许的最大日期范围为 1 个月。 API 仅允许拉取 1 个月或更短的数据。

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

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

GenerateCostDetailsReportRequestDefinition

成本详细报表的定义。

BlobInfo

此操作生成的 Blob 信息。

名称 类型 说明
blobLink

string

链接到要下载文件的 Blob。

byteCount

integer

Blob 中的字节数。

CostDetailsDataFormat

报表的数据格式

名称 类型 说明
Csv

string

Csv 数据格式。

CostDetailsMetricType

详细报表的类型。 默认提供 ActualCost

名称 类型 说明
ActualCost

string

实际成本数据。

AmortizedCost

string

摊销成本数据。

CostDetailsOperationResults

成本详细信息 Api 的长时间运行操作的结果。

名称 类型 说明
error

ErrorDetails

错误的详细信息。

id

string

长时间运行的操作的 ID。

manifest.blobCount

integer

Blob 的总数。

manifest.blobs

BlobInfo[]

此操作生成的 Blob 信息的列表。

manifest.byteCount

integer

所有 Blob 中的字节总数。

manifest.compressData

boolean

压缩格式的数据。

manifest.dataFormat

CostDetailsDataFormat

报表的数据格式

manifest.manifestVersion

string

清单版本。

manifest.requestContext.requestBody

GenerateCostDetailsReportRequestDefinition

成本详细信息调用中提供的请求有效负载正文

manifest.requestContext.requestScope

string

请求的请求范围。

name

string

长时间运行的操作的名称。

status

CostDetailsStatusType

成本详细信息操作的状态

type

string

长时间运行的操作的类型。

validTill

string

报告 URL 变为无效/过期的时间(UTC 格式),例如 2020-12-08T05:55:59.4394737Z。

CostDetailsStatusType

成本详细信息操作的状态

名称 类型 说明
Completed

string

操作已完成。

Failed

string

操作失败。

NoDataFound

string

操作已完成,未找到成本数据。

CostDetailsTimePeriod

拉取成本详细报表数据的开始和结束日期。 API 仅允许拉取 1 个月或更短且不超过 13 个月的数据。

名称 类型 说明
end

string

要将数据拉取到的结束日期。示例格式 2020-03-15

start

string

要从中拉取数据的开始日期。 示例格式 2020-03-15

ErrorDetails

错误的详细信息。

名称 类型 说明
code

string

错误代码。

message

string

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

GenerateCostDetailsReportErrorResponse

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

某些错误响应:

  • 400 错误请求 - 请求有效负载无效。 提供的请求有效负载不是 json 格式,或者请求有效负载中未接受无效成员。

  • 400 错误请求 - 请求有效负载无效:只能具有 timePeriod 或 invoiceId 或 billingPeriod。 API 仅允许拉取 timePeriod 或 invoiceId 或 billingPeriod 的数据。 客户应仅提供其中一个参数。

  • 400 错误请求 - 开始日期必须晚于 。 API 仅允许拉取数据的时间不超过 13 个月。

  • 400 错误请求 - 允许的最大日期范围为 1 个月。 API 仅允许拉取 1 个月或更短的数据。

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

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

名称 类型 说明
error

ErrorDetails

错误的详细信息。

GenerateCostDetailsReportRequestDefinition

成本详细报表的定义。

名称 类型 说明
billingPeriod

string

此参数只能由企业协议客户使用。 使用 YearMonth (例如202008) 格式。 此参数不能与 invoiceId 或 timePeriod 参数一起使用。 如果在请求正文中未提供 timePeriod、invoiceId 或 billingPeriod 参数,API 将返回当月的成本。

invoiceId

string

此参数只能由 Microsoft 客户协议客户使用。 此外,它只能在计费配置文件或客户范围内使用。 此参数不能与 billingPeriod 或 timePeriod 参数一起使用。 如果在请求正文中未提供 timePeriod、invoiceId 或 billingPeriod 参数,API 将返回当月的成本。

metric

CostDetailsMetricType

详细报表的类型。 默认提供 ActualCost

timePeriod

CostDetailsTimePeriod

为报表请求的成本详细信息的特定日期范围。 此参数不能与 invoiceId 或 billingPeriod 参数一起使用。 如果在请求正文中未提供 timePeriod、invoiceId 或 billingPeriod 参数,API 将返回当月的成本。 API 仅允许拉取 1 个月或更短且不超过 13 个月的数据。 如果未提供 timePeriod 或 billingPeriod 或 invoiceId,则 API 默认为开放月份时间段