Get started with Azure Data Lake Storage Gen1 using Azure PowerShell
Azure Data Lake Store has been renamed to Azure Data Lake Storage Gen1. If you're interested in learning about the preview of Azure Data Lake Storage Gen2, see the product page.
Learn how to use Azure PowerShell to create an Azure Data Lake Storage Gen1 account and perform basic operations such as create folders, upload and download data files, delete your account, etc. For more information about Data Lake Storage Gen1, see Overview of Data Lake Storage Gen1.
- An Azure subscription. See Get Azure free trial.
- Azure PowerShell 1.0 or greater. See How to install and configure Azure PowerShell.
This article uses a simpler authentication approach with Data Lake Storage Gen1 where you are prompted to enter your Azure account credentials. The access level to Data Lake Storage Gen1 account and file system is then governed by the access level of the logged in user. However, there are other approaches as well to authenticate with Data Lake Storage Gen1, which are end-user authentication or service-to-service authentication. For instructions and more information on how to authenticate, see End-user authentication or Service-to-service authentication.
Create a Data Lake Storage Gen1 account
From your desktop, open a new Windows PowerShell window. Enter the following snippet to log in to your Azure account, set the subscription, and register the Data Lake Storage Gen1 provider. When prompted to log in, make sure you log in as one of the subscription administrators/owner:
# Log in to your Azure account Connect-AzureRmAccount # List all the subscriptions associated to your account Get-AzureRmSubscription # Select a subscription Set-AzureRmContext -SubscriptionId <subscription ID> # Register for Azure Data Lake Storage Gen1 Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.DataLakeStore"
A Data Lake Storage Gen1 account is associated with an Azure Resource Group. Start by creating an Azure Resource Group.
$resourceGroupName = "<your new resource group name>" New-AzureRmResourceGroup -Name $resourceGroupName -Location "East US 2"
Create a Data Lake Storage Gen1 account. The name you specify must only contain lowercase letters and numbers.
$dataLakeStorageGen1Name = "<your new Data Lake Storage Gen1 account name>" New-AzureRmDataLakeStoreAccount -ResourceGroupName $resourceGroupName -Name $dataLakeStorageGen1Name -Location "East US 2"
Verify that the account is successfully created.
Test-AzureRmDataLakeStoreAccount -Name $dataLakeStorageGen1Name
The output for the cmdlet should be True.
Create directory structures in your Data Lake Storage Gen1 account
You can create directories under your Data Lake Storage Gen1 account to manage and store data.
Specify a root directory.
$myrootdir = "/"
Create a new directory called mynewdirectory under the specified root.
New-AzureRmDataLakeStoreItem -Folder -AccountName $dataLakeStorageGen1Name -Path $myrootdir/mynewdirectory
Verify that the new directory is successfully created.
Get-AzureRmDataLakeStoreChildItem -AccountName $dataLakeStorageGen1Name -Path $myrootdir
It should show an output as shown in the following screenshot:
Upload data to your Data Lake Storage Gen1 account
You can upload your data to Data Lake Storage Gen1 directly at the root level, or to a directory that you created within the account. The snippets in this section demonstrate how to upload some sample data to the directory (mynewdirectory) you created in the previous section.
If you are looking for some sample data to upload, you can get the Ambulance Data folder from the Azure Data Lake Git Repository. Download the file and store it in a local directory on your computer, such as C:\sampledata.
Import-AzureRmDataLakeStoreItem -AccountName $dataLakeStorageGen1Name -Path "C:\sampledata\vehicle1_09142014.csv" -Destination $myrootdir\mynewdirectory\vehicle1_09142014.csv
Rename, download, and delete data from your Data Lake Storage Gen1 account
To rename a file, use the following command:
Move-AzureRmDataLakeStoreItem -AccountName $dataLakeStorageGen1Name -Path $myrootdir\mynewdirectory\vehicle1_09142014.csv -Destination $myrootdir\mynewdirectory\vehicle1_09142014_Copy.csv
To download a file, use the following command:
Export-AzureRmDataLakeStoreItem -AccountName $dataLakeStorageGen1Name -Path $myrootdir\mynewdirectory\vehicle1_09142014_Copy.csv -Destination "C:\sampledata\vehicle1_09142014_Copy.csv"
To delete a file, use the following command:
Remove-AzureRmDataLakeStoreItem -AccountName $dataLakeStorageGen1Name -Paths $myrootdir\mynewdirectory\vehicle1_09142014_Copy.csv
When prompted, enter Y to delete the item. If you have more than one file to delete, you can provide all the paths separated by comma.
Remove-AzureRmDataLakeStoreItem -AccountName $dataLakeStorageGen1Name -Paths $myrootdir\mynewdirectory\vehicle1_09142014.csv, $myrootdir\mynewdirectoryvehicle1_09142014_Copy.csv
Delete your Data Lake Storage Gen1 account
Use the following command to delete your Data Lake Storage Gen1 account.
Remove-AzureRmDataLakeStoreAccount -Name $dataLakeStorageGen1Name
When prompted, enter Y to delete the account.