azure savings plan utillization using python

Anurag singh kuhswaha 21 Reputation points
2022-12-23T07:04:23.417+00:00

I am using below trying to pull azure savings plan utilization data but I am getting error

AttributeError: 'CostManagementClient' object has no attribute 'benefit_utilization_summaries'  


 

  from azure.identity import DefaultAzureCredential  
from azure.mgmt.costmanagement import CostManagementClient  
from azure.identity import ClientSecretCredential  
from azure.mgmt.compute import ComputeManagementClient  
  
     credential = ClientSecretCredential(  
        tenant_id='',  
        client_id= '',  
        client_secret= ''  
        )  
          
        client = CostManagementClient(  
            credential=credential  
              
        )  
          
        response = client.benefit_utilization_summaries.list_by_billing_account_id(  
            billing_account_id="",  
        )  
        for item in response:  
            print(item)  

I am referring below azure documentation. can you guide me how what i am doing wrong and how can i fix it.

https://learn.microsoft.com/en-in/rest/api/cost-management/benefit-utilization-summaries/list-by-billing-account-id?tabs=Python#savingsplanutilizationsummaries-billingaccount

Azure Cost Management
Azure Cost Management
An Azure service that provides cloud cost management capabilities.
981 questions
{count} votes

Accepted answer
  1. Swathi Dhanwada 9,386 Reputation points Microsoft Employee
    2022-12-27T06:02:16.493+00:00

    @Anurag singh kuhswaha azure-mgmt-costmanagement 3.0.0 doesn't have the operation benefit_utilization_summaries . This operation is recently added in the version azure-mgmt-costmanagement 4.0.0b1 which is currently in pre-release state.

    Operations within azure-mgmt-costmanagement 3.0.0

    274128-image.png

    Operations within azure-mgmt-costmanagement 4.0.0b1

    274137-image.png

    You can update the package using below command

    pip install azure-mgmt-costmanagement==4.0.0b1  
    
    No comments

0 additional answers

Sort by: Most helpful