Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PCfromDCSnippets/de51108a6cc5b7721a9e40d03bb2a381 to your computer and use it in GitHub Desktop.
Save PCfromDCSnippets/de51108a6cc5b7721a9e40d03bb2a381 to your computer and use it in GitHub Desktop.
Create Storage Context and File Share
#region Create File Share
# Get Storage Key
$key = ($sa | Get-AzureRmStorageAccountKey).Value | Select -First 1
# Create Context
$ctx = New-AzureStorageContext -StorageAccountName $storageAccountName.ToLower() -StorageAccountKey $key
$csa = Set-AzureRmCurrentStorageAccount -Context $ctx
# Create File Share
$ss = Get-AzureRmStorageAccount | Get-AzureStorageShare | Where-Object {$_.Name -eq $fileShareName.ToLower()}
if ($ss.count -gt 0) {
Write-Host("$fileShareName file share already exists...")
}
else {
Write-Host("Creating $fileShareName file share...")
$ss = New-AzureStorageShare -Name $fileShareName.ToLower() -Context $ctx
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment