azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Commerce: Rate Card "meter_sub_category" output format has changed!

Open ttruong-a10 opened this issue 8 years ago • 13 comments

Was wondering why my code for outputting VM price started failing. Found out the "meter_sub_category" for the Rate Card meter object has changed. For instance D8v3 use to have output:

Standard_D8_v3 VM

Now it outputs

Dv3/DSv3 Series

This is problematic because compute_client.virtual_machine_sizes.list() gives the first format (Standard_D8_v3)

What an easy way to match up VM Size with the Rate card pricing?

ttruong-a10 avatar Aug 20 '18 19:08 ttruong-a10

@yugangw-msft have you encountered this?

annatisch avatar Aug 23 '18 23:08 annatisch

Wrong service - adding Commerce. Sorry @yugangw-msft - as you were :)

annatisch avatar Aug 27 '18 16:08 annatisch

Hi @ttruong7 Could you confirm that you used the same package, and suddenly your code has stopped working? This would mean the RestAPI changed suddenly one day, and I would route this problem differently. Thanks!

lmazuel avatar Aug 28 '18 20:08 lmazuel

Hi @lmazuel

Yes the package version is still the same and hasn't be changed. Version: azure-mgmt-commerce==1.0.1. Code used to grab rates:

OfferDurableID = 'MS-AZR-0003P'   # Pay-as-you-go
rate = commerce_client.rate_card.get(
    "OfferDurableId eq '{}' and Currency eq 'USD' \
     and Locale eq 'en-US' and RegionInfo eq 'US'".format(OfferDurableID) 
)


rate_filtered = list(filter(lambda x:  x.meter_region == 'US West' and x.meter_category == 'Virtual Machines',
                       rate.meters))

for r in rate_filtered:
    print(r)`

# Example Output
'''
{'additional_properties': {}, 'meter_id': '878ae2c5-f13d-4c83-9af2-7b333b1c9fa1', 'meter_name': 'D16 v3/D16s v3', 'meter_category': 'Virtual Machines', 'meter_sub_category': 'Dv3/DSv3 Series', 'unit': '1 Hour', 'meter_tags': [], 'meter_region': 'US West', 'meter_rates': {'0': 0.936}, 'effective_date': datetime.datetime(2017, 7, 21, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x7f5e3648cdd8>), 'included_quantity': 0.0}

'''
### 
## Here, meter_sub_category use to output:   Standard_D16_v3 VM
###

ttruong-a10 avatar Aug 29 '18 18:08 ttruong-a10

I'm also getting this issue. This feature is very important to our customers for us to predict rates on VMs. In the past month or so the rate card meters started returning different sub categories that broke our code. I need to be able to map VM sizes to meters, but I don't see a consistent pattern between the naming conventions. For example, 'Basic_A0' VM size is equivalent to the 'A Series Basic' sub_category in meters, but 'Standard_A0' is just the 'A0' sub_category, but 'Standard_DS2_v3' is also very different. Is there an easy way to map the VM sizes to meters?

gsimore avatar Aug 31 '18 13:08 gsimore

@yugangw-msft for ideas?

lmazuel avatar Aug 31 '18 15:08 lmazuel

Adding to this. Why are region names in a different format than other Azure APIs? For instance, the region name when querying rate card gives 'meter_region': 'EU West'. For Compute API, region name is 'Europe West'. Similarly, 'Asia East' is 'AP East'. This mismatch in standards is rather aggravating.

ttruong-a10 avatar Sep 14 '18 22:09 ttruong-a10

I found this file: http://download.microsoft.com/download/4/6/4/464DEF8A-4D12-4956-9066-34750C84219F/AzureMeterMapping-en.xlsx available for mapping old naming conventions to new ones. Pretty hefty file to read from, but glad it exists.

gsimore avatar Sep 14 '18 22:09 gsimore

The region names are also rather aggravating to me.

gsimore avatar Sep 14 '18 22:09 gsimore

@gsimore Thanks for this!

ttruong-a10 avatar Sep 14 '18 22:09 ttruong-a10

np :)

gsimore avatar Sep 14 '18 23:09 gsimore

@ttruong-a10 Given latest azure-mgmt-commerce is 6.0.0, could you help to check if this issue is stall valid?

Thank you.

xiangyan99 avatar May 20 '22 22:05 xiangyan99

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar May 28 '22 02:05 ghost