Azure EA Billing Data Export to CSV

Powershell script to download Azure EA billing data to CSV.This uses the new API downloading data from the new URL https://consumption.azure.com/v3/enrollmentsCredit goes to the script based on the old API found at http://www.redbaronofazure.com/?p=631Requres 5 mandatory paramete

 
 
 
 
 
5 Star
(1)
668 times
Add to favorites
Windows Azure
1/16/2019
E-mail Twitter del.icio.us Digg Facebook
  • Getting Errors
    2 Posts | Last post October 29, 2019
    • Thanks for the script and getting below errors when executing it.
      ==============================================================
      Exception calling "Parse" with "1" argument(s): "String was not recognized as a valid DateTime."
      At line:88 char:2
      +     $csvAll[$i].Date = [datetime]::Parse($csvAll[$i].Date).ToString(" ...
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : FormatException
       
      Exception setting "Cost": "The property 'Cost' cannot be found on this object. Verify that the property exists and can be set."
      At line:89 char:2
      +     $csvAll[$i].Cost = [float]$csvAll[$i].Cost
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : ExceptionWhenSetting
       
      Exception setting "ResourceRate": "The property 'ResourceRate' cannot be found on this object. Verify that the property exists and 
      can be set."
      At line:90 char:2
      +     $csvAll[$i].ResourceRate = [float]$csvAll[$i].ResourceRate
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : ExceptionWhenSetting
       
      Exception setting "ConsumedQuantity": "The property 'ConsumedQuantity' cannot be found on this object. Verify that the property 
      exists and can be set."
      At line:91 char:2
      +     $csvAll[$i].ConsumedQuantity = [float]$csvAll[$i].ConsumedQuantit ...
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : ExceptionWhenSetting
       
      
    • Hi,
      Apologies, I don't have access to an Azure EA subscription any more so can't check it still works I'm afraid. It doesn't sound like your getting the correct data back though. If you add "$csvall | Select -first 1" (without the quotes) to line 67 it will show on screen the first record of data returned though and hopefully help you diagnose the problem.
      If you post this back (less any potentially confidential data of course) I may be able to help further though!
      
  • Geeting error
    1 Posts | Last post October 22, 2019
    • Thanks for the Script and I an getting below errors when I execute it.Can you please assist me on this to fix the issues. Thanks again.
      Exception calling "Parse" with "1" argument(s): "String was not recognized as a valid DateTime."
      At line:88 char:2
      +     $csvAll[$i].Date = [datetime]::Parse($csvAll[$i].Date).ToString(" ...
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : FormatException
       
      Exception setting "Cost": "The property 'Cost' cannot be found on this object. Verify that the property exists and can be set."
      At line:89 char:2
      +     $csvAll[$i].Cost = [float]$csvAll[$i].Cost
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : ExceptionWhenSetting
       
      Exception setting "ResourceRate": "The property 'ResourceRate' cannot be found on this object. Verify that the property exists and 
      can be set."
      At line:90 char:2
      +     $csvAll[$i].ResourceRate = [float]$csvAll[$i].ResourceRate
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : ExceptionWhenSetting
       
      Exception setting "ConsumedQuantity": "The property 'ConsumedQuantity' cannot be found on this object. Verify that the property 
      exists and can be set."
      At line:91 char:2
      +     $csvAll[$i].ConsumedQuantity = [float]$csvAll[$i].ConsumedQuantit ...
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : ExceptionWhenSetting
       
      
  • Thanks!
    2 Posts | Last post February 02, 2019
    • Very useful!
    • Thanks Dave!