Skip to content

Download from local Azurite Docker container with SAS token returns 403 AuthorizationFailure #2478

@brbarnett

Description

@brbarnett

Summary

I am able to upload a file to an Azurite container using the default connection string DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=[http://127.0.0.1:10000/devstoreaccount1;](http://127.0.0.1:10000/devstoreaccount1;%60), but generating a SAS token does not allow me to download that file.

Details

Container image: mcr.microsoft.com/azure-storage/azurite:3.32.0

Python package version: azure-storage-blob 12.23.1

Docker compose service:

  azurite:
    container_name: azurite
    image: mcr.microsoft.com/azure-storage/azurite:3.32.0
    ports:
      - "10000:10000"
    restart: unless-stopped

Generating the SAS token:

start_time = datetime.now(timezone.utc)
expiry_time = start_time + timedelta(hours=48)
sas_token = generate_blob_sas(
    account_key="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
    account_name="devstoreaccount1",
    blob_name="file.txt",
    container_name="uploads",
    expiry=expiry_time,
    permission=BlobSasPermissions(read=True, write=False, delete=False),
    start=start_time,
)
 
return f"{url}?{sas_token}"

Generated URL: http://127.0.0.1:10000/devstoreaccount1/uploads/file.txt?st=2024-10-16T20%3A07%3A16Z&se=2024-10-18T20%3A07%3A16Z&sp=r&sv=2024-11-04&sr=b&sig=jS0Luf8yHVWYVH4X5x6Wwp8KjGc%2BsNkYHl6oVNA7Wv4%3D

Formatted:

st: 2024-10-16T20:07:16Z
se: 2024-10-18T20:07:16Z
sp: r
sv: 2024-11-04
sr: b
sig: jS0Luf8yHVWYVH4X5x6Wwp8KjGc+sNkYHl6oVNA7Wv4=

Error:

<Error>
<Code>AuthorizationFailure</Code>
<Message>Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature. RequestId:acb5401c-3dce-48bc-abbe-7f2854c15a3f Time:2024-10-16T20:17:56.086Z</Message>
</Error>

Happy to provide whatever other information would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions