Consumption examples
Can you add some examples to Azure Consumption libraries for python documentation?
@dejan-shuki thanks for reporting this - I am routing this to the right team for review
any updates?
@nickzhums can you take a look at this?
@kaerm
Find below.
# various credentials options (flexible programming)
import azure.common.credentials as credential_options
import os
# TODO: add MSI / ADAL / CLI options
azure_credential = credential_options.UserPassCredentials(os.environ["AZURE_USERNAME"],os.environ["AZURE_PASSWORD"])
# azure_credential = credential_options.ServicePrincipalCredentials(os.environ["AZURE_CLIENT_ID"],os.environ["AZURE_CLIENT_SECRET"])
#grab subscription (currently an environmental variable)
azure_subscription = os.environ["AZURE_SUBSCRIPTION_ID"]
print(f"Azure Credential Object created. Details: {azure_credential}")
print(f"Working on Subscription ID {azure_subscription}")
from azure.mgmt.consumption.consumption_management_client import ConsumptionManagementClient
consumption_client = ConsumptionManagementClient(azure_credential,azure_subscription)
print(f"Created Consumption Client Utilisng API Version {consumption_client.api_version} \r\n\r\n")
# Price Sheet Operations Object
# Methods: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-consumption/3.0.0/azure.mgmt.consumption.operations.html
price_sheet_client = consumption_client.price_sheet
print(f"Using Price Sheet Operations --- API Version: {price_sheet_client.api_version}")
# get pricesheets using the get() method This method take paramters.
# review options https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-consumption/3.0.0/azure.mgmt.consumption.operations.html
price_sheet_results = price_sheet_client.get()
for price_sheet in price_sheet_results.pricesheets:
print(price_sheet)
print("\r\n")

@dejan-shuki any specific use case you are looking for?
Please see this example https://github.com/ms-premp/AzureConsumptionSamples/blob/master/Python_sdk/usage_details_list_python_sdk_example.py
closing as per Prem's inputs.