Public/NewFatDataLake.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Function New-FatDataLake {
    [cmdletbinding()]
    param(
        [parameter(Mandatory = $true)][string]$resourceGroupName,
        [parameter(Mandatory = $true)][string]$dataLakeName,
        [parameter(Mandatory = $true)][string]$Location
    )

    Get-AzResourceGroup -Name $resourceGroupName -ErrorVariable noResourceGroup4U -ErrorAction SilentlyContinue
    if ($noResourceGroup4U) {
        Write-Verbose "Creating Resource Group $resourceGroupName"
        New-AzResourceGroup -Name $resourceGroupName -Location $Location
    }
    else {
        Write-Verbose "ResourceGroup with the name $resourceGroupName already exists."
    }
    $noDataLake4U = Test-AzDataLakeStoreAccount -resourceGroupName $resourceGroupName -Name $dataLakeName
    if ($nodatalake4u -eq $false) {
        Write-Verbose "Creating Azure DataLake $dataLakeName"
        New-AzDataLakeStoreAccount -Name $dataLakeName -resourceGroupName $resourceGroupName -Location $Location
    }
    else {
        Write-Verbose "Azure DataLake with the name $dataLakeName already exists."
    }
}