public IEnumerable <StorageContainerModel> GetContainers() { Pageable <BlobContainerItem> response = _blobServiceClient.GetBlobContainers(); return(response.Select(c => new StorageContainerModel() { Name = c.Name })); }
/// <summary> /// Retrieve blob collection metadata from the container /// </summary> public BlobModel[] GetContainerItems(string containerName) { try { BlobContainerClient container = GetBlobContainer(containerName); Pageable <BlobItem> blobs = container.GetBlobs(); return(blobs.Select(blob => new BlobModel { Name = blob.Name.Replace("/", "_"), Category = containerName, Url = GetSasUri(container, blob) }).ToArray()); } catch (RequestFailedException) { return(Array.Empty <BlobModel>()); } }
public IEnumerable <BlobInfoModel> ListBlobsInContainer(string containerName) { BlobContainerClient containerClient = _blobServiceClient.GetBlobContainerClient(containerName); if (!containerClient.Exists()) { throw new ApplicationException($"Cannot list blobs in container '{containerName}' as it does not exists"); } Pageable <BlobItem> blobs = containerClient.GetBlobs(); var models = blobs.Select(b => new BlobInfoModel() { Name = b.Name, Tags = b.Tags, ContentEncoding = b.Properties.ContentEncoding, ContentType = b.Properties.ContentType, Size = b.Properties.ContentLength, CreatedOn = b.Properties.CreatedOn, AccessTier = b.Properties.AccessTier?.ToString(), BlobType = b.Properties.BlobType?.ToString() }); return(models); }