【发布时间】:2019-08-12 13:00:33
【问题描述】:
如何将 Azure 存储中的块(或页)blob 复制到 Azure 文件共享? 如果我将块 blob 下载到本地文件,我的示例代码可以正常工作,但似乎没有下载到 Azure 文件共享的方法。我查看了 Azure 数据移动库,但没有关于如何执行此操作的示例。
void Main()
{
string myfile =@"Image267.png";
CredentialEntity backupCredentials = Utils.GetBackupsCredentials();
CloudStorageAccount backupAccount = new CloudStorageAccount(new StorageCredentials(backupCredentials.Name, backupCredentials.Key), true);
CloudBlobClient backupClient = backupAccount.CreateCloudBlobClient();
CloudBlobContainer backupContainer = backupClient.GetContainerReference(@"archive");
CloudBlockBlob blob = backupContainer.GetBlockBlobReference(myfile);
CredentialEntity fileCredentails = Utils.GetFileCredentials();
CloudStorageAccount fileAccount = new CloudStorageAccount(new StorageCredentials(fileCredentails.Name,fileCredentails.Key), true);
CloudFileClient fileClient = fileAccount.CreateCloudFileClient();
CloudFileShare share = fileClient.GetShareReference(@"xfer");
if (share.Exists())
{
CloudFileDirectory rootDir = share.GetRootDirectoryReference();
CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("hello");
if (sampleDir.Exists())
{
CloudFile file = sampleDir.GetFileReference(myfile);
// blob.DownloadToFile(file.ToString());
}
}
}
不起作用的部分是注释掉的行blob.DownloadToFile
关于如何做到这一点的任何想法?
【问题讨论】: