azure python sdk error urllib3.exceptions.MaxRetryError

Angel Khalkho 1 Reputation point
2020-11-06T04:41:11.787+00:00

I'm working with a python sdk for azure and it gives me an error sometimes, and works without the error the other times.

Can someone please help me out?
Im using a registered application and service principal and key to login to azure via python.

The complete error is :

Keyring cache token has failed: (1783, 'CredWrite', 'The stub received bad data')
Traceback (most recent call last):
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 734, in urlopen
body_pos=body_pos, **response_kw)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 734, in urlopen
body_pos=body_pos, **response_kw)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 734, in urlopen
body_pos=body_pos, **response_kw)
[Previous line repeated 1 more time]
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 714, in urlopen
retries = retries.increment(method, url, response=response, _pool=self)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/93cdebad-0d07-44a7-9361-d3352ab837c7/providers/Microsoft.Commerce/UsageAggregates?reportedStartTime=2020-10-16T00%3A00%3A00.000Z&reportedEndTime=2020-11-04T00%3A00%3A00.000Z&aggregationGranularity=Daily&api-version=2015-06-01-preview (Caused by ResponseError('too many 504 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\universal_http\requests.py", line 142, in send
**kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 507, in send
raise RetryError(e, request=request)
requests.exceptions.RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/93cdebad-0d07-44a7-9361-d3352ab837c7/providers/Microsoft.Commerce/UsageAggregates?reportedStartTime=2020-10-16T00%3A00%3A00.000Z&reportedEndTime=2020-11-04T00%3A00%3A00.000Z&aggregationGranularity=Daily&api-version=2015-06-01-preview (Caused by ResponseError('too many 504 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\username\Desktop\vm_create\get_vm_creation_details_script.py", line 169, in <module>
list_vms()
File "C:\Users\username\Desktop\vm_create\get_vm_creation_details_script.py", line 108, in list_vms
month_hrs = hrs_consumed(VM_NAME,month_start,yesterday)
File "C:\Users\username\Desktop\vm_create\get_vm_creation_details_script.py", line 46, in hrs_consumed
for item in aggregate_data:
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\paging.py", line 143, in next
self.advance_page()
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\paging.py", line 129, in advance_page
self._response = self._get_next(self.next_link)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\azure\mgmt\commerce\operations\usage_aggregates_operations.py", line 117, in internal_paging
request, header_parameters, stream=False, **operation_config)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\service_client.py", line 336, in send
pipeline_response = self.config.pipeline.run(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\pipeline__init__.py", line 197, in run
return first_node.send(pipeline_request, **kwargs) # type: ignore
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\pipeline__init__.py", line 150, in send
response = self.next.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\pipeline\requests.py", line 72, in send
return self.next.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\pipeline\requests.py", line 137, in send
return self.next.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\pipeline__init__.py", line 150, in send
response = self.next.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\pipeline\requests.py", line 193, in send
self.driver.send(request.http_request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\universal_http\requests.py", line 333, in send
return super(RequestsHTTPSender, self).send(request, **requests_kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\universal_http\requests.py", line 145, in send
raise_with_traceback(ClientRequestError, msg, err)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\exceptions.py", line 51, in raise_with_traceback
raise error.with_traceback(exc_traceback)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\msrest\universal_http\requests.py", line 142, in send
**kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 507, in send
raise RetryError(e, request=request)
msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/93cdebad-0d07-44a7-9361-d3352ab837c7/providers/Microsoft.Commerce/UsageAggregates?reportedStartTime=2020-10-16T00%3A00%3A00.000Z&reportedEndTime=2020-11-04T00%3A00%3A00.000Z&aggregationGranularity=Daily&api-version=2015-06-01-preview (Caused by ResponseError('too many 504 error responses'))

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,177 questions
{count} votes