您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

快速入门:通过成本分析了解和分析成本Quickstart: Explore and analyze costs with cost analysis

需要知道你组织中哪些方面产生了成本,然后才能正确地控制和优化 Azure 成本。Before you can properly control and optimize your Azure costs, you need to understand where costs originated within your organization. 这还有助于了解服务的成本及其支持的环境和系统。It's also useful to know how much money your services cost, and in support of which environments and systems. 要准确地了解组织的支出模式,必须了解成本的方方面面。Visibility into the full spectrum of costs is critical to accurately understand organizational spending patterns. 可在强制实施成本控制机制(如预算)时使用支出模式。You can use spending patterns to enforce cost control mechanisms, like budgets.

在本快速入门中,你将通过成本分析了解和分析组织成本。In this quickstart, you use cost analysis to explore and analyze your organizational costs. 可以按组织查看合计成本,了解哪些方面持续产生成本并确定支出趋势。You can view aggregated costs by organization to understand where costs occur over time and identify spending trends. 可以查看一段时间的累计成本,根据预算预估每月、每季度甚至每年的成本趋势。You can view accumulated costs over time to estimate monthly, quarterly, or even yearly cost trends against a budget. 预算可帮助你遵守财务约束。A budget helps to provide adherence to financial constraints. 并且预算用于查看每日或每月成本,以隔离异常支出行为。And a budget is used to view daily or monthly costs to isolate spending irregularities. 你还可下载当前报表的数据进行深入分析或在外部系统中使用。And, you can download the current report's data for further analysis or to use in an external system.

此快速入门介绍如何:In this quickstart, you learn how to:

  • 通过成本分析查看成本Review costs in cost analysis
  • 自定义成本视图Customize cost views
  • 下载成本分析数据Download cost analysis data


成本分析支持各种 Azure 帐户类型。Cost analysis supports different kinds of Azure account types. 若要查看支持的帐户类型的完整列表,请参阅了解成本管理数据To view the full list of supported account types, see Understand Cost Management data. 若要查看成本数据,你至少需要对 Azure 帐户具有读取访问权限。To view cost data, you need at least read access for your Azure account.

若要了解如何分配对 Azure 成本管理数据的访问权限,请参阅分配对数据的访问权限For information about assigning access to Azure Cost Management data, see Assign access to data.

如果你有新订阅,则无法立即使用成本管理功能。If you have a new subscription, you can't immediately use Cost Management features. 最多可能需要 48 小时才能使用所有成本管理功能。It might take up to 48 hours before you can use all Cost Management features.

登录 AzureSign in to Azure

通过成本分析查看成本Review costs in cost analysis

若要通过成本分析查看成本,请在 Azure 门户打开范围并在菜单中选择“成本分析”。To review your costs in cost analysis, open the scope in the Azure portal and select Cost analysis in the menu. 例如,转到“订阅”,从列表中选择订阅,然后在菜单中选择“成本分析” 。For example, go to Subscriptions, select a subscription from the list, and then select Cost analysis in the menu. 使用“范围”框可在成本分析中切换到不同的范围。Use the Scope pill to switch to a different scope in cost analysis.

所选的范围将用于整个成本管理,以提供数据整合和控制对成本信息的访问。The scope you select is used throughout Cost Management to provide data consolidation and control access to cost information. 使用范围时,不要多选它们。When you use scopes, you don't multi-select them. 而应先选择一个汇总了其他范围的较大范围,然后筛选出所需的嵌套范围。Instead, you select a larger scope, which others roll up to, and then filter down to the nested scopes you need. 了解此方法很重要,因为某些用户可能无法访问单个涵盖多个嵌套范围的父范围。This approach is important to understand because some people may not have access to a single parent scope, which covers multiple nested scopes.

请观看视频如何在 Azure 门户中使用成本管理来详细了解成本分析的用法。Watch the video How to use Cost Management in the Azure portal to learn more about how to use Cost Analysis. 若要观看其他视频,请访问成本管理 YouTube 频道To watch other videos, visit the Cost Management YouTube channel.

初始成本分析视图包括以下方面。The initial cost analysis view includes the following areas.

累计成本视图:表示预定义的成本分析视图配置。Accumulated cost view: Represents the predefined cost analysis view configuration. 每个视图包含日期范围、粒度、分组依据和筛选器设置。Each view includes date range, granularity, group by, and filter settings. 默认视图显示当前计费周期的聚合成本,但可以更改为其他内置视图。The default view shows accumulated costs for the current billing period, but you can change to other built-in views.

实际成本:显示当前月份的总使用量和购买成本。这些购买成本是应记成本,会显示在账单上。Actual cost: Shows the total usage and purchase costs for the current month, as they're accrued and will show on your bill.

预测:显示所选时间段的预测成本总计。Forecast: Shows the total forecasted costs for time period you choose.

预算:显示所选范围的计划支出限额(如可用)。Budget: Shows the planned spending limit for the selected scope, if available.

累计粒度:显示从计费周期开始算起的累计每日成本总额。Accumulated granularity: Shows the total aggregate daily costs, from the beginning of the billing period. 为计费帐户或订阅创建预算后,可快速查看对预算而言的支出趋势。After you create a budget for your billing account or subscription, you can quickly see your spending trend against the budget. 将鼠标悬停某个日期上以查看该天的累计成本。Hover over a date to view the accumulated cost for that day.

透视图(圆环图) :提供动态透视,按一组常见标准属性分解总成本。Pivot (donut) charts: Provide dynamic pivots, breaking down the total cost by a common set of standard properties. 它们显示当前月成本(从最大到最小排列)。They show the largest to smallest costs for the current month. 通过选择不同的透视,可以随时更改透视图。You can change pivot charts at any time by selecting a different pivot. 成本按服务(计量类别)、位置(区域)和子范围(默认)分类。Costs are categorized by service (meter category), location (region), and child scope by default. 例如,注册帐户在计费帐户之下,资源组在订阅之下,资源在资源组之下。For example, enrollment accounts are under billing accounts, resource groups are under subscriptions, and resources are under resource groups.

Azure 门户中成本分析的初始视图

了解预测Understand forecast

成本预测显示选定时间段的估计成本预测。Cost forecast shows a projection of your estimated costs for the selected time period. 该模型基于时序回归模型。The model is based on a time series regression model. 它需要至少 10 天的最近成本和使用情况数据才能准确预测成本。It requires at least 10 days of recent cost and usage data to accurately forecast costs. 对于给定的时间段,预测模型需要使用与预测期间相同时长的训练数据。For a given time period, the forecast model requires equal parts of training data for the forecast period. 例如,对三个月进行预测至少需要三个月的最近成本和使用情况数据。For example, a projection of three months requires at least three months of recent cost and usage data.

该模型使用最多六个月的训练数据来预测一年的成本。The model uses a maximum of six months of training data to project costs for a year. 它至少需要 7 天的训练数据才会改变它的预测。At a minimum, it needs seven days of training data to change its prediction. 此预测基于成本和使用模式的巨大变化,例如剧增和剧减。The prediction is based on dramatic changes, such as spikes and dips, in cost and usage patterns. 预测不会为“分组依据”属性中的每个项生成单独的预测。Forecast doesn't generate individual projections for each item in Group by properties. 它仅提供针对总累计成本的预测。It only provides a forecast for total accumulated costs. 如果你使用多种货币,则模型仅以美元提供成本预测。If you use multiple currencies, the model provides forecast for costs only in USD.

由于模型依赖于数据低值与峰值,因此预留实例之类的大规模购买将导致预测变得人为夸大。Because of the model's reliance on data dips and spikes, large purchases like reserved instances will cause your forecast to become artificially inflated. 预测时间段和购买规模会影响预测受影响的时长。The forecast time period and the size of purchases affect how long the forecast is affected. 当支出稳定时,预测将恢复正常。The forecast returns to normal when spending stabilizes.

自定义成本视图Customize cost views

成本分析有四个内置视图,这些视图已针对最常见的目标进行优化:Cost analysis has four built-in views, optimized for the most common goals:

查看View 回答各种问题,例如Answer questions like
累计成本Accumulated cost 这个月目前的支出是多少?How much have I spent so far this month? 在预算范围内吗?Will I stay within my budget?
每日成本Daily cost 过去 30 天的每日成本是否有增加?Have there been any increases in the costs per day for the last 30 days?
按服务划分的成本Cost by service 过去 3 张发票的每月使用情况是否有变化?How has my monthly usage vary over the past three invoices?
按资源划分的成本Cost by resource 从这个月目前的情况来看,哪些资源的成本最高?Which resources cost the most so far this month?
发票详细信息Invoice details 我的上一张发票上有哪些费用?What charges did I have on my last invoice?


但是,在很多情况下需要更深入的分析。However, there are many cases where you need deeper analysis. 在页面顶部通过数据选择进行自定义。Customization starts at the top of the page, with the date selection.

默认情况下,成本分析显示当前月份的数据。Cost analysis shows data for the current month by default. 使用日期选择器,快速切换到常用的日期范围。Use the date selector to switch to common date ranges quickly. 例如:过去七天、上个月、本年度或自定义日期范围。Examples include the last seven days, the last month, the current year, or a custom date range. 即用即付订阅还包括基于计费周期的日期范围,该周期并未与日历月绑定,例如当前的计费周期或上一张发票。Pay-as-you-go subscriptions also include date ranges based on your billing period, which isn't bound to the calendar month, like the current billing period or last invoice. 使用菜单顶部的 <上一周期下一周期> 链接分别跳至上一周期或下一周期。Use the <PREVIOUS and NEXT> links at the top of the menu to jump to the previous or next period, respectively. 例如,“<上一周期”会从“过去七天”切换到“8-14 天之前”,或切换到“15-21 天之前” 。For example, <PREVIOUS will switch from the Last 7 days to 8-14 days ago or 15-21 days ago. 选择自定义日期范围时,请记住,最多可选择一整年(例如 1 月 1 日 - 12 月 31 日)。When selecting a custom date range, keep in mind that you can select up to a full year (for example, January 1-December 31).


默认情况下,成本分析显示“累计”成本。Cost analysis shows accumulated costs by default. 累计成本显示包括前几天在内的每日费用总额,显示每日应计成本不断变化的情况。Accumulated costs include all costs for each day plus the previous days, for a constantly growing view of your daily aggregate costs. 此视图已进行优化,可显示对预算而言所选日期范围的支出趋势。This view is optimized to show how you're trending against a budget for the selected time range.

使用预测图表视图时,可以确定潜在的预算违规情况。Use the forecast chart view to identify potential budget breaches. 如果有可能的预算违规情况,则会以红色显示预计的超支。When there's a potential budget breach, projected overspending is shown in red. 另外还会在图表中显示一个指示符。An indicator symbol is also shown in the chart. 将鼠标悬停在该符号上会显示估计的预算违规日期。Hovering over the symbol shows the estimated date of the budget breach.


此外,还有每日视图显示每日成本。There's also the daily view showing costs for each day. 每日视图不会显示增长趋势。The daily view doesn't show a growth trend. 该视图旨在显示异常,如每日的成本峰值或 dip。The view is designed to show irregularities as cost spikes or dips from day to day. 如果选择了预算,则每日视图还会显示每日预算的估算值。If you've selected a budget, the daily view also shows an estimate of your daily budget.

如果每日成本不断高于估算的每日预算,可能会超出每月预算。When your daily costs are consistently above the estimated daily budget, you can expect you'll surpass your monthly budget. 估算的每日预算是一种可在较浅显的层面上帮助你直观查看预算的方式。The estimated daily budget is a means to help you visualize your budget at a lower level. 如果每日成本出现波动,则与每月预算比较,估算的每日预算不太准确。When you have fluctuations in daily costs, then the estimated daily budget comparison to your monthly budget is less precise.

下面是一个已启用支出预测功能的每日视图,显示了最近的支出。Here's a daily view of recent spending with spending forecast turned on. 显示当月的示例性每日成本的每日视图Daily view showing example daily costs for the current month

关闭支出预测功能以后,会看不到将来日期的预计支出。When turn off the spending forecast, you don't see projected spending for future dates. 另外,当你查看过去时间段的成本时,成本预测不显示成本。Also, when you look at costs for past time periods, cost forecast doesn't show costs.

通常情况下,有望在 8 到 12 小时内看到所用资源的数据或者通知。Generally, you can expect to see data or notifications for consumed resources within 8 to 12 hours.

“分组依据”通用属性,用于细分成本并确定排名靠前的贡献因素。Group by common properties to break down costs and identify top contributors. 例如,若要按资源标记分组,请选择要按其分组的标记键。To group by resource tags, for example, select the tag key you want to group by. 成本按每个标记值进行细分,并且有一个额外的段,用于未应用该标记的资源。Costs are broken down by each tag value, with an extra segment for resources that don't have that tag applied.

大部分Azure 资源都支持标记。Most Azure resources support tagging. 但某些标记在“成本管理”和“计费”中不可用。However, some tags aren't available in Cost Management and billing. 此外,不支持资源组标记。Additionally, resource group tags aren't supported. 对标记的支持适用于在将标记应用于资源后报告的使用情况。Support for tags applies to usage reported after the tag was applied to the resource. 标记不会逆向应用于成本汇总。Tags aren't applied retroactively for cost rollups.

