I am using .net4.8. I need to connect to Azure Data Lake Storage Gen1.
I found below sample on github: https://github.com/Azure-Samples/data-lake-store-adls-dot-net-get-started/
Now in Azure account :
Registered New Application, got Application Id, tenantId, Client secret
// Obtain AAD token
var creds = new ClientCredential(applicationId, clientSecret);
var clientCreds = ApplicationTokenProvider.LoginSilentAsync(tenantId, creds).GetAwaiter().GetResult();
// Create ADLS client object
AdlsClient client = AdlsClient.CreateClient(adlsAccountFQDN, clientCreds);
try
{
string fileName = "/test/xyz.txt";
//Read file contents
using (var readStream = new StreamReader(client.GetReadStream(fileName)))
{
string line;
while ((line = readStream.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
Line using (var readStream = new StreamReader(client.GetReadStream(fileName))) { throws an exception:
xyz.txt is both available at root as well as within /test/xyz.txt.
How to fix this exception?