Blob Storage: Support AsyncIterable blob uploads
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently, azure.storage.blob.aio.BlobClient’s upload_blob (as well as stage_blob etc), don’t support data that is AsyncIterable. That is the following will not work:
async def iterator() -> AsyncGenerator[bytes, None]:
for i in range(10):
yield str(i).encode("latin1")
await asyncio.sleep(0.1)
await blob_client.upload_blob(iterator())
Describe the solution you’d like
I’d like the aio versions of the upload functions to accept AsyncIterable[AnyStr] in addition to Iterable[AnyStr] and IO[AnyStr].
Describe alternatives you’ve considered Using intermediate pipes, creating a stream that we would feed manually. All alternatives do blocking and that doesn’t fit in the asyncio model.
Additional context
Trying to have Starlette forward some data to blob storage, by using starlette.request.Request’s stream() async generator, so as to not load the entire document into memory.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (5 by maintainers)

Top Related StackOverflow Question
Hi @Krande and @pinkwah, I have finally opened #27518 to add support for
AsyncIterableto blob upload. Once this is merged, it will be part of our next release (no ETA on that currently). Thanks for your patience!Hi @dotfloat Thanks for the feedback we will support this in the future release!