LoginSignup
3
2

More than 5 years have passed since last update.

Azureの料金情報をAPIで取得。

Posted at

Azureの料金情報をPython3で取得するコードのメモ。

ライブラリの「requests」が無かったらpipで入れる。

エンロールメント:EAコンソールの左上にでてる数字。
fmt:csvかJSONを指定。指定した形に応じてコンテントタイプを変更する必要がある。
セカンダリキー:AzureのEAコンソールで取得出来る長ったらしい方。

import requests

BASE_URL = 'https://ea.azure.com/rest/エンロールメント/usage-report?fmt=json'
AUTH_KEY = 'bearer ' + 'セカンダリキー'

headers = {
  'content-type'  : 'application/json',
  'authorization' : AUTH_KEY,
}

response = requests.get(
  BASE_URL,
  headers=headers,
)
print(response.text)
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2