Skip to content

Instantly share code, notes, and snippets.

Embed
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 http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/
#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
$containerName = "DEFAULT_CONTAINER_NAME"
$storageLocation = "Southeast Asia"
$creds = Get-Credential
#create config
#note that config value is fs.azure.sas.CONTAINER.ACCOUNT =Signature
$config = New-AzureHDInsightClusterConfig -ClusterSizeInNodes $clusterNodes |
Set-AzureHDInsightDefaultStorage -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey -StorageContainerName $containerName |
Add-AzureHDInsightConfigValues -Core @{
"fs.azure.sas.$sasContainerName.$sasStorageAccountName.blob.core.windows.net"=$sas;
}
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
You can’t perform that action at this time.