python-3.x - 来自 azure.storage.blob 的 python 方法 get_service_stats 的问题
问题描述
我在使用 get_service_stats 方法时遇到了这个问题:
azure.core.exceptions.ServiceRequestError:<urllib3.connection.VerifiedHTTPSConnection 对象位于 0x7f6e32d5d240>:无法建立新连接:[Errno -2] 名称或服务未知
方法:
def geo(self):
# Create a logger for the 'azure.storage.blob' SDK
logger = logging.getLogger('azure.storage.blob')
logger.setLevel(logging.DEBUG)
# Configure a console output
handler = logging.StreamHandler(stream=sys.stdout)
logger.addHandler(handler)
bloba = BlobServiceClient.from_connection_string(self.access,logging_enable=True)
acc = bloba.get_service_stats(logging_enable=True)
我可以使用一个对象(例如 bloba)在存储中连接、上传和下载。我将存储设置为 GRS(地理复制),但我需要获取地理复制的状态(实时、无效等)
记录:
# python3 main.py
Connected to Storage Account!
Request URL: 'https://rpaivatesting123-secondary.blob.core.windows.net/?restype=service&comp=stats'
Request method: 'GET'
Request headers:
'Accept': 'application/xml'
'x-ms-version': '2019-12-12'
'x-ms-date': 'Wed, 11 Nov 2020 21:09:52 GMT'
'x-ms-client-request-id': '3d73d876-2462-11eb-a223-7cb27d33114d'
'User-Agent': 'azsdk-python-storage-blob/12.5.0 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic)'
'Authorization': '*****'
Request body:
None
Request URL: 'https://rpaivatesting123-secondary.blob.core.windows.net/?restype=service&comp=stats'
Request method: 'GET'
Request headers:
'Accept': 'application/xml'
'x-ms-version': '2019-12-12'
'x-ms-date': 'Wed, 11 Nov 2020 21:09:52 GMT'
'x-ms-client-request-id': '3d73d876-2462-11eb-a223-7cb27d33114d'
'User-Agent': 'azsdk-python-storage-blob/12.5.0 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic)'
'Authorization': '*****'
Request body:
None
降级 sdk :
Request body:
None
Tuple timeout setting is deprecated
Traceback (most recent call last):
File "main.py", line 16, in <module>
health_check.geo()
File "/root/sarah/DR/devops-toolbox/azure-storage-health-check/scripts/azure_storage_operations.py", line 113, in geo
acc = bloba.get_service_stats(logging_enable=True)
File "/usr/local/lib/python3.6/dist-packages/azure/core/tracing/decorator.py", line 83, in wrapper_use_tracer
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/azure/storage/blob/_blob_service_client.py", line 257, in get_service_stats
timeout=timeout, use_location=LocationMode.SECONDARY, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/azure/storage/blob/_generated/operations/_service_operations.py", line 229, in get_statistics
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 211, in run
return first_node.send(pipeline_request) # type: ignore
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
[Previous line repeated 5 more times]
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/policies/_redirect.py", line 157, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/storage/blob/_shared/policies.py", line 543, in send
raise err
File "/usr/local/lib/python3.6/dist-packages/azure/storage/blob/_shared/policies.py", line 517, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/storage/blob/_shared/policies.py", line 318, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
response = self.next.send(request)
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 103, in send
self._sender.send(request.http_request, **request.context.options),
File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/transport/_requests_basic.py", line 284, in send
raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f11404867b8>: Failed to establish a new connection: [Errno -2] Name or service not known
解决方案
推荐阅读
- regex - 外壳 || 大文件中的模式匹配并打印附近的行
- ruby - 在一个示例中分配的值不会被带到另一个示例中
- angularjs - Ag-grid 分页定制
- c# - 具有多个左连接的 Linq 查询生成很少的查询
- excel - 从搜索结果中保留所选行并使用 Excel VBA 或 Excel 公式删除其他行
- c# - 使用 AsyncOperation.progress 加载场景从 01f 跳转到 0.9f
- python - 如何为机器学习有意义地替换 Nan 值
- jquery - 我想使用 jquery 更改语言 url
- c++ - 如何在 boost::beast 上保持 websocket?
- javascript - 根据另一组元素的类别不断隐藏不同的元素