Get started with Azure Data Lake Analytics using Azure PowerShell

Learn how to use Azure PowerShell to create Azure Data Lake Analytics accounts and then submit and run U-SQL jobs. For more information about Data Lake Analytics, see Azure Data Lake Analytics overview.


Before you begin this tutorial, you must have the following information:

Log in to Azure

This tutorial assumes you are already familiar with using Azure PowerShell. In particular, you need to know how to log in to Azure. See the Get started with Azure PowerShell if you need help.

To log in with a subscription name:

Login-AzureRmAccount -SubscriptionName "ContosoSubscription"

Instead of the subscription name, you can also use a subscription id to log in:

Login-AzureRmAccount -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

If successful, the output of this command looks like the following text:

Environment           : AzureCloud
Account               :
TenantId              : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
SubscriptionId        : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
SubscriptionName      : ContosoSubscription
CurrentStorageAccount :

Preparing for the tutorial

The PowerShell snippets in this tutorial use these variables to store this information:

$rg = "<ResourceGroupName>"
$adls = "<DataLakeStoreAccountName>"
$adla = "<DataLakeAnalyticsAccountName>"
$location = "East US 2"

Get information about a Data Lake Analytics account

Get-AdlAnalyticsAccount -ResourceGroupName $rg -Name $adla  

Submit a U-SQL job

Create a PowerShell variable to hold the U-SQL script.

$script = @"
@a  = 
            ("Contoso", 1500.0),
            ("Woodgrove", 2700.0)
        ) AS 
              D( customer, amount );
    TO "/data.csv"
    USING Outputters.Csv();


Submit the script.

$job = Submit-AdlJob -Account $adla -Name "My Job" –Script $script

Alternatively, you could save the script as a file and submit with the following command:

$filename = "d:\test.usql"
$script | out-File $filename
$job = Submit-AdlJob -Account $adla -Name "My Job" –ScriptPath $filename

Get the status of a specific job. Keep using this cmdlet until you see the job is done.

$job = Get-AdlJob -Account $adla -JobId $job.JobId

Instead of calling Get-AdlAnalyticsJob over and over until a job finishes, you can use the Wait-AdlJob cmdlet.

Wait-AdlJob -Account $adla -JobId $job.JobId

Download the output file.

Export-AdlStoreItem -Account $adls -Path "/data.csv" -Destination "C:\data.csv"

See also