Repository navigation
Import CostExport
Loads Azure cost data from a Cost Management scheduled export held in a Storage Account.
Import-CostExport [-StorageAccountName] <String> [-ResourceGroupName] <String> [-ContainerName] <String>
[[-Prefix] <String>] [[-BillingMonth] <DateTime>] [[-PreviousMonths] <Int32>] [[-SparkLineSize] <Int32>]
[-Raw] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Azure Cost Management can be configured (in the Azure Portal, under Cost Management > Exports) to routinely write "Actual Cost" CSV exports to a Storage Account container. Import-CostExport reads the export file/s for a given billing month directly from that container, and aggregates them into the same object shape returned by Get-SubscriptionCost, so the result can be piped to Show-CostAnalysis or Export-CostData like any other cost data -- without needing to query the Consumption API at all.
Import-CostExport -StorageAccountName 'mycostexports' -ResourceGroupName 'rg-cost' -ContainerName 'costexports'
Loads cost data for the current billing month from the specified Storage Account container.
Import-CostExport -StorageAccountName 'mycostexports' -ResourceGroupName 'rg-cost' -ContainerName 'costexports' -BillingMonth 01/2024 -PreviousMonths 3
Loads cost data from October 2023 to January 2024 from the specified Storage Account container.
The name of the Storage Account the scheduled export writes to.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe name of the Resource Group containing the Storage Account.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe name of the blob container the scheduled export writes to.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAn optional blob name prefix (e.g. the export name) to scope the search, useful if the container holds more than one export.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe billing month to load cost data for, specified as a [datetime] object. You can specify just month/year, e.g 10/2023. If not specified uses the current date.
Type: DateTime
Parameter Sets: (All)
Aliases: Month
Required: False
Position: 5
Default value: (Get-Date)
Accept pipeline input: False
Accept wildcard characters: FalseThe number of previous billing months to load. Default: 0.
Type: Int32
Parameter Sets: (All)
Aliases: PrevMonths
Required: False
Position: 6
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseThe row height of sparklines to generate (requires PSparklines module). Default: 1.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: 1
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: Include the mapped export rows as a property on the returned object.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).