Home > Enterprise >  How to make an azure cost management export run daily and only export that day or previous days data
How to make an azure cost management export run daily and only export that day or previous days data

Time:02-03

Taking the Terraform resource example:

resource "azurerm_billing_account_cost_management_export" "example" {
  name                         = "example"
  billing_account_id           = "example"
  recurrence_type              = "Daily"
  recurrence_period_start_date = "2020-08-18T00:00:00Z"
  recurrence_period_end_date   = "2020-09-18T00:00:00Z"

  export_data_storage_location {
    container_id     = azurerm_storage_container.example.resource_manager_id
    root_folder_path = "/root/updated"
  }

  export_data_options {
    type       = "Usage"
    time_frame = "Custom"
  }
}

The documentation isn't very clear what time_frame = "Custom" does and what else to add here?, I would like to create an export that runs daily however it only exports that day or maybe the previous days worth of data not month-to-date being the closest to this. As i do not want all of the other days data on that export. Is Setting the time_frame to custom allow me to do this? Will i have to set a start_date and end_date? and if so can i then run an update request daily potentially to change the days in a script someway as an alternative option

Tried creating a day-to-month export however the file is too large and comes with unwanted data as the end of the month comes along

CodePudding user response:

Is Setting the time_frame to custom allow me to do this?

Yes, we can do this via json api.
enter image description here

Terraform provider it self not supporting this option. Refer below screenshots.

I have replicated the ways using terraform, no luck. Using terraform we have only below custom options. time_frame only allows below mentioned parameters. enter image description here

Possible values include: WeekToDate, MonthToDate, BillingMonthToDate, TheLastWeek, TheLastMonth, TheLastBillingMonth, Custom.

seems the respective custom parameters are specific to Month. we can use like

time_frame  =  "TheLastMonth"

enter image description here

CodePudding user response:

I would suggest you to use the Azure Cost Management connector in Power BI Desktop , upload that on Power BI and set a daily refresh.

You can then query the Datamart like a database daily.

  • Related