Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Creating an HDInsight Cluster using a SAS protected storage container
#This script lets you access data in a second storage account, where you are only granted access
#via a Shared Access Signature to a given container
#For more details on SAS, see this
#Configure SAS key
$sasStorageAccountName = "YOUR_STORAGE_ACCCOUNT_NAME"
$sasContainerName = "YOUR_SAS_CONTAINER_NAME"
$context = New-AzureStorageContext -StorageAccountName $sasStorageAccountName -StorageAccountKey (Get-AzureStorageKey -StorageAccountName $sasStorageAccountName).Primary
$sas = New-AzureStorageContainerSASToken -Name $sasContainerName -Permission rl -Context $context -ExpiryTime (get-date).AddDays(3)
#Configure Cluster
$clusterDnsName = "YOUR_CLUSTER_NAME"
$clusterNodes = 4
$storageAccountName = "DEFAULT_STORAGE_ACCOUNT"
$storageAccountKey = (Get-AzureStorageKey -StorageAccountName $storageAccountName).Primary
$storageLocation = "Southeast Asia"
$creds = Get-Credential
#create config
#note that config value is =Signature
$config = New-AzureHDInsightClusterConfig -ClusterSizeInNodes $clusterNodes |
Set-AzureHDInsightDefaultStorage -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey -StorageContainerName $containerName |
Add-AzureHDInsightConfigValues -Core @{
New-AzureHDInsightCluster -Config $config -Credential $creds -Name $clusterDnsName -Location $storageLocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment