检查blob是否在python azure中存在 [英] Checking if a blob exist in python azure

查看:57
本文介绍了检查blob是否在python azure中存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于azure-storage-blob的新更新,blockblobservice已弃用

Since the new update of azure-storage-blob, the blockblobservice is depreciated

如何检查blob是否存在?

How can I check that a blob exist ?

此答案不适用于新版本的azure-storage-blob 使用python进行快速Azure blob名称搜索?

This answer is not working with the new version of azure-storage-blob Faster Azure blob name search with python?

我在GitHub上发现了这个问题: https://github.com/Azure/azure-sdk-for- python/issues/12744

I found this issue on GitHub : https://github.com/Azure/azure-sdk-for-python/issues/12744

推荐答案

版本

Version 12.5.0 released on 2020-09-10 has now the exists method in the new SDK.

例如,

同步:

from azure.storage.blob import BlobClient

blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="mycontainer", blob_name="myblob")
exists = blob.exists()
print(exists)

异步:

import asyncio

async def check():
    from azure.storage.blob.aio import BlobClient
    blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="mycontainer", blob_name="myblob")
    async with blob:
        exists = await blob.exists()
        print(exists)

这篇关于检查blob是否在python azure中存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