Costing Query Deserialization Wrong Property
jsmartt opened this issue · 1 comments
Library: azure_mgmt_cost_management
Version: 0.17.1 (latest)
Azure::CostManagement::Mgmt::Models::QueryResult (and likely other versions) are trying to deserialize a single value
property, which does not exist in the response, so the result is an object with a single data property (value) set to nil. The correct property name is properties
, not value
. See https://docs.microsoft.com/en-us/rest/api/cost-management/query/usage#examples
How to Reproduce the Issue:
# Client Setup
provider = MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret)
credentials = MsRest::TokenCredentials.new(provider)
client = Azure::CostManagement::Mgmt::V2019_01_01::CostManagementClient.new(credentials)
client.subscription_id = opts[:subscription_id] if client.respond_to?('subscription_id=')
# Costing Query
scope = "/subscriptions/#{client.subscription_id}"
query = Azure::CostManagement::Mgmt::V2019_01_01::Models::QueryDefinition.new.tap do |q|
q.type = 'ActualCost'
q.timeframe = 'WeekToDate'
q.timeframe = 'TheLastMonth'
q.dataset = Azure::CostManagement::Mgmt::V2019_01_01::Models::QueryDataset.new.tap do |ds|
ds.granularity = 'Daily'
ds.grouping = [
Azure::CostManagement::Mgmt::V2019_01_01::Models::QueryGrouping.new.tap do |grp|
grp.type = 'Dimension'
grp.name = 'ResourceGroup'
end
]
ds.aggregation = {}
ds.aggregation['totalCost'] = Azure::CostManagement::Mgmt::V2019_01_01::Models::QueryAggregation.new.tap do |ag|
ag.name = 'PreTaxCost'
ag.function = 'Sum'
end
end
end
result = client.query_operations.usage_by_scope(scope, query)
result.value # nil
Thank you for your interest in Azure SDKs. As detailed in this retirement announcement, this repo is no longer supported as of December 31st 2021. Please find the up-to-date list of languages and services supported with Azure SDKs here: https://aka.ms/azsdk