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.



This article has been updated to use the Azure Az PowerShell module. The Az PowerShell module is the recommended PowerShell module for interacting with Azure. To get started with the Az PowerShell module, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

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:

Connect-AzAccount -SubscriptionName "ContosoSubscription"

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

Connect-AzAccount -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 text with the Submit-AdlJob cmdlet and the -Script parameter.

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

As an alternative, you can submit a script file using the -ScriptPath parameter:

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

Get the status of a job with Get-AdlJob.

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

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

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

Download the output file using Export-AdlStoreItem.

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

See also