/// <summary> /// List containers by container name pattern. /// </summary> /// <param name="name">Container name pattern</param> /// <returns>An enumerable collection of cloudblob container</returns> internal IEnumerable <Tuple <AzureStorageContainer, BlobContinuationToken> > ListContainersByName(string name) { string prefix = string.Empty; if (String.IsNullOrEmpty(name) || WildcardPattern.ContainsWildcardCharacters(name)) { prefix = NameUtil.GetNonWildcardPrefix(name); WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; WildcardPattern wildcard = null; if (!string.IsNullOrEmpty(name)) { wildcard = new WildcardPattern(name, options); } Func <string, bool> containerFilter = (containerName) => null == wildcard || wildcard.IsMatch(containerName); IEnumerable <Tuple <AzureStorageContainer, BlobContinuationToken> > containerList = ListContainersByPrefix(prefix, containerFilter); foreach (var containerInfo in containerList) { yield return(containerInfo); } } else { if (!NameUtil.IsValidContainerName(name)) { throw new ArgumentException(String.Format(Resources.InvalidContainerName, name)); } if (this.IncludeDeleted.IsPresent) { WriteWarning("Can't get single deleted container, so -IncludeDeleted will be omit when get single container with -Name."); } CloudBlobContainer container = Channel.GetContainerReference(name); BlobContainerClient containerClient = AzureStorageContainer.GetTrack2BlobContainerClient(container, this.Channel.StorageContext, ClientOptions); global::Azure.Storage.Blobs.Models.BlobContainerProperties properties = null; try { properties = containerClient.GetProperties(cancellationToken: this.CmdletCancellationToken); } catch (global::Azure.RequestFailedException e) when(e.Status == 404) { throw new ResourceNotFoundException(String.Format(Resources.ContainerNotFound, name)); } yield return(new Tuple <AzureStorageContainer, BlobContinuationToken>(new AzureStorageContainer(containerClient, Channel.StorageContext, properties), null)); } }
public AzureStorageContainer(BlobContainerClient container, AzureStorageContext storageContext, BlobContainerProperties properties = null) { Name = container.Name; privateBlobContainerClient = container; cloudBlobContainer = GetTrack1BlobContainer(privateBlobContainerClient, storageContext.StorageAccount.Credentials); privateBlobContainerProperties = properties; if (privateBlobContainerProperties == null) { LastModified = null; } else { LastModified = privateBlobContainerProperties.LastModified; } this.Context = storageContext; }
//refresh XSCL track2 container properties object from server public void FetchAttributes() { privateBlobContainerProperties = BlobContainerClient.GetProperties().Value; }