问题描述
我目前正在使用Microsoft Azure for Government。我创建了一个存储帐户并设置了"需要安全传输"在存储帐户上禁用。我创建了一个容器并将一个blob插入其中以进行测试。我尝试用
来使用这个简单的连接测试。
I am currently using Microsoft Azure for Government. I have created a storage account and set the "Secure Transfer Required" to Disabled on the storage account. I created a container and inserted one blob into it for testing purposes. I attempted to use this simple test for the connection.
block_blob_service = BlockBlobService(account_name='ACCOUNT_NAME', account_key='KEY')
generator = block_blob_service.list_blobs('CONTAINER_NAME')
for blob in generator:
print("\t Blob name: " + blob.name)
它创建了" block_blob_service"成功使用帐户名称和密钥,但是当从我创建的容器生成blob列表时,它会生成此错误。我正在使用Python 3.6运行python flask服务器
It creates the "block_blob_service" successfully using the account name and key, however when generating the list of blobs from the container I created it generates this error. I am running the python flask server using Python 3.6
Client-Request-ID = d6c841c4-3463-11e9-8bd6-0242ac11003b重试策略没有不允许重试:,HTTP状态代码=未知,异常= HTTPSConnectionPool(host ='globalviewstorage.blob.core.windows.net',port = 443):使用url:/ staff?restype = container& comp超出最大重试次数= list
(由NewConnectionError引起('< urllib3.connection.VerifiedHTTPSConnection对象位于0x7ff5bf239278>:无法建立新连接:[Errno -2]名称或服务未知',))。
Client-Request-ID=d6c841c4-3463-11e9-8bd6-0242ac11003b Retry policy did not allow for a retry: , HTTP status code=Unknown, Exception=HTTPSConnectionPool(host='globalviewstorage.blob.core.windows.net', port=443): Max retries exceeded with url: /staff?restype=container&comp=list (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff5bf239278>: Failed to establish a new connection: [Errno -2] Name or service not known',)).
推荐答案
您可以查看此以获取此示例:
You can check this repo for this example:
def list_blobs(container):
try:
global blob_list
content = block_blob_service.list_blobs(container)
print("******Blobs currently in the container:**********")
for blob in content:
blob_list.append(blob.name)
print(blob.name)
except:
print("The specified container does not exist, Please check the container name or if it exists.")
list_blobs(container)
这篇关于Azure存储Blob Python Flask名称或服务未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!