CloudBlob not found in the new Microsoft.WindowsAz

2019-05-31 18:29发布

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条回答
做自己的国王
2楼-- · 2019-05-31 18:52

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.

查看更多
登录 后发表回答