You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
Try to create a blob connection azure blobstorage gen2 with FromConnectionString
did the StorageFactory.Modules.UseAzureBlobStorage() to register the azure blob storage extention
throws a NullReferenceException
Cause:
ExtendedSdk.GetHttpPipeline(BlobServiceClient sdkClient) is using internals of Azure BlobServiceClient and they have changed I assume.
This ugly hack did the trick:
var accountName = <<StorageAccountName>>;
var credential = new StorageSharedKeyCredential(accountName ,<<accessToken>>);
var uri = new Uri($"https://{accountName}.blob.core.windows.net/");
var client = new BlobServiceClient(uri, credential);
FieldInfo BlobClientConfigurationField =
typeof(BlobServiceClient).GetField("_clientConfiguration", BindingFlags.NonPublic | BindingFlags.Instance);
var clientConfig = BlobClientConfigurationField.GetValue(client);
var clientConfigType = clientConfig.GetType();
PropertyInfo httpPipelineProperty =
clientConfigType.GetProperty("Pipeline", BindingFlags.Public | BindingFlags.Instance);
Azure.Core.Pipeline.HttpPipeline httpPipeline = httpPipelineProperty.GetValue(clientConfig) as Azure.Core.Pipeline.HttpPipeline;
Type AzureDataLakeStorageType = typeof(IBlobStorage)
.Assembly.GetType("FluentStorage.Azure.Blobs.AzureDataLakeStorage");
// ConstructorInfo method = t.GetConstructor(new Type[] { typeof(BlobServiceClient), typeof(string), typeof(StorageSharedKeyCredential), typeof(string )} );
//# Object o = method.Invoke(new Object[] {client, accountName, credential, null});
Type extendedSdkType = typeof(IBlobStorage)
.Assembly.GetType("Blobs.ExtendedSdk");
var dlStorage = FormatterServices.GetUninitializedObject(AzureDataLakeStorageType);
var extendedSdk = FormatterServices.GetUninitializedObject(extendedSdkType);
var sdkClientField =
extendedSdkType.GetField("_sdkClient", BindingFlags.Instance | BindingFlags.NonPublic);
var pipelineField = extendedSdkType.GetField("_httpPipeline", BindingFlags.Instance | BindingFlags.NonPublic);
var dsfBaseAddress = extendedSdkType.GetField("_dfsBaseAddress", BindingFlags.Instance | BindingFlags.NonPublic);
sdkClientField.SetValue(extendedSdk, client);
pipelineField.SetValue(extendedSdk, httpPipeline);
dsfBaseAddress.SetValue(extendedSdk, $"https://{accountName}.dfs.core.windows.net/");
var extendedField = AzureDataLakeStorageType.GetField("_extended", BindingFlags.Instance | BindingFlags.NonPublic);
extendedField.SetValue(dlStorage, extendedSdk);
var clientField2 = AzureDataLakeStorageType.BaseType.GetField("_client", BindingFlags.Instance | BindingFlags.NonPublic);
clientField2.SetValue(dlStorage, client);
var sasCredField = AzureDataLakeStorageType.BaseType.GetField("_sasSigningCredentials", BindingFlags.Instance | BindingFlags.NonPublic);
sasCredField.SetValue(dlStorage, credential);
var containerField = AzureDataLakeStorageType.BaseType.GetField("_containerNameToContainerClient", BindingFlags.Instance | BindingFlags.NonPublic);
containerField.SetValue(dlStorage, new ConcurrentDictionary<string, BlobContainerClient>());
The text was updated successfully, but these errors were encountered:
robinrodricks
changed the title
Azure Datalake Blob storage gen2 regression
Azure Datalake Blob storage gen2 regression [COMMUNITY HELP WANTED]
Aug 18, 2024
robinrodricks
changed the title
Azure Datalake Blob storage gen2 regression [COMMUNITY HELP WANTED]
Azure Datalake Blob storage gen2 fails to connect [COMMUNITY HELP WANTED]
Aug 18, 2024
Problem:
Try to create a blob connection azure blobstorage gen2 with FromConnectionString
did the StorageFactory.Modules.UseAzureBlobStorage() to register the azure blob storage extention
throws a NullReferenceException
Cause:
ExtendedSdk.GetHttpPipeline(BlobServiceClient sdkClient) is using internals of Azure BlobServiceClient and they have changed I assume.
This ugly hack did the trick:
The text was updated successfully, but these errors were encountered: