Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob client download_blob api is broken with AsyncioRequestsTransport #40217

Open
vpanghal opened this issue Mar 25, 2025 · 7 comments
Open

Blob client download_blob api is broken with AsyncioRequestsTransport #40217

vpanghal opened this issue Mar 25, 2025 · 7 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)

Comments

@vpanghal
Copy link

vpanghal commented Mar 25, 2025

  • Package Name: azure-storage-blob
  • Package Version: 12.24.1
  • Operating System: All
  • Python Version: 3.11

Describe the bug
download_blob API is failing with AttributeError: 'RestAsyncioRequestsTransportResponse' object has no attribute 'load_body'

/home/cohesity/.cache/pypoetry/virtualenvs/xxxx-6dGAiALT-py3.11/lib/python3.11/site-packages/azure/core/tracing/decorator_async.py:114: in wrapper_use_tracer return await func(*args, **kwargs) /home/cohesity/.cache/pypoetry/virtualenvsxxxx-6dGAiALT-py3.11/lib/python3.11/site-packages/azure/storage/blob/aio/_blob_client_async.py:746: in download_blob await downloader._setup() # pylint: disable=protected-access /home/cohesity/.cache/pypoetry/virtualenvs/xxxx-6dGAiALT-py3.11/lib/python3.11/site-packages/azure/storage/blob/aio/_download_async.py:328: in _setup self._response = await self._initial_request() /home/cohesity/.cache/pypoetry/virtualenvs/xxxxx-6dGAiALT-py3.11/lib/python3.11/site-packages/azure/storage/blob/aio/_download_async.py:416: in _initial_request self._current_content = await process_content( /home/cohesity/.cache/pypoetry/virtualenvs/xxxxxx-6dGAiALT-py3.11/lib/python3.11/site-packages/azure/storage/blob/aio/_download_async.py:49: in process_content await data.response.load_body() /home/cohesity/.cache/pypoetry/virtualenvs/xxxxxx-6dGAiALT-py3.11/lib/python3.11/site-packages/azure/core/rest/_http_response_impl_async.py:44: in __getattr__ return super().__getattr__(attr)

To Reproduce
Steps to reproduce the behavior:

  1. Invoke donwload_blob API with AsyncioRequestsTransport

Expected behavior
download_blob API should succeed

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
This succeeds with 12.23.1 but fails with 12.24.x release

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files) labels Mar 25, 2025
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jalauzon-msft @vincenttran-msft.

Copy link

Hello @vpanghal. I'm an AI assistant for the azure-sdk-for-python repository. I have some suggestions that you can try out while the team gets back to you.

  • It appears that the error is due to the AsyncioRequestsTransport not implementing the load_body method, which is needed during the download_blob operation.
  • A common workaround is to switch to a transport that fully supports async operations (such as AioHttpTransport). Installing the aiohttp package and ensuring that the client picks up this transport can resolve the issue.
  • Double-check that you are running the latest versions of both azure-core and azure-storage-blob, since improvements and fixes are regularly introduced.
  • For more details on async transports in the Azure SDK for Python, see the azure-core async transport documentation.
  • If you require the use of AsyncioRequestsTransport, you might consider extending it to implement load_body or filing an issue against that transport implementation.

The team will get back to you shortly, hopefully this helps in the meantime.

@weirongw23-msft
Copy link
Member

Hi @vpanghal, thanks for the inquiry. Could you provide us with a code sample to reproduce your exact issue? Thanks!

@kashifkhan kashifkhan added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Mar 25, 2025
Copy link

Hi @vpanghal. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Mar 25, 2025
@vpanghal
Copy link
Author

vpanghal commented Mar 26, 2025

This is the script that you can use to reproduce the issue. It works with 12.23.1 but fails with 12.24.1

import asyncio
from azure.storage.blob.aio import BlobClient
from azure.core.pipeline.transport import AsyncioRequestsTransport

async def download_blob_to_file(account_url, container_name, blob_name, credential, download_path):
    blob_url = f"{account_url}/{container_name}/{blob_name}"

    # Create custom transport
    transport = AsyncioRequestsTransport()

    # Create BlobClient with custom transport
    blob_client = BlobClient(
        blob_url=blob_url,
        credential=credential,
        transport=transport
    )

    try:
        print(f"Downloading blob '{blob_name}' to '{download_path}'...")
        stream = await blob_client.download_blob()

        with open(download_path, "wb") as f:
            async for chunk in stream.chunks():
                f.write(chunk)

        print("Download complete.")
    finally:
        await blob_client.close()
        await transport.close()

if __name__ == "__main__":
    account_url = "https://my-storage-account.blob.core.windows.net"
    container_name = "my-container"
    blob_name = "my-demo"
    credential = "my-credentials"
    download_path = "my-download.txt"

    asyncio.run(download_blob_to_file(account_url, container_name, blob_name, credential, download_path))

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Mar 26, 2025
@weirongw23-msft
Copy link
Member

Hi @vpanghal, thanks for providing the sample code! I was able to reproduce the issues you're experiencing.

The error appears to be the AsyncioRequestsTransport from azure.core.pipeline.transport does not have an attribute of load_body(), and the async download path requires this attribute while processing downloaded content.

The immediate workaround will be to try removing the transport kwarg and use the default transport in the Python SDK, or to use a different transport by azure-core.

In the meantime, our team will discuss how to best resolve your issue and get back to you on any changes we'll make. Thanks!

@jalauzon-msft
Copy link
Member

Hi @vpanghal, for a bit more context here, before version 12.23.X the Storage SDK did not support AsyncioRequestsTransport. With version 12.23.0, we inadvertently added support for it while trying to fix another issue. It turns out the fix we added to 12.23.0 broke older, legacy transport types and so we reverted that change in 12.24.1, also inadvertently breaking AsyncioRequestsTransport. Basically, it boils down to Storage wants to support all types of transports offered by Azure Core, new and old, but the sets of APIs offered on the response objects from these transports are not consistent so by adding support for one, we break support for others.

We are investigating a way to handle the differences in APIs gracefully so we can support all types of transports, and we hope to include that in our next release or two. As is, however, we do not currently support AsyncioRequestsTransport in Storage yet.

@weirongw23-msft weirongw23-msft self-assigned this Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

4 participants