I have files in Azure Web App that I need to copy to a container in my Azure Storage Account.
I previously saved images in the website in a folder within the web-app. Now, I need to separate concern and store them in Azure storage account. I have managed to write code to store new images to the storage account. I need to copy the already existing files to the storage account. How do I achieve this?
Any insight to the solution is highly appreciated
Update:
If FTP is allowed. Download and upload images manually is also a method.(Just get the host name and the password is ok.)
Original Answer:
You can use the code like below:
var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=xxxxxx");
var myClient = storageAccount.CreateCloudBlobClient();
var container = myClient.GetContainerReference("images");
var blockBlob = container.GetBlockBlobReference("grass.jpg");
blockBlob.UploadFromStreamAsync(xxx);
This is the offcial doc of how to download:
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet#download-blobs
And this is the offcial doc of how to upload:
Hope it helps.:)