/// <summary>
        /// Initializes a new instance of the <see cref="TableClient" /> class.
        /// </summary>
        /// <param name="storageCredentials">A Microsoft.WindowsAzure.Storage.Auth.StorageCredentials object.</param>
        /// <param name="useHttps">true to use HTTPS to connect to storage service endpoints; otherwise, false.</param>
        public TableClient(StorageCredentials storageCredentials, bool useHttps = true)
        {
            storageCredentials.ValidateNull();

            var cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps);

            this._cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            this.SetDefaultRetryIfNotExists(this._cloudTableClient);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FileStorage" /> class.
        /// </summary>
        /// <param name="shareName">A string containing the name of the share.</param>
        /// <param name="storageCredentials">A Microsoft.WindowsAzure.Storage.Auth.StorageCredentials object.</param>
        /// <param name="useHttps">true to use HTTPS to connect to storage service endpoints; otherwise, false.</param>
        /// <param name="createIfNotExists">true to creates the share if it does not already exist; otherwise, false.</param>
        public FileStorage(string shareName, StorageCredentials storageCredentials, bool useHttps, bool createIfNotExists = true)
        {
            shareName.ValidateShareName();
            storageCredentials.ValidateNull();

            var cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps);
            var cloudFileClient     = cloudStorageAccount.CreateCloudFileClient();

            this._fileClient = new FileClient(cloudFileClient);
            this.SetDefaultRetryIfNotExists(cloudFileClient);

            this._cloudFileShare = cloudFileClient.GetShareReference(shareName);

            if (createIfNotExists)
            {
                this._cloudFileShare.CreateIfNotExists();
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QueueStorage" /> class.
        /// </summary>
        /// <param name="queueName">Name of the queue.</param>
        /// <param name="storageCredentials">A Microsoft.WindowsAzure.Storage.Auth.StorageCredentials object.</param>
        /// <param name="useHttps">true to use HTTPS to connect to storage service endpoints; otherwise, false.</param>
        /// <param name="createIfNotExists">true to creates the table if it does not already exist; otherwise, false.</param>
        public QueueStorage(string queueName, StorageCredentials storageCredentials, bool useHttps = true, bool createIfNotExists = true)
        {
            queueName.ValidateQueueName();
            storageCredentials.ValidateNull();

            var cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps);
            var cloudQueueClient    = cloudStorageAccount.CreateCloudQueueClient();

            this._queueClient = new QueueClient(cloudQueueClient);
            this.SetDefaultRetryIfNotExists(cloudQueueClient);

            this._cloudQueue = cloudQueueClient.GetQueueReference(queueName);

            if (createIfNotExists)
            {
                this._cloudQueue.CreateIfNotExists();
            }
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobContainer" /> class.
        /// </summary>
        /// <param name="containerName">Name of the container.</param>
        /// <param name="storageCredentials">A Microsoft.WindowsAzure.Storage.Auth.StorageCredentials object.</param>
        /// <param name="useHttps">true to use HTTPS to connect to storage service endpoints; otherwise, false.</param>
        /// <param name="createIfNotExists">true to creates the container if it does not already exist; otherwise, false.</param>
        /// <param name="newContainerAccessType">Access type for the newly created container.</param>
        public BlobContainer(string containerName, StorageCredentials storageCredentials, bool useHttps, bool createIfNotExists, BlobContainerPublicAccessType newContainerAccessType)
        {
            containerName.ValidateContainerName();
            storageCredentials.ValidateNull();

            var cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps);
            var cloudBlobClient     = cloudStorageAccount.CreateCloudBlobClient();

            this._blobClient = new BlobClient(cloudBlobClient);
            this.SetDefaultRetryIfNotExists(cloudBlobClient);

            this._cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);

            if (createIfNotExists)
            {
                if (this._cloudBlobContainer.CreateIfNotExists())
                {
                    var permissions = this._cloudBlobContainer.GetPermissions();
                    permissions.PublicAccess = newContainerAccessType;
                    this._cloudBlobContainer.SetPermissions(permissions);
                }
            }
        }