在 Power BI Desktop (Beta) 中连接到 Azure 使用情况见解Connect to Azure Consumption Insights in Power BI Desktop (Beta)

借助 Azure 使用情况见解连接器,可以使用 Power BI Desktop 连接到 Azure,并获取有关组织 Azure 服务使用情况更详细的数据和信息。With the Azure Consumption Insights connector, you can use Power BI Desktop to connect to Azure and get in-depth data and information about your organization's Azure services usage. 还可以创建度量值、自定义列和视觉对象来报告和共享组织的 Azure 使用情况。You can also create measures, custom columns, and visuals to report and share about your organization's Azure usage. 此版本的 Azure 使用情况和见解连接器处于测试阶段,随时可能更改。This release of the Azure Consumption and Insights connector is in Beta, and is subject to change.

在本文中,你将了解如何使用 Azure 使用情况见解连接器进行连接,并获取所需的数据,如何使用 Azure 企业连接器进行迁移,此外,还会找到 ACI(Azure 使用情况见解)API 中提供的“使用情况详细信息列”的映射。In this article you learn how to connect using the Azure Consumption Insights connector and get the data you need, how to migrate from using the Azure Enterprise Connector, and you'll find a mapping of usage details columns available in the ACI (Azure Consumption Insights) API.

连接到 Azure 使用情况见解Connect to Azure Consumption Insights

要使用 Azure 使用情况见解连接器成功连接,需要能够访问 Azure 门户中的“企业”功能。To successfully connect using the Azure Consumption Insights connector, you need to have access to the Enterprise features within the Azure portal.

若要使用 Azure 使用情况见解连接器进行连接,请从“Power BI Desktop”的“主页”功能区中选择“获取数据”。To connect to using the Azure Consumption Insights connector, select Get Data from the Home ribbon in Power BI Desktop. 从左侧类别中选择“联机服务”,会看到“Microsoft Azure 使用情况见解 (Beta)”。Select Online Services from the categories on the left, and you see Microsoft Azure Consumption Insights (Beta). 选择“连接”。Select Connect.

在出现的对话框中,提供你的“合约编号”。In the dialog that appears, provide your Enrollment Number.

  • 可以从 Azure Enterprise Portal 获取合约编号,位置如下图所示。You can get your enrollment number from the Azure Enterprise Portal, in the location shown in the following image.

    此版本的连接器仅支持来自 https://ea.azure.com 的企业合约。目前尚不支持中国合约。This version of the connector only supports enterprise enrollments from https://ea.azure.com. China enrollments are not currently supported.

接下来,提供“访问密钥”进行连接。Next, provide your Access key to connect.

提供访问密钥并选择“连接”后,“导航器”窗口将显示四个可用的表,分别为:“摘要”、“使用情况”、“价目表”和“商城”。Once you provide your Access key and select Connect, a Navigator window appears and shows the four tables available to you: Summary, Usage, PriceSheet, and MarketPlace. 可以选中任意表旁边的复选框来查看预览。You can select a checkbox beside any table to see a preview. 可以通过勾选表名称旁边的框来选择一个或多个表,然后选择“加载”。You can select one or more tables by checking the box beside their name, then select Load.


“摘要”和“价目表”这两个表仅适用于注册级 API 密钥。The *Summary and *PriceSheet tables are only available for the enrollment-level API Key. 此外,这些表中的数据默认包含“使用情况”和“价目表”的当前月份数据。Also, the data in these tables has, by default, the current month's data for Usage and PriceSheet. 未将“摘要”和“商城”这两个表限制到当前月份。The Summary and MarketPlace tables are not constrained to the current month.

选择“加载”时,数据将加载到 Power BI Desktop。When you select Load the data is loaded into Power BI Desktop.

加载所选数据后,可以在“字段”窗格中看到选择的表和字段。Once the data you selected is loaded, the tables and fields you selected can be seen in the Fields pane.

使用 Azure 使用情况见解Using Azure Consumption Insights

要使用 Azure 使用情况见解连接器,需要能够访问 Azure 门户中的“企业”功能。To use the Azure Consumption Insights connector, you need to have access to the Enterprise features within the Azure portal.

使用 Azure 使用情况见解连接器成功加载数据后,可以使用“查询编辑器”创建自己的自定义度量值和列,并且可以创建可在 Power BI 服务中共享的视觉对象、报表和仪表板。Once you successfully load data using the Azure Consumption Insights connector, you can create your own custom measures and columns using Query Editor, and you can create visuals, reports, and dashboards that you can share in the Power BI service.

Azure 还包括一些可以使用空查询检索的示例自定义查询的集合。Azure also includes a collection of sample custom queries that you can retrieve using a blank query. 为此,在 Power BI Desktop 的“主页”功能区中,选择“获取数据”中的下拉箭头,然后选择“空查询”。To do so, in the Home ribbon of Power BI Desktop, select the drop down arrow in Get Data and then select Blank Query. 此外,还可以在“查询编辑器”中执行此操作,方法是右键单击左侧的“查询”窗格,然后从显示的菜单中选择“新建查询”>”空查询”。You can also do this in Query Editor by right-clicking in the Queries pane along the left, and selecting New Query > Blank Query from the menu that appears.

在“编辑栏”中,键入以下内容:In the Formula bar type the following:

= MicrosoftAzureConsumptionInsights.Contents

将显示示例集合,如下图所示。A collection of samples appear, as shown in the following image.

处理报表和创建查询时,请使用以下命令:When working with reports and creating queries, use the following:

  • 要定义从当前日期开始的月数,请使用 noOfMonthsTo define the number of months starting from the current date, use noOfMonths
    • 使用介于 1 到 36 之间的值表示自当前日期开始要导入的月数。Use a value between one and 36 to represent the number of months, from the current date, you want to import. 建议获取的数据不要超过 12 个月,以避免超过导入限制和 Power BI 中查询允许数据量限制。We recommend getting no more than 12 months of data to avoid thresholds with import constraints and the volume of data allowed for queries in Power BI.
  • 要在历史时间窗口中定义一段时间内的月份,请使用 startBillingDataWindow 和 endBillingDataWindowTo define a period of months in a historical time window, use startBillingDataWindow and endBillingDataWindow
  • 请勿将 noOfMonths 与 startBillingDataWindow 或 endBillingDataWindow 一起使用Do not use noOfMonths together with startBillingDataWindow or endBillingDataWindow

从 Azure 企业连接器迁移Migrating from the Azure Enterprise Connector

一些客户使用 Azure 企业连接器 (Beta)创建视觉对象,这些对象最终将被停用,并被替换为 Azure 使用情况见解连接器。Some customers created visuals using the Azure Enterprise Connector (Beta), which will eventually be discontinued, and is being replaced by the Azure Consumption Insights connector. Azure 使用情况见解连接器具有以下功能和增强功能:The Azure Consumption Insights connector has features and enhancements that include the following:

  • “余额汇总”和“商城购买”可用的其他数据来源Additional data sources available for Balance Summary and Marketplace Purchases
  • 新增参数和高级参数,如 startBillingDataWindow 和 endBillingDataWindowNew and advanced parameters, such as startBillingDataWindow and endBillingDataWindow
  • 更好的性能和响应能力Better performance and responsiveness

为了帮助客户过渡到较新的 Azure 使用情况见解连接器,并保留他们在创建自定义仪表板或报表方面所做的工作,以下步骤显示如何移至新的连接器。To help customers transition to the newer Azure Consumption Insights connector, and to preserve the work they've done in creating custom dashboards or reports, the following steps show how to move to the new connector.

步骤1:使用新的连接器连接到 AzureStep 1: Connect to Azure using the new connector

第一步是使用 Azure 使用情况见解连接器进行连接,这在本文前面的部分中进行了详细介绍。The first step is to connect using the Azure Consumption Insights connector, which was described earlier in this article in detail. 在此步骤中,在 Power BI Desktop 的“主页”功能区中选择“获取数据”>“空查询”。In this step, select Get Data > Blank Query from the Home ribbon in Power BI Desktop.

步骤 2:使用高级编辑器创建查询Step 2: Use the Advanced Editor to create a query

在“查询编辑器”中,从“主页”功能区的“查询”部分选择“高级编辑器”。In Query Editor, select Advanced Editor from the Query section of the Home ribbon. 在出现的“高级编辑器”窗口中,输入以下查询。In the Advanced Editor window that appears, enter the following query.

    enrollmentNumber = "100",
    optionalParameters = [ numberOfMonth = 6, dataType="DetailCharges" ],
    data = MicrosoftAzureConsumptionInsights.Contents(enrollmentNumber, optionalParameters)   

当然,需要将 enrollmentNumber 的值替换为你自己的合约编号,该编号可从 Azure Enterprise Portal 获取。Of course, you'll need to replace the value of enrollmentNumber with your own enrollment number, which you can get from the Azure Enterprise Portal. numberOfMonth 参数表示要从当前数据中返回几个月的数据。The numberOfMonth parameter is how many months of data you want going back, from the current data. 当前月份用零 (0) 表示。Use zero (0) for the current month.

在“高级编辑器”窗口中选择“完成”后,预览将会刷新,你将看到表中指定月份范围的数据。Once you select Done in the Advanced Editor window, the preview refreshes and you'll see data from the secified month range in the table. 选择“关闭并应用”,然后返回。Select Close & Apply and return.

步骤 3:将度量值和自定义列移动到新报表Step 3: Move measures and custom columns to the new report

接下来,需要将创建的全部自定义列或度量值移动到新的详细信息表中。Next you'll need to move any custom columns or measures you created into the new details table. 步骤如下。Here are the steps.

  1. 打开记事本(或其他文本编辑器)。Open Notepad (or another text editor).
  2. 选择要移动的度量值,从“公式”字段中复制文本并粘贴到记事本中。Select the measure you want to move, and copy the text from the Formula field, and place it in Notepad.

  3. 将 Query1 重命名为原始详细信息表名称。Rename Query1 to the original details table name.
  4. 右键单击表格并选择“新建度量值”,然后剪切并粘贴存储度量值和列,完成在表中创建新的度量值和自定义列操作。Create new measures and custom columns in your table by right-clicking on your table, and choosing New Measure, then cut and paste your store measures and columns until they're all done.

许多仪表板包含用于查找或筛选的其他表,可使用这类日期表或表自定义项目。Many dashboards have additional tables that are used for lookup or filtering, such date tables or tables used for custom projects. 重新建立这些关系可解决大部分遗留问题。Reestablishing those relationships resolves most remaining issues. 下面介绍如何执行该操作。Here's how to do it.

  • 在 Power BI Desktop 的“建模”选项卡中,选择“管理关系”会弹出允许你管理模型中关系的窗口。In the Modeling tab in Power BI Desktop, select Manage Relationships to bring up a window that lets you manage relationships within the model. 根据需要重新关联表。Re-link your tables, as needed.

步骤 5:验证视觉对象,并根据需要调整字段格式Step 5: Verify your visuals, and adjust field formatting as needed

执行这一步时,大部分原始视觉对象、表和向下钻取应该按预期方式工作。Once you get this far, most of your original visuals, tables, and drill-downs should be working as expected. 但是,格式设置可能需要进行一些微小调整,使内容按预期显示。However, there may be some minor tweaks necessary for formatting, to get things looking just how you want them. 花点时间查看每个仪表板和视觉对象,确保它们按预期显示。Take a bit of time to look over each of your dashboards and visuals, to ensure they look how you want them.

使用 Azure 使用情况和见解 (ACI) API 获取使用情况数据Using the Azure Consumption and Insights (ACI) API to get consumption data

Azure 还提供了 Azure 使用情况和见解 (ACI) APIAzure also provides the Azure Consumption and Insights (ACI) API. 用户可以使用 ACI API 创建自己的自定义解决方案来收集、报告和直观显示 Azure 使用情况信息。You can create your own custom solutions to gathering, reporting, and visualizing Azure consumption information using the ACI API.

映射门户、连接器和 API 之间的名称和使用情况详细信息Mapping names and usage details between the portal, the connector, and the API

Azure 门户中的列和名称详细信息与 API 和连接器中的相关信息类似,但并不总是完全一致。The columns and names of details in the Azure Portal are similar in the API and the connector, but they're not always identical. 为清晰起见,下表提供了可在 Azure 门户中看到的 API、连接器、和列之间的映射。To help clarify, the following table provides a mapping between the API, the connector, and columns you see in the Azure Portal. 还指示了列是否已过时。Also indicated is whether the column is obsolete. 有关这些术语的详细信息和定义,请查看 Azure 帐单数据字典For more information and definitions of these terms, take a look at the Azure billing data dictionary.

