Skip to content

Instantly share code, notes, and snippets.

@codexponent
Last active February 6, 2021 09:32
Show Gist options
  • Select an option

  • Save codexponent/948f3cfb8055b8aec82a5750f8851a6e to your computer and use it in GitHub Desktop.

Select an option

Save codexponent/948f3cfb8055b8aec82a5750f8851a6e to your computer and use it in GitHub Desktop.
Mounting the Azure File Share with Azure Virtual Machine
#!/bin/sh
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
sudo apt update
sudo apt install cifs-utils
mkdir data
az login
resourceGroupName="<your-resource-group>"
storageAccountName="<your-storage-account>"
fileShareName="<your-file-share>"
mntPath="/home/azureuser/data/$storageAccountName/$fileShareName"
sudo mkdir -p $mntPath
httpEndpoint=$(az storage account show \
--resource-group $resourceGroupName \
--name $storageAccountName \
--query "primaryEndpoints.file" | tr -d '"')
smbPath=$(echo $httpEndpoint | cut -c7-$(expr length $httpEndpoint))$fileShareName
storageAccountKey=$(az storage account keys list \
--resource-group $resourceGroupName \
--account-name $storageAccountName \
--query "[0].value" | tr -d '"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment