Setting up an Azure Virtual Machine
April 23, 2022Quick reference notes I compiled for setting up a virtual machine in Microsoft Azure.
Deploy Azure VM
- Virtual Machines -> Create -> Azure Virtual Machine
- Be weary of SSH public key vs Password option, and what is better suited.
- Other options are fairly self-explanatory
Afterwards,
- on Blade -> Reset Password -> Reset configuration
- on Blade -> Reset Password -> Reset password, and change the azureuser password.
SSH into VM
sudo ssh -i .ssh/azureuser azureuser@ipaddress
Create a storage account
- Storage Accounts -> Create
- Then open up the created Storage Account resource
- Blade -> Containers -> Add (private, no Anonymous access)
Install blobfuse in VM
See: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-how-to-mount-container-linux
In the spun up VM:
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install blobfuse
Setup Ramdisk
The following creates a ramdisk of 16 GB and a directory for blobfuse. Choose the size based on your needs. This ramdisk allows blobfuse to open files up to 16 GB in size.
sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs -o size=16g tmpfs /mnt/ramdisk
sudo mkdir /mnt/ramdisk/blobfusetmp
sudo chown <youruser> /mnt/ramdisk/blobfusetmp
Configure storage credentials
touch ~/fuse_connection.cfg
chmod 600 ~/fuse_connection.cfg
Add to file fuse_connection.cfg:
accountName storage_name
accountKey the_key
containerName container_name
This values will come from the storage container resources page.
Mounting
Make a new directory in the VM for mounting…
mkdir ~/mycontainer
Run blobfuse on the VM…
sudo blobfuse ~/mycontainer --tmp-path=/mnt/resource/blobfusetmp --config-file=/path/to/fuse_connection.cfg -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120
To allow access to all users, you can mount via the option -o allow_other.
Unmount
sudo umount ~/mycontainer
Testing write access
On VM, test by echoing to a file in mycontainer
cd ~/mycontainer
mkdir test
echo "hello world" > test/blob.txt
Verify working my looking in Azure container contents on portal.azure.com.
Copying file with SCP
Copying from development machine to VM:
scp file_from_dev_machine azureuser@destip:/home/azureuser