在 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 使用深入解析連接器處於搶鮮版 (Beta),並可能有所變更。This release of the Azure Consumption and Insights connector is in Beta, and is subject to change.

在本文章中,您了解如何使用 Azure 使用深入解析連接器進行連線,並取得您需要的資料、如何從使用 Azure Enterprise 連接器移轉,且您會發現「使用方式詳細資料資料行」的對應,這提供於 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 企業版入口網站取得註冊號碼,位置如下列影像所示。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.

提供您的「存取金鑰」並選取 [連接] 之後,會出現 [導覽] 視窗,並顯示四個您可用的資料表:SummaryUsagePriceSheetMarketPlaceOnce 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.

注意

Summary 和 PriceSheet 資料表只可供註冊層級 API 金鑰之用。The *Summary and *PriceSheet tables are only available for the enrollment-level API Key. 此外,這些資料表中的資料預設具有目前月份的 UsagePriceSheet 資料。Also, the data in these tables has, by default, the current month's data for Usage and PriceSheet. SummaryMarketPlace 資料表不受限於目前月份。The Summary and MarketPlace tables are not constrained to the current month.

當您選取 [載入] 時,資料會載入到 Power BI DesktopWhen 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.
  • 若要定義歷程記錄時間範圍中的月份期間,請使用 startBillingDataWindowendBillingDataWindowTo define a period of months in a historical time window, use startBillingDataWindow and endBillingDataWindow
  • 請「勿」使用 noOfMonths 搭配 startBillingDataWindowendBillingDataWindowDo 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:

  • 適用於 Balance SummaryMarketplace Purchases 的其他資料來源Additional data sources available for Balance Summary and Marketplace Purchases
  • 新參數和進階參數,例如 startBillingDataWindowendBillingDataWindowNew 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.

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

當然,您必須將 enrollmentNumber 的值取代為您自己的註冊號碼,您可以從 Azure 企業版入口網站取得。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. 為了協助釐清,下表提供 API、連接器與您在 Azure 入口網站中看到的資料行之間的對應。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
ProductProduct productproduct ProductProduct 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: