Azure:在blob_客户端中未找到资源
我正在尝试使用python脚本删除我的azure blob,为此,我使用azure.storage库中的BlobClient 以下是我正在尝试运行的代码:Azure:在blob_客户端中未找到资源,azure,azure-active-directory,azure-functions,azure-storage-blobs,Azure,Azure Active Directory,Azure Functions,Azure Storage Blobs,我正在尝试使用python脚本删除我的azure blob,为此,我使用azure.storage库中的BlobClient 以下是我正在尝试运行的代码: import json, sys, os, time from azure.storage.blob import BlobServiceClient, PublicAccess, BlobClient endpoint = os.environ['COMPUTER_VISION_ENDPOINT'] subscription_key =
import json, sys, os, time
from azure.storage.blob import BlobServiceClient, PublicAccess, BlobClient
endpoint = os.environ['COMPUTER_VISION_ENDPOINT']
subscription_key = os.environ['COMPUTER_VISION_SUBSCRIPTION_KEY']
text_recognition_url = endpoint + "/vision/v3.0/read/analyze"
file_name = input("Enter the file name: ")
image_url = "https://textimage.blob.core.windows.net/handwritten-text/" + file_name
blob_client = BlobClient.from_blob_url(blob_url=image_url)
blob_client.delete_blob()
print("Done")
尽管blob和容器存在于azure存储帐户中,但它会引发以下错误:
azure.core.exceptions.ResourceNotFoundError: The specified resource does not exist.
我错在哪里
使用python脚本删除特定开放blob的更好方法是什么
import os
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
blob_service_client = BlobServiceClient.from_connection_string(os.getenv('str'))
container_client = blob_service_client.get_container_client("test")
blob_client = blob_service_client.get_blob_client("test", "test.txt")
blob_client.delete_blob()
以上代码在我这方面运行良好。(您可以用动态值替换容器名称和blob名称。)
并查看官方文件:
当你面对的
NoneType对象没有属性“rstrip”
,这意味着你应该给这个方法一个连接字符串。请不要这样做…我会更新一个答案。谢谢,只是有一点变化:不是os.getenv('str'),而是直接为我提供连接字符串的值。前者给出了一个错误,NoneType对象没有属性“rstrip”
@nipan09此问题应该来自from\u connection\u string()方法中的参数为null。你已经给出了连接字符串了吗?它应该从这里得到:我已经在我的环境变量中设置了连接字符串,我想这就是它工作的原因。