question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[azure-storage-blob] BlobClient upload_blob does not use headers parameter for multi-block uploads.

See original GitHub issue
  • Package Name: azure-storage-blob
  • Package Version: 12.4.0
  • Operating System: WSL / Ubuntu 20.04.1 LTS / 4.19.104-microsoft-standard / Windows 10.0.19041.450
  • Python Version: 3.8.2

Describe the bug BlobClient upload_blob() does not inject the headers parameter if the upload takes the multi-block upload code path (single block upload works).

To Reproduce

The provided headers will not be injected into the request if the object size exceeds blob_settings.max_single_put_size (default 64 * 1024 * 1024). Starting from a SAS URL.

        object = io.BytesIO(bytearray(1024*1024*100))
        blob = BlobClient.from_blob_url(url)
        blob.upload_blob(
           object,
           headers={'x-custom-header':'value'}, # BUG in the Azure SDK
        )

Expected behavior

The headers parameter to upload_blob should work for both single PUT uploads and multi-block uploads.

Fix appears to be just passing headers to upload_data_chunks 1 2 and upload_substream_blocks 1 2 in upload_block_blob. Not sure where else this may show up.

Additional context

We use a custom outgoing reverse proxy that expects certain headers.

Workaround the issue with a raw_request_hook.

        def hook(args):
            args.http_request.headers.update({'x-custom-header':'value'})

        blob = BlobClient.from_blob_url(url)
        blob.upload_blob(
            object,
            raw_request_hook=hook,
        )

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tasherif-msftcommented, Oct 6, 2020

Hi @jboelter just wanted to let you know that we have a PR up for this issue. I’ll let you know once its merged.

0reactions
xiafu-msftcommented, Sep 24, 2020

Hi @jboelter

It looks like we intended to only add the customized header in the exact “write” operation (change blob content) which is upload blob or commit block list operation. So it’s not a bug… While I think it doesn’t hurt if we add it to all internal requests! We will post a pr to add customized header to all sub requests soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure.storage.blob.BlobClient class - Microsoft Learn
Specify this header to perform the operation only if the resource has not been modified since the specified date/time. etag: str. An ETag...
Read more >
BlobClient (Azure SDK for Java Reference Documentation)
This class provides a client that contains generic blob operations for Azure Storage Blobs. Operations allowed by the client are uploading and downloading, ......
Read more >
Azure Storage Blob Service - Apache Camel
The Azure Storage Blob component is used for storing and retrieving blobs from Azure Storage Blob ... The blob will be created if...
Read more >
@azure/storage-blob - npm
Azure Storage Blob client library for JavaScript ... available when used in the browser, which web workers do not make available by default....
Read more >
How to configure Azure Blob storage with FileNet ... - IBM
FileUploadBlockSize (in bytes) configuration parameter. The staging file upload mode also has a multi block upload threshold set at 32 MB, any ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found