Jaa


New-FinOpsCostExport command

The New-FinOpsCostExport command creates a new Cost Management export for the specified scope.

This command was tested with the following API versions:

  • 2023-07-01-preview (default) – Enables FocusCost and other datasets.
  • 2023-08-01

Syntax

# Create a new daily/monthly export
New-FinOpsCostExport `
    [-Name] <string> `
    -Scope <string> `
    [-Dataset <string>] `
    [-DatasetVersion <string>] `
    [-DatasetFilters <hashtable>] `
    [-Monthly] `
    [-StartDate <DateTime>] `
    [-EndDate <DateTime>] `
    -StorageAccountId <string> `
    [-StorageContainer <string>] `
    [-StoragePath <string>] `
    [-Location] `
    [-DoNotPartition] `
    [-DoNotOverwrite] `
    [-Execute] `
    [-Backfill <int>] `
    [-ApiVersion <string>]
# Create a new one-time export
New-FinOpsCostExport `
    [-Name] <string> `
    -Scope <string> `
    [-Dataset <string>] `
    [-DatasetVersion <string>] `
    [-DatasetFilters <hashtable>] `
    -OneTime `
    -StartDate <DateTime> `
    -EndDate <DateTime> `
    -StorageAccountId <string> `
    [-StorageContainer <string>] `
    [-StoragePath <string>] `
    [-Location] `
    [-DoNotPartition] `
    [-ApiVersion <string>]

Parameters

Name Description
‑Name Required. Name of the export.
‑Scope Required. Resource ID of the scope to export data for.
‑Dataset Optional. Dataset to export. Allowed values = "ActualCost", "AmortizedCost". Default = "ActualCost".
‑DatasetVersion Optional. Schema version of the dataset to export. Default = (latest version as of June 2024; for example, "1.0" for FocusCost).
‑DatasetFilters Optional. Dictionary of key/value pairs to filter the dataset with. Only applies to ReservationRecommendations dataset in 2023-07-01-preview. Valid filters are reservationScope (Shared or Single), resourceType (for example, VirtualMachines), lookBackPeriod (Last7Days, Last30Days, Last60Days).
‑Monthly Optional. Indicates that the export should be executed monthly (instead of daily). Default = false.
‑OneTime Optional. Indicates that the export should only be executed once. When set, the start/end dates are the dates to query data for. Can't be used with the -Monthly option.
‑StartDate Optional. Day to start running exports. Default = First day of the previous month if -OneTime is set; otherwise, tomorrow (DateTime.Now.AddDays(1)).
‑EndDate Optional. Last day to run the export. Default = Last day of the month identified in -StartDate if -OneTime is set; otherwise, five years from -StartDate.
‑StorageAccountId Required. Resource ID of the storage account to export data to.
‑StorageContainer Optional. Name of the container to export data to. Container is created if it doesn't exist. Default = "cost-management".
‑StoragePath Optional. Path to export data to within the storage container. Default = (scope ID).
‑Location Optional. Indicates the Azure location to use for the managed identity used to push data to the storage account. Managed identity is required in order to work with storage accounts behind a firewall but require access to grant permissions (for example, Owner). If specified, managed identity is used; otherwise, managed identity isn't used and your export doesn't push data to a storage account behind a firewall. Default = (empty).
‑DoNotPartition Optional. Indicates whether to partition the exported data into multiple files. Partitioning is recommended for reliability so this option is to disable partitioning. Default = false.
‑DoNotOverwrite Optional. Indicates whether to overwrite previously exported data for the current month. Overwriting is recommended to keep storage size and costs down so this option is to disable overwriting. Default = false.
‑Execute Optional. Indicates that the export should be run immediately after created.
‑Backfill Optional. Number of months to export the data for. It only runs once at create time. Failed exports aren't reattempted. Not supported when -OneTime is set. Default = 0.
‑Execute Optional. Indicates that the export should be run immediately after created.
‑Backfill Optional. Number of months to export the data for. It only runs once at create time. Failed exports aren't reattempted. Not supported when -OneTime is set. Default = 0.
‑ApiVersion Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview.

Examples

Create one time export

New-FinopsCostExport -Name 'July2023OneTime' `
    -Scope "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e" `
    -StorageAccountId "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/SharedStorage/providers/Microsoft.Storage/storageAccounts/ddsharedstorage" `
    -DataSet ActualCost `
    -OneTime `
    -StartDate "2023-07-01" `
    -EndDate "2023-07-31"

Creates a new one time export called 'July2023OneTime' from 2023-07-01 to 2023-07-31 with Dataset = Actual and execute it once.

Create and run a daily export

New-FinopsCostExport -Name 'DailyMTD' `
    -Scope "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e" `
    -StorageAccountId "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/SharedStorage/providers/Microsoft.Storage/storageAccounts/ddsharedstorage" `
    -DataSet AmortizedCost `
    -EndDate "2024-12-31" `
    -Execute

Creates a new scheduled export called Daily-MTD with StartDate = DateTime.Now and EndDate = 2024-12-31. Export is run immediately after creation.

Create a monthly export

New-FinopsCostExport -Name 'Monthly-Report' `
    -Scope "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e" `
    -StorageAccountId "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/SharedStorage/providers/Microsoft.Storage/storageAccounts/ddsharedstorage" `
    -DataSet AmortizedCost `
    -StartDate $(Get-Date).AddDays(5) `
    -EndDate "2024-08-15" `
    -Monthly `
    -Execute

Creates a new monthly export called Monthly-Report with StartDate = 1 day from DateTime.Now and EndDate 2024-08-15. Export is run immediately after creation.

Create daily export and backfill four months

New-FinopsCostExport -Name 'Daily--MTD' `
    -Scope "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e" `
    -StorageAccountId "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/SharedStorage/providers/Microsoft.Storage/storageAccounts/ddsharedstorage" `
    -DataSet ActualCost `
    -StorageContainer "costreports" `
    -Backfill 4 `
    -Execute

Creates a new daily export called Daily-MTD with StartDate = DateTime.Now and EndDate 5 years from StartDate. Additionally, export cost data for the previous four months and save all results in costreports container of the specified storage account.


Related products:

Related solutions: