'Unable to download data from Blob storage. Getting 404 returned
I'm using a Python Azure function which gets invoked when I add a blob to a storage container. The function is triggered ok, but I get a 404 response when trying to download the blob.
The blob resource definitely does exist because I can see it in the Azure portal. I've also made the container publicly accessible.
The confusing thing is that upload works fine.
def get_data_from_azure(blob_name, default=None):
try:
azure_connection_string = os.getenv('AzureWebJobsStorage')
container_name = os.getenv('ContainerName')
blob_service_client = BlobServiceClient.from_connection_string(azure_connection_string)
blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)
download_stream = blob_client.download_blob() # <----- FAILS
data = download_stream.readall()
return data
except:
return default
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
username = myblob.name.split('/')[2]
data = get_data_from_azure(blob_name=myblob.name)
Solution 1:[1]
You can check the security settings of the Blob container, It might be that you don't have enough access rights.
In the Azure Portal Panel select
Storage account>- from
Blob serviceSection Select "Blob" > - Select Blob or Blobs that you want to change the access permission >
- Select "
Access policy" > - from the Drop Down menu select "
Blob" or "Container" anonymous access based on your needs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RajkumarMamidiChettu-MT |
