Created
February 21, 2021 00:25
-
-
Save GustavoAmerico/f044ee56a49d7a297dc4c2e40374f960 to your computer and use it in GitHub Desktop.
azure-storage-file-as-windows-disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script help you setting an azure storage account as a network folder or windows disk | |
# Is need Azure CLI installed | |
param( | |
[System.String] | |
$resourceGroupName = "<resource group>", | |
[System.String] | |
$storageAccountName = "<storage account name>", | |
[System.String] | |
$subscription = "<subscription name or id>", | |
[System.String] | |
$folder = "<folder create in storage account file>" | |
) | |
# Get the storage file host | |
$storageFileHost = (az storage account show -g $resourceGroupName -n $storageAccountName -o tsv --subscription $subscription --query 'primaryEndpoints.file' |%{ ([System.Uri]::new($_).Host)}); | |
# Get the first key for access storage | |
$storageKey = (az storage account keys list -g $resourceGroupName -n $storageAccountName --subscription $subscription --query '[0].value' -o tsv); | |
#Save credentials on windows vault | |
Invoke-Expression -Command ("cmdkey /add:$storageFileHost /user:AZURE\$storageAccountName /pass:$storageKey" ) | |
# Register folder as network directory | |
Invoke-Expression -Command("net use \\$storageFileHost\$folder"); | |
# TODO: save credentials on linux. | |
# run as MSSQL Server | |
#EXEC xp_cmdshell 'pwsh azure-storage-file-as-windows-disk.ps1' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment