Esempio n. 1
0
        public IBlobStorage CreateBlobStorage(StorageConnectionString connectionString)
        {
            if (connectionString.Prefix == "azure.datalake.gen1")
            {
                connectionString.GetRequired("account", true, out string accountName);
                connectionString.GetRequired("tenantId", true, out string tenantId);
                connectionString.GetRequired("principalId", true, out string principalId);
                connectionString.GetRequired("principalSecret", true, out string principalSecret);

                int.TryParse(connectionString.Get("listBatchSize"), out int listBatchSize);

                AzureDataLakeGen1Storage client = AzureDataLakeGen1Storage.CreateByClientSecret(
                    accountName, tenantId, principalId, principalSecret);

                if (listBatchSize != 0)
                {
                    client.ListBatchSize = listBatchSize;
                }

                return(client);
            }
            else if (connectionString.Prefix == "azure.datalake.gen2")
            {
                connectionString.GetRequired("account", true, out string accountName);

                if (connectionString.Parameters.ContainsKey("msi"))
                {
                    return(AzureDataLakeStoreGen2BlobStorageProvider.CreateByManagedIdentity(accountName));
                }

                string key = connectionString.Get("key");

                if (!string.IsNullOrWhiteSpace(key))
                {
                    //connect with shared key

                    return(AzureDataLakeStoreGen2BlobStorageProvider.CreateBySharedAccessKey(accountName, key));
                }
                else
                {
                    //connect with service principal

                    connectionString.GetRequired("tenantId", true, out string tenantId);
                    connectionString.GetRequired("principalId", true, out string principalId);
                    connectionString.GetRequired("principalSecret", true, out string principalSecret);

                    return(AzureDataLakeStoreGen2BlobStorageProvider.CreateByClientSecret(accountName, tenantId, principalId, principalSecret));
                }
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates and instance of Azure Data Lake Gen 2 Store client
        /// </summary>
        /// <param name="factory">Factory reference</param>
        /// <param name="accountName">Data Lake account name</param>
        /// <param name="accessKey">Shared access key</param>
        /// <param name="listBatchSize">Batch size for list operation for this storage connection. If not set defaults to 5000.</param>
        /// <returns></returns>
        public static IBlobStorage AzureDataLakeGen2StoreBySharedAccessKey(this IBlobStorageFactory factory,
                                                                           string accountName,
                                                                           string accessKey,
                                                                           int listBatchSize = 5000)
        {
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }

            if (accessKey == null)
            {
                throw new ArgumentNullException(nameof(accessKey));
            }

            var client = AzureDataLakeStoreGen2BlobStorageProvider.CreateBySharedAccessKey(accountName, accessKey);

            client.ListBatchSize = listBatchSize;

            return(client);
        }
Esempio n. 3
0
 /// <summary>
 /// Creates and instance of Azure Data Lake Gen 2 Store client
 /// </summary>
 /// <param name="factory">Factory reference</param>
 /// <param name="accountName">Data Lake account name</param>
 /// <param name="accessKey">Shared access key</param>
 /// <returns></returns>
 public static IBlobStorage AzureDataLakeGen2StoreBySharedAccessKey(this IBlobStorageFactory factory,
                                                                    string accountName,
                                                                    string accessKey)
 {
     return(AzureDataLakeStoreGen2BlobStorageProvider.CreateBySharedAccessKey(accountName, accessKey));
 }