我有一些用C#编写的blob访问代码,我需要将它们从使用Microsoft.WindowsAzure. Storage.Blob迁移到使用Azure. Storage.Blob
在旧代码中,读取blob时的故障转移是使用以下代码行处理的:
using Microsoft.WindowsAzure.Storage;
Blob.BlobRequestOptions myBlobOptions = new Blob.BlobRequestOptions();
myBlobOptions.LocationMode = RetryPolicies.LocationMode.PrimaryThenSecondary;
myBlobClient.DefaultRequestOptions = myBlobOptions;
Blob.CloudBlobContainer myContainer = myBlobClient.GetContainerReference("container");
Blob.CloudBlockBlob blockBlob = myContainer.GetBlockBlobReference("blobfile");
使用Azure.存储. Blob时该怎么做?
新代码:
BlobServiceClient BlobServiceClient = new BlobServiceClient("connectionString");
BlobContainerClient container = BlobServiceClient.GetBlobContainerClient("container");
BlobClient blob = container.GetBlobClient("blobfile");
1条答案
按热度按时间dly7yett1#
我在自己的环境中尝试过,并通过一段代码成功读取了Azure Blob存储中的文件。
代码:
门户网站:
控制台: