@Madugula Jahnavi Yes I have tried the API and below are my observations.
- According to the documentation, if I specify the TYPE as 'ActualCost', the API fails with the error "Request properties validation failed: Invalid definition type \u0027ActualCost\u0027; valid values: \u0027Usage\u0027".
The API works when I specify the Type as 'Usage'.
- The documentation shows an example for exporting data at the billing account scope, however I am trying the export at the Subscription level (my code given below)
- Specifying the time duration older than 12 months exports an empty CSV file. Exporting data for Dec 2024 exports the data however NOT in FOCUS format
Seems we are going round in circles. Can you help with the following
- How do I export data in FOCUS format using API ?
- How do I export data both - newer and older than 12 Months using API ?
"Usually, the exported CSV files will always bind to the FOCUS schema,"
Please help with the pointers on how to achieve this.
Below is the request I tried which failed to export any data. Changing the 'timeperiod' to Dec 2024 worked.
Create and export
-----------------------
$Url = "https://management.azure.com/subscriptions/<subscriptionID>/providers/Microsoft.CostManagement/exports/exportwithapi?api-version=2021-10-01"
$body = @'
{
"properties": {
"definition": {
"dataset": {
"granularity": "Daily",
"grouping": []
},
"timePeriod": {
"from": "2023-12-01T00:00:00.000Z",
"to": "2023-12-30T00:00:00.000Z"
},
"timeframe": "Custom",
"type": "ActualCost"
},
"deliveryInfo": {
"destination": {
"container": "cost",
"rootFolderPath": "apicostexport",
"resourceId": "/subscriptions/<SubscriptionID>/resourceGroups/Test/providers/Microsoft.Storage/storageAccounts/<stgaccountname>"
}
},
"format": "Csv",
"partitionData": false
}
}
'@
--------------------
RUN the EXPORT
--------------------
$Url = "https://management.azure.com/subscriptions/<subscriptionID>/providers/Microsoft.CostManagement/exports/exportwithapi/run?api-version=2021-10-01"
$body = @'
{
"properties": {
"definition": {
"dataset": {
"granularity": "Daily",
"grouping": []
},
"timePeriod": {
"from": "2022-12-01T00:00:00.000Z",
"to": "2022-12-30T00:00:00.000Z"
},
"timeframe": "Custom",
"type": "Usage"
},
"deliveryInfo": {
"destination": {
"container": "cost",
"rootFolderPath": "apicostexport",
"resourceId": "/subscriptions/<subscriptionID>/resourceGroups/Test/providers/Microsoft.Storage/storageAccounts/<stgaccountname>"
}
},
"format": "Csv",
"partitionData": false
}
}
'@