Getting list of names of Azure blob files in a container?

前端 未结 8 1650
醉酒成梦
醉酒成梦 2020-12-15 15:31

I need to list names of Azure Blob file names. Currently I m able to list all files with URL but I just need list of names. I want to avoid parsing names. Can you please see

8条回答
  •  盖世英雄少女心
    2020-12-15 16:08

    Full answer with details.

            // Parse the connection string and return a reference to the storage account.
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AzureBlobConnectionString"));
    
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
            // Retrieve reference to a previously created container.
            CloudBlobContainer container = blobClient.GetContainerReference("container_name");
    
            // Retrieve reference to a blob named "test.csv"
            CloudBlockBlob blockBlob = container.GetBlockBlobReference("BlobName.tex");
    
            //Gets List of Blobs
            var list = container.ListBlobs();
            List blobNames = list.OfType().Select(b => b.Name).ToList();
    

提交回复
热议问题