观看 How to review tag policies with Azure Cost Management(如何通过 Azure 成本管理查看标记策略)视频,了解如何使用 Azure 标记策略来改进成本数据可见性。Watch the How to review tag policies with Azure Cost Management video to learn about using Azure tag policy to improve cost data visibility.

下面是当前月份的 Azure 服务成本视图。Here's a view of Azure service costs for the current month.

显示上个月示例 Azure 服务成本的分组的每日汇总视图

默认情况下,成本分析会显示所有使用情况和应记购买成本(也称“实际成本”),并会将其显示在发票上。By default, cost analysis shows all usage and purchase costs as they're accrued and will show on your invoice, also known as Actual cost. 查看实际成本适用于发票对帐。Viewing actual cost is ideal for reconciling your invoice. 但是,在观察成本中的支出异常和其他变化时,需警觉成本中的购买峰值。However, purchase spikes in cost can be alarming when you're keeping an eye out for spending anomalies and other changes in cost. 若要抹平因预留购买成本导致的峰值,请切换到“摊销成本”。To flatten out spikes caused by reservation purchase costs, switch to Amortized cost.


摊销成本会将预留购买细分成每日区块,将其平摊到整个预留期间。Amortized cost breaks down reservation purchases into daily chunks and spreads them over the duration of the reservation term. 例如,你会看到从 1 月 1 日到 12 月 31 日这段时间每天都有一个 1.00 美元的购买项,而不是在 1 月 1 日有一个 365 美元的购买项。For example, instead of seeing a $365 purchase on January 1, you'll see a $1.00 purchase every day from January 1 to December 31. 除了基本摊销,系统还会将这些成本重新分配并与使用了预留的特定资源相关联。In addition to basic amortization, these costs are also reallocated and associated by using the specific resources that used the reservation. 例如,如果将那个 1.00 美元的每日费用分摊到两个虚拟机,则会看到该日有两个 0.50 美元的费用。For example, if that $1.00 daily charge was split between two virtual machines, you'd see two $0.50 charges for the day. 如果该日的部分预留未使用,则会看到一个与相应的虚拟机关联的 0.50 美元费用,以及另一个费用类型为 UnusedReservation 的 0.50 美元费用。If part of the reservation isn't utilized for the day, you'd see one $0.50 charge associated with the applicable virtual machine and another $0.50 charge with a charge type of UnusedReservation. 未使用的预留成本只能在查看摊销成本时看到。Unused reservation costs can be seen only when viewing amortized cost.

必须指出,由于成本表示方式发生变化,实际成本和摊销成本视图会显示不同的总计数字。Because of the change in how costs are represented, it's important to note that actual cost and amortized cost views will show different total numbers. 通常情况下,在查看摊销成本时,有预留购买的月份的总成本会下降,而预留购买之后的月份的总成本会上升。In general, the total cost of months with a reservation purchase will decrease when viewing amortized costs, and months following a reservation purchase will increase. 目前,摊销仅适用于预留购买,不适用于 Azure 市场购买。Amortization is available only for reservation purchases and doesn't apply to Azure Marketplace purchases at this time.

下图显示了资源组名称。The following image shows resource group names. 可以按标记分组,以便按标记查看总成本;也可以使用“按资源分类的成本”视图,查看特定资源的所有标记的总成本。You can group by tag to view total costs per tag or use the Cost by resource view to see all tags for a particular resource.


当按特定的属性对成本进行分组时,将按从最高到最低的顺序显示排名前 10 的成本贡献因素。When you're grouping costs by a specific attribute, the top 10 cost contributors are shown from highest to lowest. 如果成本贡献因素超过 10 个,则会显示排名前九的成本贡献因素和一个“其他”组,该组表示合并的所有剩余组。If there are more than 10, the top nine cost contributors are shown with an Others group that represents all remaining groups combined. 按标记分组时,将显示“无标记”组,用于表示未应用标记键的成本。When you're grouping by tags, an Untagged group appears for costs that don't have the tag key applied. 非标记 总是位于最后,即使非标记成本高于标记成本。Untagged is always last, even if untagged costs are higher than tagged costs. 如果存在 10 个或更多个标记值,则非标记成本将会列在“其他”中。Untagged costs will be part of Others, if 10 or more tag values exist. 切换到表视图并将粒度更改为“无”,以查看成本从最高到最低排名的所有值。Switch to the table view and change granularity to None to see all values ranked from highest to lowest cost.

经典虚拟机、网络和存储资源不共享详细的计费数据。Classic virtual machines, networking, and storage resources don't share detailed billing data. 当对成本进行分组时,它们合并为 经典服务They're merged as Classic services when grouping costs.

主图下的透视图显示了不同的分组,让你在更大范围内了解所选时段和筛选器对应的总体成本。Pivot charts under the main chart show different groupings, which give you a broader picture of your overall costs for the selected time period and filters. 选择一个属性或标记即可按任意维度查看聚合的成本。Select a property or tag to view aggregated costs by any dimension.


你可以查看任何视图的完整数据集。You can view the full dataset for any view. 你应用的选择或筛选器会影响所显示的数据。Whichever selections or filters that you apply affect the data presented. 若要查看完整的数据集,请选择“图表类型”列表,然后选择“表”视图。To see the full dataset, select the chart type list and then select Table view.


保存和共享自定义视图Saving and sharing customized views

保存自定义视图并将其与他人共享,方法是将成本分析固定到 Azure 门户仪表板或复制成本分析的链接。Save and share customized views with others by pinning cost analysis to the Azure portal dashboard or by copying a link to cost analysis.

请观看视频在 Azure 成本管理中共享和保存视图,来详细了解如何使用门户在整个组织中分享成本知识。Watch the video Sharing and saving views in Azure Cost Management to learn more about how to use the portal to share cost knowledge around your organization. 若要观看其他视频,请访问成本管理 YouTube 频道To watch other videos, visit the Cost Management YouTube channel.

若要固定成本分析,请选择右上角或“ | 成本分析”后的图钉图标。To pin cost analysis, select the pin icon in the upper-right corner or just after the " | Cost analysis". 固定成本分析只会保存主图表或表视图。Pinning cost analysis will save only the main chart or table view. 共享仪表板,允许他人访问此磁贴。Share the dashboard to give others access to the tile. 共享只会共享仪表板配置,并不授予他人访问基础数据的权限。Sharing only shares the dashboard configuration and doesn't grant others access to the underlying data. 如果你没有成本访问权限但有共享仪表板的访问权限,将会看到“拒绝访问”消息。If you don't have access to costs but do have access to a shared dashboard, you'll see an "access denied" message.

若要共享成本分析链接,请选择窗口顶部的“共享”。To share a link to cost analysis, select Share at the top of the window. 随即会显示一个自定义 URL,单击此 URL 会打开针对此特定范围的特定视图。A custom URL will show, which opens this specific view for this specific scope. 如果你没有成本访问权限也没有获取此 URL,你将看到“拒绝访问”消息。If you don't have cost access and get this URL, you'll see an "access denied" message.

下载使用情况数据Download usage data

有时候,需要下载数据进行进一步的分析、将其与你自己的数据合并,或者将其集成到你自己的系统中。There are times when you need to download the data for further analysis, merge it with your own data, or integrate it into your own systems. 成本管理提供一些不同选项。Cost Management offers a few different options. 如果需要快速获得大致摘要(例如成本分析中的内容),请首先生成所需的视图。As a starting point, if you need a quick high-level summary, like what you get within cost analysis, build the view you need. 然后通过依次选择“导出”和“将数据下载到 CSV”或“将数据下载到 Excel”进行下载 。Then download it by selecting Export and selecting Download data to CSV or Download data to Excel. Excel 下载提供关于用于生成下载的视图的更多上下文,例如范围、查询配置、总计以及生成日期。The Excel download provides more context on the view you used to generate the download, like scope, query configuration, total, and date generated.

如果需要完整的非聚合数据集,请从计费帐户下载。If you need the full, unaggregated dataset, download it from the billing account. 然后从门户左侧导航窗格中的服务列表中转到“成本管理 + 计费”。Then, from the list of services in the portal's left navigation pane, go to Cost Management + Billing. 如果适用,请选择你的计费帐户。Select your billing account, if applicable. 转到“使用情况 + 费用”,然后选择计费周期的“下载”图标 。Go to Usage + charges, and then select the Download icon for a billing period.

清理资源Clean up resources

  • 如果已固定成本分析的自定义视图,但你不再需要它,请转到固定该视图的仪表板,然后删除固定视图。If you pinned a customized view for cost analysis and you no longer need it, go to the dashboard where you pinned it and delete the pinned view.
  • 如果下载了使用情况数据文件且不再需要这些文件,请确保将其删除。If you downloaded usage data files and you no longer need them, be sure to delete them.

后续步骤Next steps

转到第一个教程,了解如何创建并管理预算。Advance to the first tutorial to learn how to create and manage budgets.