I got the code to upload a document to Azure storage.
container_client = blob_service_client.get_container_client(container_name)
blob_client = blob_service_client.get_blob_client(container_name, blob_name)
blob_client.upload_blob(file_content, overwrite=True)
absolute_path = f"https://{container_name}.blob.core.windows.net/{blob_name}"
And the file gets uploaded to a link like this :
https://projectName.blob.core.windows.net/attachments/16/document1.pdf
But how do I download it ?
When I try to curl --head
the URL I get :
Could not resolve host: projectName.blob.core.windows.net
Why not use blob_service_client
for download as well? taken from Download a blob with Python
blob_client = blob_service_client.get_blob_client(container_name, blob_name)
with open(file=os.path.join('filepath', 'filename'), mode="wb") as sample_blob:
download_stream = blob_client.download_blob()
sample_blob.write(download_stream.readall())