title: Python code to access Azure Data Lake Store
body: <p>I 'm looking at Microsoft Documentation <a href="https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-data-operations-python" rel="nofollow noreferrer">here</a> and <a href="https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-service-to-service-authenticate-python" rel="nofollow noreferrer">here</a>, I have created Web App in Azure Active Directory to access the Data Lake Store</p>
  
  <p>From the Web App I have <strong>Object ID</strong>, <strong>Application</strong> ID and <strong>Key</strong></p>
  
  <p>looking at the documentations I see this:</p>
  
  <pre><code>adlCreds = lib.auth(tenant_id = 'FILL-IN-HERE', client_secret = 'FILL-IN-HERE', client_id = 'FILL-IN-HERE', resource = 'https://datalake.azure.net/')
  </code></pre>
  
  <p>how to use it to authenticate my code and run operation on Data Lake Store?</p>
  
  <p>here is my full test code:</p>
  
  <pre><code>## Use this for Azure AD authentication
  from msrestazure.azure_active_directory import AADTokenCredentials
  
  ## Required for Azure Data Lake Store account management
  from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient
  from azure.mgmt.datalake.store.models import DataLakeStoreAccount
  
  ## Required for Azure Data Lake Store filesystem management
  from azure.datalake.store import core, lib, multithread
  
  # Common Azure imports
  import adal
  from azure.mgmt.resource.resources import ResourceManagementClient
  from azure.mgmt.resource.resources.models import ResourceGroup
  
  ## Use these as needed for your application
  import logging, getpass, pprint, uuid, time
  
  
  ## Declare variables
  subscriptionId = 'FILL-IN-HERE'
  adlsAccountName = 'FILL-IN-HERE'
  
  tenant_id = 'FILL-IN-HERE'
  client_secret = 'FILL-IN-HERE'
  client_id = 'FILL-IN-HERE'
  
  
  ## adlCreds = lib.auth(tenant_id = 'FILL-IN-HERE', client_secret = 'FILL-IN-HERE', client_id = 'FILL-IN-HERE', resource = 'https://datalake.azure.net/')
  from azure.common.credentials import ServicePrincipalCredentials
  adlCreds = lib.auth(tenant_id, client_secret, client_id, resource = 'https://datalake.azure.net/')
  
  
  ## Create a filesystem client object
  adlsFileSystemClient = core.AzureDLFileSystem(adlCreds, store_name=adlsAccountName)
  
  ## Create a directory
  adlsFileSystemClient.mkdir('/mysampledirectory')
  </code></pre>
  
  <p>when I try to ru the code I get error:</p>
  
  <p>[Running] python "c:....\dls.py"
  Traceback (most recent call last):
  File "c:....\dls.py", line 38, in 
    adlCreds = lib.auth(tenant_id, client_secret, client_id, resource = '<a href="https://datalake.azure.net/" rel="nofollow noreferrer">https://datalake.azure.net/</a>')
    File "C:\Python36\lib\site-packages\azure\datalake\store\lib.py", line 130, in auth password, client_id)
    File "C:\Python36\lib\site-packages\adal\authentication_context.py", line 145, in acquire_token_with_username_password
      return self._acquire_token(token_func)
    File "C:\Python36\lib\site-packages\adal\authentication_context.py", line 109, in _acquire_token
      return token_func(self)
    File "C:\Python36\lib\site-packages\adal\authentication_context.py", line 143, in token_func
      return token_request.get_token_with_username_password(username, password)
    File "C:\Python36\lib\site-packages\adal\token_request.py", line 280, in get_token_with_username_password
      self._user_realm.discover()
    File "C:\Python36\lib\site-packages\adal\user_realm.py", line 152, in discover
      raise AdalError(return_error_string, error_response)
  adal.adal_error.AdalError: User Realm Discovery request returned http error: 404 and server response: </p>
  
  <p></p>
  
  <p></p>
  
  <p></p>
  
  <p>404 - File or directory not found.</p>
  
  <p></p>
  
  
  
  <p></p>
  
  <p></p>
  
  <p></p>
  
  <h1>Server Error</h1>
  
  
  
   
  
    <h2>404 - File or directory not found.</h2>
  
    <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
  
   
  
  
  
  <p></p>
  
  <p></p>
  
  <p>[Done] exited with code=1 in 1.216 seconds</p>