我一直在使用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应用程序中使用它。有不同的方法来获取不同环境下的斑点列表吗?我只是不确定为什么该方法不可用在相同的名称空间/库/版本...?Azure Blob存储库更改了吗?
// 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);
}
}
是否仍适用于您的控制台应用程序? (而不是.net核心版本)? –
@ThiagoCustodio是的。 – JReam
我认为这是与.net核心版本有关的错误。我建议你直接在Github上打开一个问题。 https://github.com/Azure/azure-storage-net –