Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CostManagementClient does not return tags associated with resource groups #36366

Open
ash-dey-sa opened this issue Jul 5, 2024 · 7 comments
Open
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@ash-dey-sa
Copy link

  • Package Name: - azure-mgmt-costmanagement
  • Package Version: 4.0.1
  • Operating System: Linux
  • Python Version: 3.11.2

Describe the bug
CostManagementClient does not return tags associated with resource groups

To Reproduce
Steps to reproduce the behavior:

  1. Run CostManagementClient with the following query.
{
   "type":"ActualCost",
   "dataSet":{

       "aggregation":{
         "consumedquantities":{
            "name":"UsageQuantity",
            "function":"Sum"
         },
         "totalCostUSD":{
            "name":"PreTaxCostUSD",
            "function":"Sum"
         }
      },
      "granularity":"none",
      "grouping":[
         {
            "type":"Dimension",
            "name":"ResourceGroupName"
         },
         {
            "type":"Dimension",
            "name":"SubscriptionName"
         }
      ],
      "include":[
         "Tags"
      ]
   },
   "timeframe":"Custom",
   "timePeriod":{
      "from":"from_time",
      "to":"to_time"
   }
}

The type column output I get

'columns': [<azure.mgmt.costmanagement.models._models_py3.QueryColumn object at 0x7f757ca238d0>, <azure.mgmt.costmanagement.models._models_py3.QueryColumn object at 0x7f757ca23950>, <azure.mgmt.costmanagement.models._models_py3.QueryColumn object at 0x7f757ca23990>, <azure.mgmt.costmanagement.models._models_py3.QueryColumn object at 0x7f757ca239d0>, <azure.mgmt.costmanagement.models._models_py3.QueryColumn object at 0x7f757ca23a10>]

Expected behavior
The column output should be as per below (which can be validated from API play ground in Azure portal by running the same query with latest API version i.e. "2023-11-01"). the scope /subscriptions/{subscription_id}/providers/Microsoft.CostManagement/query?api-version=2023-11-01


 "columns": [
      {
        "name": "UsageQuantity",
        "type": "Number"
      },
      {
        "name": "PreTaxCostUSD",
        "type": "Number"
      },
      {
        "name": "ResourceGroupName",
        "type": "String"
      },
      {
        "name": "SubscriptionName",
        "type": "String"
      },
      {
        "name": "Tags",
        "type": "Array"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ]

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Tried to run the cost management client by specifying the latest version of API, but still does not work.
cost_management_client = CostManagementClient(credential=cost_credential, api_version="2023-11-01")

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jul 5, 2024
@pvaneck pvaneck added Service Attention This issue is responsible by Azure service team. Mgmt This issue is related to a management-plane library. labels Jul 5, 2024
@github-actions github-actions bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jul 5, 2024
@pvaneck
Copy link
Member

pvaneck commented Jul 5, 2024

Hey, thanks for the issue. Seems like you are getting Python objects QueryColumn which have the name and type properties when you expect the JSON/dict representation of it (i.e. the Python object deserialized) in the response?

@msyyc Is this expected?

@ash-dey-sa
Copy link
Author

ash-dey-sa commented Jul 8, 2024

@pvaneck, the primary problem due to the bug is the JSON output returned by the query is missing all the tags for the resource groups. Other information seems to be returned as expected i.e. resource group name, subscription name, costs etc. Expected out put should include an array of each resource group tags along with other values specified above.

@msyyc
Copy link
Member

msyyc commented Jul 8, 2024

@ChenxiJiang333 Please help on this issue

@ChenxiJiang333
Copy link
Member

got it

@ChenxiJiang333
Copy link
Member

Hi @ash-dey-sa, the issue occurs because the model QueryDataset does not have the property include, which caused serialization bug to build the correct request body. And since SDKs is auto generated by swagger definitions, I have opened issue Azure/azure-rest-api-specs#29719 to request an update for the swagger. Once the swagger is updated, python would release a new version to fix the issue.

@ash-dey-sa
Copy link
Author

Look forward to the bug fix. Thank you for your help.

@ChenxiJiang333
Copy link
Member

Hope we can have a quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants