I am trying to calculate the Azure usage cost in python by getting response from url API with importing urllib3.
But I am not getting full data in the response. Partial data is coming. My requirement is to get this data day wise and have to send a mail for 5 days with comparison. I am able to get this in powershell, but not in Pyhton.
Here is the code I am using:
import requests
import datetime
import json
import logging
import urllib3
import csv
#logging.raiseExceptions=False
Enrollmentnbr = 'xxxx'
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
month= datetime.date.today().strftime('%Y-%m')
urlbase = 'https://ea.azure.com/rest/'
#authHeaders = {'Authorization': 'Bearer ' + key}
url= urlbase + Enrollmentnbr + "/usage-report?month="+month+"&type=detail"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36',
'Authorization': 'Bearer {0}'.format(key)}
http = urllib3.PoolManager()
response = http.request('GET', url=url,headers=headers)