In this post, we will go through the PowerShell commands to create a new Data Factory. First of all, lets discuss the pre-requisites:
- Azure Subscription: To work with Azure Data Factory, we need to have the login details for Azure Subscription
- Appropriate Role Permissions: Data Factory Contributor Role on the Azure Portal at the resource group level or above and Contributor role for PowerShell at the resource level.
To know about the pre-requisites in detail, please check the Microsoft Docs reference link at the bottom of this post.
After launching PowerShell, use the three commands below to login:
# To list Azure Subscriptions Get-AzSubscription
# Select Azure Subscription Select-AzSubscription -SubscriptionId "<SubscriptionId>"
Step 1: Define a variable for the resource group name
$resourceGroupName = "ADFADESBS02RG";
Explanation: This variable name will be used in the commands later. The resourcegroup name (in double quotes) should be unique.
Step2: Create ResourceGroup
$ResGrp = New-AzResourceGroup $resourceGroupName -location 'East US'
Explanation: To create the resource group from the variable. ‘East US’ is the name of Azure Region where we want the resource group to be created.
Step 3: Create variable for DataFactory Name
$dataFactoryName = "ADFADESBS02Factory";
Explanation: Variable for storing DataFactory name, which we are going to use later. The Data Factory name should be globally unique across Azure.
Step 4: Create Data Factory
$DataFactory = Set-AzDataFactoryV2 -ResourceGroupName $ResGrp.ResourceGroupName -Location $ResGrp.Location -Name $dataFactoryName
Explanation: Run Set-AzDataFactoryV2 cmdlet using the Location and ResourceGroupName property from the $ResGrp variable