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); }
/// <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="listBatchSize">Batch size for list operation for this storage connection. If not set defaults to 5000.</param> /// <returns></returns> public static IBlobStorage AzureDataLakeGen2StoreByManagedIdentity(this IBlobStorageFactory factory, string accountName, int listBatchSize = 5000) { if (accountName == null) { throw new ArgumentNullException(nameof(accountName)); } var client = AzureDataLakeStoreGen2BlobStorageProvider.CreateByManagedIdentity(accountName); client.ListBatchSize = listBatchSize; return(client); }
/// <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> /// <returns></returns> public static IBlobStorage AzureDataLakeGen2StoreByManagedIdentity(this IBlobStorageFactory factory, string accountName) { return(AzureDataLakeStoreGen2BlobStorageProvider.CreateByManagedIdentity(accountName)); }