none
Accessing Azure Datalake store through powershell

    Question

  • I am trying to access the files in datalake folder with command:

    Get-AzureRmDataLakeStoreChildItem -AccountName $dataLakeStorageGen1Name -Path $myrootdir

    But it gives the below mentioned error. how can I fix this issue?

    Get-AzureRmDataLakeStoreChildItem : Error getting listStatus for path /dummy after
    Operation: LISTSTATUS failed with   Error: Token Length is 6. Something is wrong with the token..
    Last encountered exception thrown after 2 tries. [There was an error retrieving the managed service access token for resource 'https://datalake.azure.net' using the URI 'http://localhost:50342/oauth2/token?resource=https%3A%2F%2Fdatalake.azure.net&api-version=2018-02-01'.  Please check that this managed service is configured to emit tokens at this address and that the associated managed service identity has the appropriate role assignment and try logging in again.,Token Length is 6. Something is wrong with the token.]
    [ServerRequestId:]
    At line:1 char:1
    + Get-AzureRmDataLakeStoreChildItem -AccountName "testdatalakegohar" -P ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzDataLakeStoreChildItem], AdlsException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeStore.GetAzureDataLakeStoreChildItem

    Wednesday, October 31, 2018 10:02 AM

All replies

  • Hi Gohar,

    You are having token issues:

    Please check that this managed service is configured to emit tokens at this address and that the associated managed service identity has the appropriate role assignment and try logging in again.,Token Length is 6. Something is wrong with the token.]

    In this scenario, you need to authenticate with Azure first by passing the Connect-AzureRmAccount cmdlet first and then run your desired cmdlet: Get-AzureRmDataLakeStoreChildItem
    -AccountName $dataLakeStorageGen1Name -Path $myrootdir

    Sign in with Azure PowerShell

    Or, if you are wanting to use the REST API, there is another authentication method: End-user authentication with Azure Data Lake Storage Gen1 using REST API

    Can you run this cmdlet to ensure the account is set up correctly:

    Test-AzureRmDataLakeStoreAccount -Name $dataLakeStorageGen1Name

    Thank you,

    Mike

    Wednesday, October 31, 2018 3:45 PM
    Moderator
  • Hello Gohar,

    I am noticing the same issue as you with 'Get-AzureRmDataLakeStoreChildItem' when using Cloud Shell.  It works on my local machine with AzureRM 6.11.0 and 5.7.0.  The commands I usually use to list module versions is not working in Cloud Shell at the moment.  I see the Powershell version is 6.x in Cloud Shell and 5.x on my local Windows machine.  Could you try the command on your local Windows machine and see if you have any luck?


    Thursday, November 1, 2018 8:49 PM
    Moderator
  • Hi Jason/Mike,

    It worked completely fine from my windows but it was making an issue while using it in runbook.

     The issue was because of accessing the datalake with an App account, but it started working by providing my personal credentials.

    Thanks.

    Gohar

    Wednesday, November 28, 2018 1:00 PM