CloudBlob not found in the new Microsoft.WindowsAzure.Storage what is its equivalent

时间秒杀一切 提交于 2019-12-08 05:43:58

问题


I had the following code which was using the deprecated Microsoft.WindowsAzure.StorageClient and have upgraded to Microsoft.WindowsAzure.Storage and now I am unable to use the code below as it is not recognising the CloudBlob class, has this been totally removed or is there an equivalent class I can use in a similar manner

//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:


Starting with Azure Storage Client Library 2.0, all blobs must be accessed via CloudPageBlob or CloudBlockBlob, since the CloudBlob base class has been removed. To get a reference to the concrete blob class when the client does not know the type, please see CloudBlobClient.GetBlobReferenceFromServer and CloudBlobContainer.GetBlobReferenceFromServer.

For migration from a pre-2.0 release to a newer version, I would recommend reading Windows Azure Storage Client Library 2.0 Breaking Changes & Migration Guide.



来源:https://stackoverflow.com/questions/25158252/cloudblob-not-found-in-the-new-microsoft-windowsazure-storage-what-is-its-equiva

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!