Azure Blob 存储库有变化吗?

Did Azure Blob Storage Library Change?

我一直在使用 WindowsAzure.Storage 8.* 库来使用容器来移动一些 blob。最近,我想使用 Microsoft 站点上示例中的以下代码获取 blob 列表。 (https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-how-to-use-blobs#set-up-your-development-environment) 当我尝试使用 'ListBlobs()' 时,该方法不再可通过库使用。我在控制台应用程序中使用它,而现在我试图在 .net 核心 Web 应用程序中使用它。是否有不同的方法来获取不同环境中的 blob 列表?我只是不确定为什么该方法在同一个 namespace/library/version...?

中不可用
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));

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

// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("photos");

// Loop over items within the container and output the length and URI.
foreach (IListBlobItem item in container.ListBlobs(null, false))
{
if (item.GetType() == typeof(CloudBlockBlob))
{
    CloudBlockBlob blob = (CloudBlockBlob)item;

    Console.WriteLine("Block blob of length {0}: {1}",    blob.Properties.Length, blob.Uri);

}
else if (item.GetType() == typeof(CloudPageBlob))
{
    CloudPageBlob pageBlob = (CloudPageBlob)item;

    Console.WriteLine("Page blob of length {0}: {1}", pageBlob.Properties.Length, pageBlob.Uri);

}
else if (item.GetType() == typeof(CloudBlobDirectory))
{
    CloudBlobDirectory directory = (CloudBlobDirectory)item;

    Console.WriteLine("Directory: {0}", directory.Uri);
}
}

根据这个问题:Missing syncronous methods for dotnet core?,NetCore/Netstandard支持还不包括 API 的同步实现。

由于 ListBlobs 是一种同步方法,因此在不支持同步方法的平台上不存在,因此您只能在云中调用 ListBlobsSegmentedAsync 并处理它的延续令牌 returns。

关于如何使用 ListBlobsSegmentedAsync 列出 blob 的更多详细信息,您可以参考以下 link 的示例: CloudBlobClient.ListBlobsSegmentedAsync Method

从9.4.2 SDK开始,微软带回了同步实现: https://github.com/Azure/azure-storage-net/tree/master/Blob