Please find the below code for copying the blob files from one storage account to another storage account in Azure using Python, if helpful:
from azure.storage.blob import ResourceTypes, AccountSasPermissions, generate_account_sas, BlobServiceClient
from datetime import datetime, timedelta
# Initialize your source and destination storage account name and key
source_account_key = ''
dest_account_key = ''
source_account_name = ''
des_account_name = ''
# genearte account sas token for source account
sas_token = generate_account_sas(account_name=source_account_name, account_key=source_account_key,
resource_types=ResourceTypes(
service=True, container=True, object=True),
permission=AccountSasPermissions(read=True),
expiry=datetime.utcnow() + timedelta(hours=1))
# Interact with the blobs on the account level
source_blob_service_client = BlobServiceClient(
account_url=f'https://{source_account_name}.blob.core.windows.net/', credential=source_account_key)
des_blob_service_client = BlobServiceClient(
account_url=f'https://{des_account_name}.blob.core.windows.net/', credential=dest_account_key)
source_container_client = source_blob_service_client.get_container_client(
'copy')
source_blob = source_container_client.get_blob_client('Capture.PNG')
source_url = source_blob.url+'?'+sas_token
# copy
des_blob_service_client.get_blob_client(
'test', source_blob.blob_name).start_copy_from_url(source_url)
For more in detail, please refer below links:
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/storage/azure-storage-blob/samples/blob_samples_containers.py#L145
move or copy files(blob) between storage accounts python (azure function)? - Stack Overflow.