0

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 :

enter image description here

Registered New Application, got Application Id, tenantId, Client secret enter image description here

// 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:

enter image description here

enter image description here

xyz.txt is both available at root as well as within /test/xyz.txt.

How to fix this exception?

Yoni L.
  • 22,627
  • 2
  • 29
  • 48
knowdotnet
  • 839
  • 1
  • 15
  • 29
  • Have you set the firewall? see https://learn.microsoft.com/en-us/azure/data-lake-store/data-lake-store-secure-data#set-ip-address-range-for-data-access – Joy Wang Apr 29 '19 at 06:44

1 Answers1

0

This is clearly an permission issue. Have you added you application to access your data lake as per the below screenshot, this is mandatory to have service to service authentication.

enter image description here

enter image description here

Please make sure to check the below thread to ensure you have the right privilege:

https://learn.microsoft.com/en-us/azure/data-lake-store/data-lake-store-service-to-service-authenticate-using-active-directory

It worked for me. Try this and see if it helps else will take a look and debug with you.

Mohit Verma
  • 5,140
  • 2
  • 12
  • 27