I am trying to download an Azure Blob Storage file from my storage account, to do so, I have checked what the URL is and I am doing the following:
with urllib.request.urlopen("<url_file>") as resp:
img = np.asarray(bytearray(resp.read()), dtype="uint8")
Run Code Online (Sandbox Code Playgroud)
But I am getting the following error:
urllib.error.HTTPError: HTTP Error 404: The specified resource does not exist.
Run Code Online (Sandbox Code Playgroud)
I have doubled checked that the url is correct. Could this have something to do with not having passed the keys of my subscription or any other info about the Storage Account?
Any idea?
截至 2019 年 12 月 26 日,我无法从 azure 云存储导入 BaseBlobService。BlobPermissions 和 generate_blob_shared_access_signature 都不适合我。下面是我使用过的东西,它在我的情况下有效,希望它有所帮助
from azure.storage.blob import generate_blob_sas, AccountSasPermissions
def scan_product():
account_name=<account_name>
container_name=<container_name>
blob_name=<blob_name>
account_key=<account_key>
url = f"https://{account_name}.blob.core.windows.net/{container_name}/{blob_name}"
sas_token = generate_blob_sas(
account_name=account_name,
account_key=account_key,
container_name=container_name,
blob_name=blob_name,
permission=AccountSasPermissions(read=True),
expiry=datetime.utcnow() + timedelta(hours=1)
)
url_with_sas = f"{url}?{sas_token}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7619 次 |
| 最近记录: |