azure-armrest icon indicating copy to clipboard operation
azure-armrest copied to clipboard

Get Subscription Usage cost (monthly)

Open kTipSSIoYv opened this issue 3 years ago • 8 comments

@Fryguy The Azure::Armrest::Billing::UsageService returns detail billing of each resources. Is there a way to get the total cost of all resources? I mean total cost of subscription for the defined period?

BILLING = Azure::Armrest::Billing::UsageService.new(conf)  
  
options = {:reportedStartTime => '2022-08-01T00:00:00Z', :reportedEndTime => '2022-08-02T00:00:00Z', :aggregationGranularity  => 'Daily', :ShowDetails => 'false'}

kTipSSIoYv avatar Aug 22 '22 01:08 kTipSSIoYv

Not sure - I don't really use the library or the azure API. Perhaps @djberg96 knows?

Fryguy avatar Aug 22 '22 17:08 Fryguy

I'm afraid I don't know, sorry.

djberg96 avatar Aug 23 '22 01:08 djberg96

@Fryguy @agrare Ruby doc shows that we can use azure_mgmt_consumption.

But I can't install that on the docker container. I get error. Is this already included or is there a way to install these?

I'm not sure why I can't install these. I could install aws-sdk fine on the container without issues.

sh-4.4# gem install azure_mgmt_consumption
Building native extensions. This could take a while...
ERROR:  Error installing azure_mgmt_consumption:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/gems/gems/unf_ext-0.0.8.2/ext/unf_ext
/usr/bin/ruby -I /usr/share/rubygems -r ./siteconf20220823-31870-17iu7iu.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /usr/local/share/gems/gems/unf_ext-0.0.8.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/unf_ext-0.0.8.2/gem_make.out


kTipSSIoYv avatar Aug 23 '22 13:08 kTipSSIoYv

Looks like azure_mgmt_consumption is a C extensions, and we don't have the C headers in the docker image (we do that at build time).

Fryguy avatar Aug 23 '22 16:08 Fryguy

Weird that it's a C extension. Looks like y'all need to wrap their consumption REST API: https://docs.microsoft.com/en-us/rest/api/consumption/

Though that only works for enterprise accounts I think.

djberg96 avatar Aug 25 '22 12:08 djberg96

I think that's the one that @kTipSSIoYv is suggesting (that article points to https://rubygems.org/gems/azure_mgmt_consumption)

Fryguy avatar Aug 31 '22 13:08 Fryguy

It is important to note that the azure_mgmt_* gems are deprecated and are not being updated so if we want to use consumption data I think we should hit the rest api directly as @djberg96 mentioned rather than trying to use azure_mgmt_consumption

agrare avatar Sep 02 '22 16:09 agrare

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

miq-bot avatar Feb 27 '23 00:02 miq-bot