教學課程:建立和管理匯出的資料Tutorial: Create and manage exported data

若您已閱讀過成本分析教學課程,您便已對手動下載成本管理資料相當熟悉。If you read the Cost Analysis tutorial, then you're familiar with manually downloading your Cost Management data. 但是,您可以建立週期性工作,每天、每週或每個月自動將您的成本管理資料匯出至 Azure 儲存體。However, you can create a recurring task that automatically exports your Cost Management data to Azure storage on a daily, weekly, or monthly basis. 匯出的資料格式為 CSV,其中包含所有由成本管理收集的資訊。Exported data is in CSV format and it contains all the information that's collected by Cost Management. 您接著可以在 Azure 儲存體中,搭配外部系統使用匯出的資料,並與您擁有的自訂資料合併。You can then use the exported data in Azure storage with external systems and combine it with your own custom data. 您也可以在外部系統 (例如儀表板或其他財務系統) 中使用您的匯出資料。And you can use your exported data in an external system like a dashboard or other financial system.

觀看影片:如何使用 Azure 成本管理制定匯出至儲存體的排程,為您的 Azure 成本資料建立匯出至 Azure 儲存體的排程。Watch the How to schedule exports to storage with Azure Cost Management video about creating a scheduled export of your Azure cost data to Azure Storage. 若要觀看其他影片,請造訪成本管理 YouTube 頻道To watch other videos, visit the Cost Management YouTube channel.

本教學課程中的範例會引導您匯出成本管理資料,並驗證該資料已成功匯出。The examples in this tutorial walk you though exporting your cost management data and then verify that the data was successfully exported.

在本教學課程中,您會了解如何:In this tutorial, you learn how to:

  • 建立每日匯出Create a daily export
  • 驗證已收集資料Verify that data is collected


資料匯出適用于各種不同的 Azure 帳戶類型,包括 Enterprise 合約 (EA) Microsoft 客戶合約 客戶。Data export is available for various Azure account types, including Enterprise Agreement (EA) and Microsoft Customer Agreement customers. 若要檢視所支援帳戶類型的完整清單,請參閱了解成本管理資料To view the full list of supported account types, see Understand Cost Management data. 針對依使用者和群組的資料匯出,每個訂用帳戶皆支援下列 Azure 權限或範圍。The following Azure permissions, or scopes, are supported per subscription for data export by user and group. 如需有關範圍的詳細資訊,請參閱了解並使用範圍For more information about scopes, see Understand and work with scopes.

  • 擁有者-可以建立、修改或刪除訂用帳戶的排程匯出。Owner - Can create, modify, or delete scheduled exports for a subscription.
  • 參與者-可以建立、修改或刪除他們自己的排程匯出。Contributor - Can create, modify, or delete their own scheduled exports. 可以修改其他人所建立的排程匯出名稱。Can modify the name of scheduled exports created by others.
  • 讀者-可以排程擁有其許可權的匯出。Reader - Can schedule exports that they have permission to.

如需範圍的詳細資訊,包括為 Enterprise 合約和 Microsoft 客戶合約範圍設定匯出所需的存取權,請參閱 瞭解及使用範圍For more information about scopes, including access needed to configure exports for Enterprise Agreement and Microsoft Customer agreement scopes, see Understand and work with scopes.

針對 Azure 儲存體帳戶:For Azure Storage accounts:

  • 需要有寫入權限,才能變更已設定的儲存體帳戶,而不需與匯出的許可權無關。Write permissions are required to change the configured storage account, independent of permissions on the export.
  • 您的 Azure 儲存體帳戶必須針對 Blob 或檔案儲存體進行設定。Your Azure storage account must be configured for blob or file storage.

如果您有新的訂用帳戶,您無法立即使用成本管理功能。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

登入 Azure 入口網站:https://portal.azure.comSign in to the Azure portal at https://portal.azure.com.

建立每日匯出Create a daily export

若要建立或查看資料匯出或排程匯出,請選擇 [Azure 入口網站中的範圍,然後選取功能表中的 [ 成本分析 ]。To create or view a data export or to schedule an export, choose a scope in the Azure portal and select Cost analysis in the menu. 例如,瀏覽至 [訂用帳戶]、從清單中選取訂用帳戶,然後在功能表中選取 [成本分析]。For example, navigate to Subscriptions, select a subscription from the list, and then select Cost analysis in the menu. 在成本分析頁面頂端,選取 [設定],然後選取 [匯出]。At the top of the Cost analysis page, select Settings, then Exports.


  • 除了訂用帳戶,您也可以在資源群組、管理群組、部門和註冊上建立匯出。Besides subscriptions, you can create exports on resource groups, management groups, departments, and enrollments. 如需有關範圍的詳細資訊,請參閱了解並使用範圍For more information about scopes, see Understand and work with scopes.
  • 當您在計費帳戶範圍或客戶的租用戶上以合作夥伴身分登入時,您可以將資料匯出至與合作夥伴儲存體帳戶連結的 Azure 儲存體帳戶。When you're signed in as a partner at the billing account scope or on a customer's tenant, you can export data to an Azure Storage account that's linked to your partner storage account. 不過,您必須在 CSP 租用戶中擁有有效的訂用帳戶。However, you must have an active subscription in your CSP tenant.
  1. 選取 [新增],然後輸入匯出的名稱。Select Add and type a name for the export.
  2. 針對 計量,請選取:For the Metric, make a selection:
    • 實際成本 (使用量和購買) - 選擇匯出標準使用量和購買Actual cost (Usage and Purchases) - Select to export standard usage and purchases
    • 分攤成本 (使用量和採購) - 選取以匯出 Azure 保留等購買的分攤成本Amortized cost (Usage and Purchases) - Select to export amortized costs for purchases like Azure reservations
  3. 匯出類型,請選取:For Export type, make a selection:
    • 日匯出當月成本-為您的當月成本每天提供新的匯出檔案。Daily export of month-to-date costs - Provides a new export file daily for your month-to-date costs. 系統會從先前的每日匯出彙總最新資料。The latest data is aggregated from previous daily exports.
    • 過去 七天的每週成本匯出-從匯出的選取開始日期開始,為過去七天建立成本的每週匯出。Weekly export of cost for the last seven days - Creates a weekly export of your costs for the past seven days from the selected start date of your export.
    • 上個月成本的每月匯出 -與您建立匯出的當月相同,可讓您匯出上個月的成本。Monthly export of last month's costs - Provides you with an export of your last month's costs compared to the current month that you create the export. 之後,此排程會在每個新月份的第五天與您先前的月份成本之間執行匯出。Afterward, the schedule runs an export on the fifth day of every new month with your previous months costs.
    • 單次 匯出-可讓您選擇要匯出至 Azure blob 儲存體的歷程記錄資料的日期範圍。One-time export - Allows you to choose a date range for historical data to export to Azure blob storage. 從選擇的日期起算,您最多可以匯出 90 天的歷程記錄成本。You can export a maximum of 90 days of historical costs from the day you choose. 這項匯出會立即執行,您的儲存體帳戶在兩個小時內會提供此資訊。This export runs immediately and is available in your storage account within two hours. 根據您的匯出類型,選擇開始日期,或選擇 開始結束 日期。Depending on your export type, either choose a start date, or choose a From and To date.
  4. 為您的 Azure 儲存體帳戶指定訂用帳戶,然後選取資源群組或建立新的資源群組。Specify the subscription for your Azure storage account, then select a resource group or create a new one.
  5. 選取儲存體帳戶名稱,或建立新名稱。Select the storage account name or create a new one.
  6. 選取位置 (Azure 區域)。Select the location (Azure region).
  7. 指定您希望匯出檔案移至的儲存體容器和目錄路徑。Specify the storage container and the directory path that you'd like the export file to go to. 新增匯出範例
  8. 檢閱匯出詳細資料,然後選取 [建立]。Review your export details and select Create.

您新增的匯出會出現在匯出清單中。Your new export appears in the list of exports. 根據預設會啟用新的匯出。By default, new exports are enabled. 若您想要停用或刪除已排程的匯出,請選取清單中的任何項目,然後選取 [停用] 或 [刪除]。If you want to disable or delete a scheduled export, select any item in the list and then select either Disable or Delete.

剛開始可能會需要12 到 24 個小時,才會開始執行匯出。Initially, it can take 12-24 hours before the export runs. 但是,資料可能需要更久才會出現在匯出檔案中。However, it can take up longer before data is shown in exported files.

匯出排程Export schedule

排程的匯出會受您最初建立匯出時的時間和星期幾所影響。Scheduled exports are affected by the time and day of week of when you initially create the export. 當您建立排程的匯出時,匯出會針對稍後執行的每個匯出以相同的頻率執行。When you create a scheduled export, the export runs at the same frequency for each export that runs later. 例如,頻率設定為每日的當月迄今成本每日匯出,就會在每一天執行匯出。For example, for a daily export of month-to-date costs export set at a daily frequency, the export runs daily. 同樣地,如果是每週匯出,就會在每週已排定的同一天執行匯出。Similarly for a weekly export, the export runs every week on the same day as it is scheduled. 匯出的確切發生時間無法保證,但匯出的資料可在執行匯出後四小時內取得。The exact delivery time of the export is not guaranteed and the exported data is available within four hours of run time.

每次匯出都會建立一個新檔案,因此不會覆寫較舊的匯出。Each export creates a new file, so older exports aren't overwritten.

建立多個訂用帳戶的匯出Create an export for multiple subscriptions

如果您有 Enterprise 合約,則可以使用管理群組,將訂用帳戶成本資訊彙總在單一容器中。If you have an Enterprise Agreement, then you can use a management group to aggregate subscription cost information in a single container. 接著,您可以匯出管理群組的成本管理資料。Then you can export cost management data for the management group.

不支援其他訂用帳戶類型的管理群組匯出。Exports for management groups of other subscription types aren't supported.

  1. 如果您尚未建立管理群組,請建立一個群組,並為其指派訂用帳戶。If you haven't already created a management group, create one group and assign subscriptions to it.
  2. 在成本分析中,將範圍設定為您的管理群組,然後選取 [選取此管理群組]。In cost analysis, set the scope to your management group and select Select this management group. 顯示選取此管理群組選項的範例
  3. 在範圍建立匯出,以取得管理群組中訂用帳戶的成本管理資料。Create an export at the scope to get cost management data for the subscriptions in the management group. 顯示 [建立新的匯出] 選項與管理群組範圍的範例

大型資料集的檔案分割File partitioning for large datasets

如果您有 Microsoft 客戶合約或 Microsoft 合作夥伴合約,您可以啟用匯出將檔案分成多個較小的檔案分割區,以協助進行資料內嵌。If you have a Microsoft Customer Agreement or a Microsoft Partner Agreement, you can enable Exports to chunk your file into multiple smaller file partitions to help with data ingestion. 當您一開始設定匯出時,請將 [檔案 分割 ] 設定設為 [ 開啟]。When you initially configure your export, set the File Partitioning setting to On. 此設定預設為 關閉The setting is Off by default.

顯示 [檔案分割] 選項的螢幕擷取畫面。

更新現有的匯出以使用檔案分割Update existing exports to use file partitioning

如果您有現有的匯出,而您想要設定檔案分割,請建立新的匯出。If you have existing exports and you want to set up file partitioning, create a new export. 只有最新的匯出版本才能使用檔案分割。File partitioning is only available with the latest Exports version. 所建立之使用方式檔案中的某些欄位可能會有微小的變更。There may be minor changes to some of the fields in the usage files that get created.

如果您在現有的匯出上啟用檔案磁碟分割,您可能會在檔案輸出中看到欄位的微小變更。If you enable file partitioning on an existing export, you may see minor changes to the fields in file output. 任何變更都是因為在您初次設定之後,對匯出所做的更新所造成。Any changes are due to updates that were made to Exports after you initially set yours up.

分割輸出Partitioning output

啟用檔案分割之後,您會在匯出中取得每個資料分割的檔案,以及檔案上的 _manifest.js。When file partitioning is enabled, you get a file for each partition of data in the export along with a _manifest.json file. 資訊清單包含完整資料集的摘要,以及其中每個檔案分割區的資訊。The manifest contains a summary of the full dataset and information for each file partition in it. 每個檔案分割區都有標頭,而且只包含完整資料集的子集。Each file partition has headers and contains only a subset of the full dataset. 若要處理完整的資料集,您必須內嵌匯出的每個資料分割。To handle the full dataset, you must ingest each partition of the export.

以下是範例資訊清單檔的 _manifest.js。Here's a _manifest.json example manifest file.

  "manifestVersion": "2021-01-01",
  "dataFormat": "csv",
  "blobCount": 1,
  "byteCount": 160769,
  "dataRowCount": 136,
  "blobs": [
      "blobName": "blobName.csv",
      "byteCount": 160769,
      "dataRowCount": 136,
      "headerRowCount": 1,
      "contentMD5": "md5Hash"

驗證已收集資料Verify that data is collected

您可以輕鬆驗證您的成本管理資料已收集完成,並使用 Azure 儲存體總管檢視匯出的 CSV 檔案。You can easily verify that your Cost Management data is being collected and view the exported CSV file using Azure Storage Explorer.

在匯出清單中,選取儲存體帳戶名稱。In the export list, select the storage account name. 在儲存體帳戶頁面上,選取 [在總管中開啟]。On the storage account page, select Open in Explorer. 若您看見確認方塊,請選取 [是] 以在 Azure 儲存體總管中開啟檔案。If you see a confirmation box, select Yes to open the file in Azure Storage Explorer.

顯示範例資訊和 [在總管中開啟] 連結的儲存體帳戶頁面

在 [儲存體總管] 中,巡覽至您想要開啟的容器,然後選取對應到目前月份的資料夾。In Storage Explorer, navigate to the container that you want to open and select the folder corresponding to the current month. 隨即顯示 CSV 檔案清單。A list of CSV files is shown. 選取其中一個,然後選取 [開啟]。Select one and then select Open.

[儲存體總管] 中顯示的範例訊息

檔案隨即便會使用設為開啟 CSV 檔案副檔名的程式或應用程式開啟。The file opens with the program or application that's set to open CSV file extensions. 以下是 Excel 中的範例。Here's an example in Excel.

Excel 中顯示的範例匯出 CSV 資料

下載匯出的 CSV 資料檔案Download an exported CSV data file

您也可以在 Azure 入口網站中下載匯出的 CSV 檔案。You can also download the exported CSV file in the Azure portal. 下列步驟說明如何從成本分析尋找它。The following steps explain how to find it from cost analysis.

  1. 在 [成本分析] 中,選取 [設定],然後選取 [匯出]。In cost analysis, select Settings, and then select Exports.
  2. 在匯出清單中,選取用於匯出的儲存體帳戶。In the list of exports, select the storage account for an export.
  3. 在您的儲存體帳戶中,選取 [容器]。In your storage account, select Containers.
  4. 在容器清單中,選取容器。In list of containers, select the container.
  5. 瀏覽目錄和儲存體 Blob,前往您想要的日期。Navigate through the directories and storage blobs to the date you want.
  6. 選取 CSV 檔案,然後選取 [下載]。Select the CSV file and then select Download.

匯出下載範例Example export download

檢視匯出執行歷程記錄View export run history

您可以在匯出清單頁面中選取個別的匯出,以檢視排程匯出的執行歷程記錄。You can view the run history of your scheduled export by selecting an individual export in the exports list page. 匯出清單頁面也可讓您快速存取,以檢視先前匯出的執行時間,以及下一次執行匯出的時間。The exports list page also provides you with quick access to view the run time of your previous exports and the next time and export will run. 以下是顯示執行歷程記錄的範例。Here's an example showing the run history.

顯示 [匯出] 窗格的螢幕擷取畫面。

選取匯出以檢視其執行歷程記錄。Select an export to view its run history.


從其他系統存取匯出資料Access exported data from other systems

匯出成本管理資料的其中一個目的是從外部系統存取資料。One of the purposes of exporting your Cost Management data is to access the data from external systems. 您可能會使用儀表板系統或其他財務系統。You might use a dashboard system or other financial system. 這類系統之間的差異相當大,因此顯示範例並不實用。Such systems vary widely so showing an example wouldn't be practical. 但是,您可以從 Azure 儲存體簡介中應用程式存取您的資料開始。However, you can get started with accessing your data from your applications at Introduction to Azure Storage.

後續步驟Next steps

在本教學課程中,您已了解如何:In this tutorial, you learned how to:

  • 建立每日匯出Create a daily export
  • 驗證已收集資料Verify that data is collected

前進到下一個教學課程,透過識別閒置及使用量過低的資源來最佳化和改善效率。Advance to the next tutorial to optimize and improve efficiency by identifying idle and underutilized resources.