复制一幅Azure的BLOB在Azure存储客户端2.0的另一种斑点 [英] Copying one Azure blob to another blob in Azure Storage Client 2.0

查看:125
本文介绍了复制一幅Azure的BLOB在Azure存储客户端2.0的另一种斑点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧的1.7存储客户端有一个CloudBlob.CopyFromBlob(otherBlob)方法,但它似乎并没有在2.0版本present。什么是复制的斑点推荐的最佳做法?我确实看到了ICloudBlob.BeginStartCopyFromBlob方法。如果是适当的方法,我怎么使用它?

In the old 1.7 storage client there was a CloudBlob.CopyFromBlob(otherBlob) method, but it does not seem to be present in the 2.0 version. What is the recommended best practice for copying blobs? I do see a ICloudBlob.BeginStartCopyFromBlob method. If that is the appropriate method, how do I use it?

推荐答案

拉夫Mantri 写了一系列关于2.0版本的Azure存储文章。我采取这种code提取物从他的<博客文章href=\"http://gauravmantri.com/2012/11/28/storage-client-library-2-0-migrating-blob-storage-$c$c/\">Storage客户端库2.0 - 迁移Blob存储$ C为斑点复制$ C

Gaurav Mantri has written a series of articles on Azure Storage on version 2.0. I have taken this code extract from his blog post of Storage Client Library 2.0 – Migrating Blob Storage Code for Blob Copy

    CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer sourceContainer = cloudBlobClient.GetContainerReference(containerName);
CloudBlobContainer targetContainer = cloudBlobClient.GetContainerReference(targetContainerName);
string blobName = "<Blob Name e.g. myblob.txt>";
CloudBlockBlob sourceBlob = sourceContainer.GetBlockBlobReference(blobName);
CloudBlockBlob targetBlob = targetContainer.GetBlockBlobReference(blobName);
targetBlob.StartCopyFromBlob(sourceBlob);

这篇关于复制一幅Azure的BLOB在Azure存储客户端2.0的另一种斑点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