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)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0