Exemple #1
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        protected AzureQueue(AzureSettings settings, string queueName, bool createIfNotExists)
        {
            _client = new Lazy <QueueClient>(() =>
            {
                var client = AzureClient.Create(
                    settings,
                    conn => new QueueClient(conn, queueName),
                    (acc, cred) => new QueueClient(new Uri($"https://{acc}.queue.core.windows.net/{queueName}"), cred),
                    () => throw new InvalidOperationException("Cannot create Azure queue client without storage account name"));

                if (createIfNotExists)
                {
                    client.CreateIfNotExists();
                }

                return(client);
            });
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        protected AzureBlobContainer(AzureSettings settings, string containerName, bool createIfNotExists)
        {
            _client = new Lazy <BlobContainerClient>(() =>
            {
                var client = AzureClient.Create(
                    settings,
                    conn => new BlobContainerClient(conn, containerName),
                    (acc, cred) => new BlobContainerClient(new Uri($"https://{acc}.blob.core.windows.net/{containerName}"), cred),
                    () => throw new InvalidOperationException("Cannot create Azure blob container client without storage account name"));

                if (createIfNotExists)
                {
                    client.CreateIfNotExists();
                }

                return(client);
            });
        }