.NETを使用してBLOBをコピーする方法はありますか。
あなたはAzure Storage SDK for .Net
(Github
| Nuget
)を使用する必要があります。
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
static void CopyBlobUsingSasExample()
{
var destinationAccountName = "";
var destinationAccountKey = "";
var destinationAccount = new CloudStorageAccount(new StorageCredentials(destinationAccountName, destinationAccountKey), true);
var destinationContainerName = "vhds";
var destinationContainer = destinationAccount.CreateCloudBlobClient().GetContainerReference(destinationContainerName);
destinationContainer.CreateIfNotExists();
var destinationBlob = destinationContainer.GetPageBlobReference("MyDestinationBlobName.vhd");
var sourceBlobSasUri = "";
destinationBlob.StartCopy(new Uri(sourceBlobSasUri));
//Since copy operation is async, please wait for the copy operation to finish.
do
{
destinationBlob.FetchAttributes();
var copyStatus = destinationBlob.CopyState.Status;
if (copyStatus != CopyStatus.Pending)
{
break;
}
else
{
System.Threading.Thread.Sleep(5000);//Sleep for 5 seconds and then fetch attributes to check the copy status.
}
} while (true);
}