Account management operations on Azure Data Lake Store using .NET SDK

In this article, you learn how to perform account management operations on Data Lake Store using .NET SDK. Account management operations include creating a Data Lake Store account, listing the accounts in an Azure subscription, deleting the accounts, etc.

For instructions on how to perform data management operations on Data Lake Store using .NET SDK, see Filesystem operations on Data Lake Store using .NET SDK.


  • Visual Studio 2013, 2015, or 2017. The instructions below use Visual Studio 2017.

  • An Azure subscription. See Get Azure free trial.

Create a .NET application

  1. Open Visual Studio and create a console application.
  2. From the File menu, click New, and then click Project.
  3. From New Project, type or select the following values:

    Property Value
    Category Templates/Visual C#/Windows
    Template Console Application
    Name CreateADLApplication
  4. Click OK to create the project.
  5. Add the NuGet packages to your project.

    1. Right-click the project name in the Solution Explorer and click Manage NuGet Packages.
    2. In the NuGet Package Manager tab, make sure that Package source is set to and that Include prerelease check box is selected.
    3. Search for and install the following NuGet packages:

      • Microsoft.Azure.Management.DataLake.Store - This tutorial uses v2.1.3-preview.
      • Microsoft.Rest.ClientRuntime.Azure.Authentication - This tutorial uses v2.2.12.

        Add a NuGet source

    4. Close the NuGet Package Manager.
  6. Open Program.cs, delete the existing code, and then include the following statements to add references to namespaces.

     using System;
     using System.IO;
     using System.Linq;
     using System.Text;
     using System.Threading;
     using System.Collections.Generic;
     using System.Security.Cryptography.X509Certificates; // Required only if you are using an Azure AD application created with certificates
     using Microsoft.Rest;
     using Microsoft.Rest.Azure.Authentication;
     using Microsoft.Azure.Management.DataLake.Store;
     using Microsoft.Azure.Management.DataLake.Store.Models;
     using Microsoft.IdentityModel.Clients.ActiveDirectory;
  7. Declare the variables and provide the values for placeholders. Also, make sure the local path and file name you provide exist on the computer.

     namespace SdkSample
         class Program
             private static DataLakeStoreAccountManagementClient _adlsClient;
             private static string _adlsAccountName;
             private static string _resourceGroupName;
             private static string _location;
             private static string _subId;
             private static void Main(string[] args)
                 _adlsAccountName = "<DATA-LAKE-STORE-NAME>"; 
                 _resourceGroupName = "<RESOURCE-GROUP-NAME>"; 
                 _location = "East US 2";
                 _subId = "<SUBSCRIPTION-ID>";                    

In the remaining sections of the article, you can see how to use the available .NET methods to perform operations such as authentication, file upload, etc.


Create client object

The following snippet creates the Data Lake Store account client object, which is used to issue account management requests to the service, such as create account, delete account, etc.

// Create client objects and set the subscription ID
_adlsClient = new DataLakeStoreAccountManagementClient(armCreds) { SubscriptionId = _subId };

Create a Data Lake Store account

The following snippet creates a Data Lake Store account in the Azure subscription you provided while creating the Data Lake Store account client object.

// Create Data Lake Store account
var adlsParameters = new DataLakeStoreAccount(location: _location);
_adlsClient.Account.Create(_resourceGroupName, _adlsAccountName, adlsParameters);

List all Data Lake Store accounts within a subscription

Add the following method to your class definition. The following snippet lists all Data Lake Store accounts within a given Azure subscription.

// List all Data Lake Store accounts within the subscription
public static List<DataLakeStoreAccountBasic> ListAdlStoreAccounts()
    var response = _adlsClient.Account.List(_adlsAccountName);
    var accounts = new List<DataLakeStoreAccountBasic>(response);

    while (response.NextPageLink != null)
        response = _adlsClient.Account.ListNext(response.NextPageLink);

    return accounts;

Delete a Data Lake Store account

The following snippet deletes the Data Lake Store account you created earlier.

// Delete Data Lake Store account
_adlsClient.Account.Delete(_resourceGroupName, _adlsAccountName);

See also

Next steps