CloudBlob在新的Microsoft.WindowsAzure.Storage中找不到它的等价物

时间:2014-08-06 10:40:02

标签: azure azure-storage azure-storage-blobs

我有以下代码使用已弃用的Microsoft.WindowsAzure.StorageClient并已升级到Microsoft.WindowsAzure.Storage,现在我无法使用下面的代码,因为它无法识别CloudBlob类,这完全是删除或是否存在我可以以类似方式使用的等效类

//blob client now
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

//the container for this is customerlogo
CloudBlobContainer container = blobClient.GetContainerReference(Container);
container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

//blob reference, this will be the company name in this case. it should not exist but if it does it will get overwritten.
CloudBlob blob = container.GetBlobReference(fileName);

1 个答案:

答案 0 :(得分:1)

从Azure Storage Client Library 2.0开始,必须通过CloudPageBlob或CloudBlockBlob访问所有blob,因为已删除CloudBlob基类。要在客户端不知道类型时获取对具体blob类的引用,请参阅CloudBlobClient.GetBlobReferenceFromServerCloudBlobContainer.GetBlobReferenceFromServer

要从2.0之前的版本迁移到较新版本,我建议您阅读Windows Azure Storage Client Library 2.0 Breaking Changes & Migration Guide