ACI 连接器/ContentPack ColumnNameACI Connector / ContentPack ColumnName ACI API 列名称ACI API Column Name EA 列名称EA Column Name 已过时/用于向后兼容Obsolete / Present for backward compatiblity
AccountNameAccountName accountNameaccountName Account NameAccount Name No
AccountIdAccountId accountIdaccountId Yes
AcccountOwnerIdAcccountOwnerId accountOwnerEmailaccountOwnerEmail AccountOwnerIdAccountOwnerId No
AdditionalInfoAdditionalInfo additionalInfoadditionalInfo AdditionalInfoAdditionalInfo No
AdditionalInfoldAdditionalInfold Yes
Consumed QuantityConsumed Quantity consumedQuantityconsumedQuantity Consumed QuantityConsumed Quantity No
Consumed ServiceConsumed Service consumedServiceconsumedService Consumed ServiceConsumed Service No
ConsumedServiceIdConsumedServiceId consumedServiceIdconsumedServiceId Yes
CostCost costcost ExtendedCostExtendedCost No
Cost CenterCost Center costCentercostCenter Cost CenterCost Center No
日期Date datedate 日期Date No
Day Day No
DepartmentNameDepartmentName departmentNamedepartmentName Department NameDepartment Name No
DepartmentIDDepartmentID departmentIddepartmentId Yes
Instance IDInstance ID Yes
InstanceIdInstanceId instanceIdinstanceId Instance IDInstance ID No
位置Location Yes
Meter CategoryMeter Category meterCategorymeterCategory Meter CategoryMeter Category No
Meter IDMeter ID Yes
Meter NameMeter Name meterNamemeterName Meter NameMeter Name No
Meter RegionMeter Region meterRegionmeterRegion Meter RegionMeter Region No
Meter Sub-CategoryMeter Sub-Category meterSubCategorymeterSubCategory Meter Sub-CategoryMeter Sub-Category No
MeterIdMeterId meterIdmeterId Meter IDMeter ID No
月份Month 月份Month No
产品Product productproduct 产品Product No
ProductIdProductId productIdproductId Yes
Resource GroupResource Group resourceGroupresourceGroup Resource GroupResource Group No
Resource LocationResource Location resourceLocationresourceLocation Resource LocationResource Location No
ResourceGroupIdResourceGroupId Yes
ResourceLocationIdResourceLocationId resourceLocationIdresourceLocationId Yes
ResourceRateResourceRate resourceRateresourceRate ResourceRateResourceRate No
ServiceAdministratorIdServiceAdministratorId serviceAdministratorIdserviceAdministratorId ServiceAdministratorIdServiceAdministratorId No
ServiceInfo1ServiceInfo1 serviceInfo1serviceInfo1 ServiceInfo1ServiceInfo1 No
ServiceInfo1IdServiceInfo1Id Yes
ServiceInfo2ServiceInfo2 serviceInfo2serviceInfo2 ServiceInfo2ServiceInfo2 No
ServiceInfo2IdServiceInfo2Id Yes
Store Service IdentifierStore Service Identifier storeServiceIdentifierstoreServiceIdentifier Store Service IdentifierStore Service Identifier No
StoreServiceIdentifierIdStoreServiceIdentifierId Yes
Subscription NameSubscription Name subscriptionNamesubscriptionName Subscription NameSubscription Name No
标记Tags tagstags 标记Tags No
TagsIdTagsId Yes
Unit Of MeasureUnit Of Measure unitOfMeasureunitOfMeasure Unit Of MeasureUnit Of Measure No
年份Year 年份Year No
SubscriptionIdSubscriptionId subscriptionIdsubscriptionId SubscriptionIdSubscriptionId Yes
SubscriptionGuidSubscriptionGuid subscriptionGuidsubscriptionGuid SubscriptionGuidSubscriptionGuid No

后续步骤Next steps

你可以使用 Power BI Desktop 连接到各种数据。There are all sorts of data you can connect to using Power BI Desktop. 有关数据源的详细信息,请参阅下列资源:For more information on data sources, check out the following resources: