title: How to stream Azure Blob to AWS S3?
body: <p>I need to copy a large Azure Blob to AWS S3 without keeping a copy of it in the memory. After some Googling I have found a bunch of examples that I combined in the following script. This still loads data into memory though. Is there a good way to avoid it?</p>
  <pre><code>import boto3
  from azure.storage.blob import BlobClient
  
  with io.BytesIO() as input_stream, io.BytesIO() as output_stream:
      blob_client = BlobClient.from_connection_string(
          conn_str=AZURE_CONNECTION_STRING,
          container_name=container,
          blob_name=filename,
      )
      blob_client.download_blob().readinto(input_stream)
  
      input_stream.seek(0)
      shutil.copyfileobj(input_stream, output_stream)
      output_stream.seek(0)
  
      boto3.resource(&quot;s3&quot;).Object(BUCKET_NAME, s3_key).put(Body=output_stream)
  </code></pre>