I recommend that you use the NuGet package that Microsoft publishes: https://www.nuget.org/packages/Azure.Storage.Files.DataLake
This is a library wrapping calls to Azure DataLake Gen2's REST API (docs here).
This first release is just a helper that makes it easier to make correct calls to the API. Later releases will provide helpers to assist with more complex tasks, such as automatically segmenting and uploading large files.
This library depends on Newtonsoft.Json becuase all libraries do, and on Polly to provide retry semantics.
This release supports shared key authentication or oauth.. Install in your application like this:
var host = new HostBuilder()
.ConfigureServices(svc =>
{
svc.AddAzureDataLakeGen2Client(options =>
{
options.AuthorizeWithAccountNameAndKey("account name", "shared key");
// or //
options.AuthorizeWithAccountNameAndAzureOauth("account name", "tenant id", "client id", "client secret");
// or //
options.AuthorizeWithSharedAccessSignature("account name", "shared access signature");
});
})
.Build();
//later in your code
var pathClient = services.GetRequiredService<Adlg2PathClient>();
var filesystemClient = services.GetRequiredService<Adlg2FilesystemClient>();
Or create it directly using the factory:
var pathClient = Adlg2ClientFactory.BuildPathClient("account name", "shared key");
// or //
var pathClient = Adlg2ClientFactory.BuildPathClient("account name", "tenant id", "client id", "client secret");
var filesystemClient = Adlg2ClientFactory.BuildFilesystemClient("account name", "shared key");
// or //
var filesystemClient = Adlg2ClientFactory.BuildFilesystemClient("account name", "tenant id", "client id", "client secret");
The path client wraps the path API.
The filesystem client wraps the filesystem API.
Let me know if this was useful for you or if you have suggestions or feature requests (issues welcome). The current roadmap is:
- Allow configuration of retry policies.
- Create helpers to segment upload and download of large files.
- Clean up some of the tech debt in the 0.X release and get ready for a 1.0