I'm trying to copy a blob from Azure storage blob container to a file share, running the following script on Azure Databricks
dbutils.library.installPyPI('azure-storage-blob')
dbutils.library.installPyPI('azure-storage-file-share')
from azure.storage.blob import BlobServiceClient, BlobClient
from azure.storage.fileshare import ShareClient, ShareFileClient
connection_string = my_connection_string
blobserviceclient = BlobServiceClient.from_connection_string(connection_string)
source_blob = BlobClient(blobserviceclient.url,container_name = 'my-container-name', blob_name = 'my_file.json')
fileshareclient = ShareClient.from_connection_string(connection_string, 'my-fileshare-name')
destination_file= fileshareclient.get_file_client('my_file.json')
destination_file.start_copy_from_url(source_blob.url)
I get the following error:
ResourceNotFoundError: The specified resource does not exist.
When I check for source_blob.url and destination_file.url, they both exist:
source_blob.url
'https://myaccountname.file.core.windows.net/my-container-name/my_file.json'
and
destination_file.url
'https://myaccountname.file.core.windows.net/my-fileshare-name/my_file.json'
I used the examples from this: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/storage/azure-storage-file-share/samples/file_samples_client.py Any idea what I'm doing wrong? This works when I use AzCopy. I can also copy from one blob container to another, just not from the blob container to file share.
start_copy_from_url
method. – Gaurav Mantri