Quickstart: Create an Azure Synapse Analytics workspace with Azure PowerShell

Azure PowerShell is a set of cmdlets for managing Azure resources directly from PowerShell. You can install it on macOS, Linux, or Windows.

In this quickstart, you learn to create an Azure Synapse Analytics workspace by using Azure PowerShell.

If you don't have an Azure subscription, create a trial Azure account before you begin.

Prerequisites

  • Azure Data Lake Storage Gen2 storage account

    Important

    An Azure Synapse Analytics workspace needs to be able to read and write to the selected Azure Data Lake Storage Gen2 account. For any storage account that you link as the primary storage account, you must enable hierarchical namespace at the creation of the storage account as described in Create a storage account.

Install the Azure PowerShell module locally

If you choose to use PowerShell locally, this article requires that you install the Az PowerShell module and connect to your Azure account by using the Connect-AzAccount cmdlet. For more information about installing the Az PowerShell module, see Install Azure PowerShell.

For more information about authentication with Azure PowerShell, see Sign in with Azure PowerShell.

Install the Azure Synapse PowerShell module

Important

While the Az.Synapse PowerShell module is in preview, you must install it separately by using the Install-Module cmdlet. After this PowerShell module becomes generally available, it will be part of future Az PowerShell module releases.

Install-Module -Name Az.Synapse

Create an Azure Synapse Analytics workspace by using Azure PowerShell

  1. Define necessary environment variables to create resources for an Azure Synapse Analytics workspace.

    Variable name Description
    StorageAccountName Name for your existing Azure Data Lake Storage Gen2 storage account.
    StorageAccountResourceGroup Name of your existing Azure Data Lake Storage Gen2 storage account resource group.
    FileShareName Name of your existing storage file system.
    SynapseResourceGroup Choose a new name for your Azure Synapse Analytics resource group.
    Region Choose one of the Azure regions.
    SynapseWorkspaceName Choose a unique name for your new Azure Synapse Analytics workspace.
    SqlUser Choose a value for a new username.
    SqlPassword Choose a secure password.
    ClientIP Public IP address of the system you're running PowerShell from.
  2. Create a resource group as a container for your Azure Synapse Analytics workspace:

    New-AzResourceGroup -Name $SynapseResourceGroup -Location $Region
    
  3. Create an Azure Synapse Analytics workspace:

    $Cred = New-Object -TypeName System.Management.Automation.PSCredential ($SqlUser, (ConvertTo-SecureString $SqlPassword -AsPlainText -Force))
    
    $WorkspaceParams = @{
      Name = $SynapseWorkspaceName
      ResourceGroupName = $SynapseResourceGroup
      DefaultDataLakeStorageAccountName = $StorageAccountName
      DefaultDataLakeStorageFilesystem = $FileShareName
      SqlAdministratorLoginCredential = $Cred
      Location = $Region
    }
    New-AzSynapseWorkspace @WorkspaceParams
    
  4. Get the web and dev URLs for Azure Synapse Analytics workspace:

    $WorkspaceWeb = (Get-AzSynapseWorkspace -Name $SynapseWorkspaceName -ResourceGroupName $StorageAccountResourceGroup).ConnectivityEndpoints.web
    $WorkspaceDev = (Get-AzSynapseWorkspace -Name $SynapseWorkspaceName -ResourceGroupName $StorageAccountResourceGroup).ConnectivityEndpoints.dev
    
  5. Create a firewall rule to allow access to your Azure Synapse Analytics workspace from your machine:

    $FirewallParams = @{
      WorkspaceName = $SynapseWorkspaceName
      Name = 'Allow Client IP'
      ResourceGroupName = $StorageAccountResourceGroup
      StartIpAddress = $ClientIP
      EndIpAddress = $ClientIP
    }
    New-AzSynapseFirewallRule @FirewallParams
    
  6. Open the Azure Synapse Analytics workspace web URL address stored in the environment variable WorkspaceWeb to access your workspace:

    Start-Process $WorkspaceWeb
    

    Screenshot that shows the Azure Synapse Analytics workspace web.

  7. After it's deployed, more permissions are required.

Clean up resources

Follow these steps to delete the Azure Synapse Analytics workspace.

Warning

Deleting an Azure Synapse Analytics workspace removes the analytics engines and the data stored in the database of the contained SQL pools and workspace metadata. It will no longer be possible to connect to the SQL or Apache Spark endpoints. All code artifacts will be deleted (queries, notebooks, job definitions, and pipelines).

Deleting the workspace won't affect the data in the Azure Data Lake Storage Gen2 account linked to the workspace.

If the Azure Synapse Analytics workspace created in this article isn't needed, you can delete it by running the following example:

Remove-AzSynapseWorkspace -Name $SynapseWorkspaceNam -ResourceGroupName $SynapseResourceGroup

Next, you can create SQL pools or create Apache Spark pools to start analyzing and exploring your data.