Example #1
0
        /// <summary>
        /// Asynchronously creates a named container.
        /// </summary>
        /// <remarks>Returns a created unique name derived from <paramref name="containerName"/> and returns it.</remarks>
        /// <param name="containerName">Container name.</param>
        /// <returns>An unique generated container name.</returns>
        public async Task <AzureContainer> CreateContainerAsync(
            string containerName)
        {
            if (string.IsNullOrWhiteSpace(containerName))
            {
                throw new ArgumentNullException(paramName: nameof(containerName), message: "Container name must not be null.");
            }

            var uniqueName = $"{containerName}_{Guid.NewGuid():N}";

            this[uniqueName] = new AzureContainer(await serviceClient.CreateBlobContainerAsync(uniqueName));

            return(this[uniqueName]);
        }
Example #2
0
 /// <summary>
 /// Try to get a container with specified name.
 /// </summary>
 /// <param name="containerName">Container name.</param>
 /// <param name="container">Container to be outputted to.</param>
 /// <returns>true if container is obtained, otherwise false.</returns>
 public bool TryGetContainer(
     string containerName, out AzureContainer container)
 {
     try
     {
         container = this[containerName];
         return(true);
     }
     catch
     {
         container = null;
         return(false);
     }
 }