Last active
December 29, 2022 03:08
-
-
Save yuwtennis/174d1e37b3c76e7050e8644e0ea516e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUBSCRIPTION_ID: str = os.environ.get("SUBSCRIPTION_ID", None) | |
SCOPE: str =f'/subscriptions/{SUBSCRIPTION_ID}' | |
logging.basicConfig(filename='./az-sdk-consumption-api-8-0-0-b1.log', level=logging.DEBUG, force=True) | |
current_timestamp = datetime.datetime.now(datetime.timezone.utc).strftime("%c %") | |
print(f"Querying Microsoft REST API. Started on {current_timestamp}") | |
consumption_client = ConsumptionManagementClient( | |
credential=DefaultAzureCredential(), | |
subscription_id=SUBSCRIPTION_ID | |
) | |
result = consumption_client.usage_details.list( | |
SCOPE, | |
metric='AmortizedCost') | |
o = next(result) | |
attrs = [ | |
'billing_period_end_date', | |
'billing_period_start_date', | |
'date', | |
'exchange_rate_date', | |
'service_period_end_date', | |
'service_period_start_date' | |
] | |
for attr in attrs: | |
print(f"{attr}: {getattr(o, attr)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment