Skip to content

Instantly share code, notes, and snippets.

@dazfuller
Last active October 1, 2021 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dazfuller/0740f1640225dc8ea0eb29a8e6f88a6a to your computer and use it in GitHub Desktop.
Save dazfuller/0740f1640225dc8ea0eb29a8e6f88a6a to your computer and use it in GitHub Desktop.
Azure Data Lake Gen 2 - ARM template
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "0.0.0.1",
"parameters": {
"resourcePrefix": {
"type": "string",
"minLength": 3,
"maxLength": 10,
"metadata": {
"description": "The prefix to use for resources within the resource group"
}
},
"storageSku": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS",
"Standard_RAGRS"
],
"metadata": {
"description": "Defines the type of storage account to use for the data lake store"
}
}
},
"variables": {
"storageAccountApiVersion": "[utils.apiVersion('Microsoft.Storage', 'storageAccounts')]",
"storageAccountName": "[utils.uniqueName(parameters('resourcePrefix'), 'store')]",
"storageAccountResourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
},
"functions": [
{
"namespace": "utils",
"members": {
"apiVersion": {
"parameters": [
{
"name": "providerNamespace",
"type": "string"
},
{
"name": "resourceType",
"type": "string"
}
],
"output": {
"type": "string",
"value": "[providers(parameters('providerNamespace'), parameters('resourceType')).apiVersions[0]]"
}
},
"uniqueName": {
"parameters": [
{
"name": "resourcePrefix",
"type": "string"
},
{
"name": "resourceSuffix",
"type": "string"
}
],
"output": {
"type": "string",
"value": "[concat(parameters('resourcePrefix'), uniqueString(resourceGroup().id), parameters('resourceSuffix'))]"
}
}
}
}
],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "[variables('storageAccountApiVersion')]",
"location": "[resourceGroup().location]",
"name": "[variables('storageAccountName')]",
"kind": "StorageV2",
"sku": {
"name": "[parameters('storageSku')]"
},
"properties": {
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": {
"enabled": true
},
"file": {
"enabled": true
}
}
},
"isHnsEnabled": true,
"supportsHttpsTrafficOnly": true
}
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
},
"storageAccountConnectionString": {
"type": "string",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountResourceId'), variables('storageAccountApiVersion')).keys[0].value)]"
}
}
}
Param (
[Parameter(Mandatory=$true)] [string] $ResourceGroupName,
[Parameter(Mandatory=$true)] [string] [ValidateSet("northeurope", "westeurope")] $Location,
[Parameter(Mandatory=$true)] [string] $ResourcePrefix
)
$ResourceGroup = Get-AzureRmResourceGroup -Name $ResourceGroupName -ErrorAction SilentlyContinue
if ($null -eq $ResourceGroup) {
$ResourceGroup = New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location
}
$Parameters = @{}
$Parameters["resourcePrefix"] = $ResourcePrefix
$Parameters["storageSku"] = "Standard_LRS"
$Deployment = New-AzureRmResourceGroupDeployment -Name ($ResourceGroupName + '-deployment-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) `
-ResourceGroupName $ResourceGroupName `
-TemplateFile "$($PSScriptRoot)/azuredeploy.json" `
-TemplateParameterObject $Parameters `
-Force `
-Verbose
Write-Host "Storage Account"
Write-Host "Account Name : $($Deployment.Outputs["storageAccountName"].Value)"
Write-Host "Connection String : $($Deployment.Outputs["storageAccountConnectionString"].Value)"
@dazfuller
Copy link
Author

Template can be deployed as follows:

.\deploy.ps1 -ResourceGroupName DemoResourceGroup -Location northeurope -ResourcePrefix demoadls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment