Azure getting started

From Stat DS Computing Wiki


Azure

Respectiful use of Azure resources

Ensure you’re not wasting precious department Azure credits - when you are not using your virtual machine, please shut it down (and then relaunch it when you need to use it). You can shut-down and relauch a server on the resource page. The overview for your virtual machine might look something like the image below. To turn off your machine click the “Stop” button on the “Overview” tab, and to launch your machine click the “Start” button. Every time you launch your machine it’s likely that the IP address will have changed, so use the “Connect” button to figure out the new IP address (though it is also listed on the Overview page). The “Connect” page (which appears in the second image) will also remind you of what your username for the virtual machine is.

turning on and off server to save department money

connecting to your server's IP address when it changes

Getting started: create an Azure virtual machine

Creating a Resource

You will need to have an established Azure account, which no longer can be done through department resources as of Summer 2025. Creating a virtual on Azure can be a bit complicated (which is why other resources like the department servers are available for certain types of computing).

The first thing to do is click the “create a resource” button on your azure home page (should look something like this:)

create new server button

You can also do so in the All resources > + Create

 


For statistical computing we select a resource from the AI + Machine Learning tab on the left side and then select Data Science Virtual Machine - Ubuntu 18.04 for a linux virtual machine. This selection will look something like the image below:

Selecting which type of virtual server to use

Defining your Resource

There are a lot of options to create your resource, but you can ignore a lot of these.

Basics

Below is 2 images of the first “Basics” page. You will need to

  1. Fill out / select your “Resource group”
  2. Define your “Virtual machine name” (might we recommend (username)-(CPU/GPU)-cores(#)-(RAM)-(index). For example “bpleroy-GPU-cores4-27-1”.
  3. Select the size of the machine (relative to it’s cores and types of cores). You will see available options. You can also click "see all images" to explore a list of options. If you are looking for GPU in this list filter by "family" and "GPU" for the family.
  4. Finally, we recommend using a ssh public key (which will be downloaded at the end of the set-up process). We recommend you change your “Username” to your andrew ID but you can leave it as “azureuser” if you’d like (we recommend such things since you may forget and it's natural to have it consistent across your servers).

setting up new server, basic page (1)

setting up new server, basic page (2)

Disks

The second pages is about “Disks” although creating storage on Azure is complicated it’s a very necessary procedure. Click “Create and attache a new disk”. You will then have to select the right size. Generally, disks smaller than 512 GB are cheap for the department but 1 TB + are more costly. You personal computer likely has between 128 - 512 GB (maybe 1TB), but it’s really unlikely you’ll need too much for your project.

creating a disk

 

Network and Management

There isn’t really anything necessary for you to do on these tabs.

Advanced

If you are using GPUs you’ll need to add the NVDIA extension for GPUs.

Tags are also not necessary

Done?

You did it! Save your ssh key (.pem file) in a location where you plan to call the server from. Also note that you will still need to correctly link your data disk you just created (which is discussed in the next step).

Connecting your data disk

This process is slightly complex (and can have implications if you don’t do it correctly). We recommend you follow the azure docs.

step 1: finding and identifying your disk

on the server run something like:

 

lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"

you should see a list something like this:

 

sda     3:0:0:0      128G
sdb     0:0:0:0      150G
├─sdb1             149.9G /
├─sdb14                4M
└─sdb15              106M /boot/efi
sdc     1:0:1:0      176G
└─sdc1               176G /mnt

now, on portal for the same VM, look at your disks (left side: Settings > Disks) and examine the size of your disk you added (for mine it’s 128G). As such we can conclude that my disk that needs mounting is sda (this might not be the same for you - and is not the same in the azure docs).

step 2: partitioning a new disk

Copied form the azure docs (but changed for my disk name)

 

sudo parted /dev/sda --script mklabel gpt mkpart xfspart xfs 0% 100%
sudo mkfs.xfs /dev/sda1
sudo partprobe /dev/sda1

step 3: mount the disk

Create a directory to mount the file system using mkdir. The following example creates a directory at /datadrive:

 

sudo mkdir /datadrive

Use mount to then mount the filesystem. The following example mounts the /dev/sda1 partition to the /datadrive mount point:

 

sudo mount /dev/sda1 /datadrive

Now we have:

 

lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
sda     3:0:0:0      128G
└─sda1               128G /datadrive
sdb     0:0:0:0      150G
├─sdb1             149.9G /
├─sdb14                4M
└─sdb15              106M /boot/efi
sdc     1:0:1:0      176G
└─sdc1               176G /mnt

step 4: …

 

sudo blkid
/dev/sdb1: LABEL="cloudimg-rootfs" UUID="1fe704c3-9cec-4cb5-b634-2e46f6bd9f90" TYPE="ext4" PARTUUID="318ec118-9248-4203-9cd5-7cb8c36f04d6"
/dev/sdb15: LABEL="UEFI" UUID="52A4-029B" TYPE="vfat" PARTUUID="2332d2b4-222e-425d-866e-227b42f3979d"
/dev/sdc1: UUID="9cc09cc7-c65d-4fe4-a397-75679a438c1c" TYPE="ext4" PARTUUID="2b584de2-01"
/dev/sda1: UUID="a2ba271d-e5a4-4416-84d2-b9408864b53b" TYPE="xfs" PARTLABEL="xfspart" PARTUUID="77452866-0b43-4485-9956-673377498608"

step 5: creating alias link to datadrive

To create a symbolic link to your a workspace folder to the /datadrive you can do the following.

 

ln -s /datadrive ~/workspace

Afterwards, everything in the workspace will actually be stored on your new /datadrive.

step 6: making sure you have correct permissions

ls -al / (might show you don’t have access (write, read, execute) to the /datadrive), so we did

sudo chmod 777 datadrive …

https://www.hostinger.com/tutorials/how-to-create-symbolic-links-in-linux/

Connecting to your server and moving files

To connect to your server you will need to know (1) where you're ssh key is (often called _server_name_.pem (this should have been downloaded at the end of the creation of your server). Note that the first time your connect you need to make sure you have the correct permissions - see the connect page for the correct cmod command you need to use! (2) your username defined in the Basics step

You will also need to know what IP address your server is currently using. This can before on the connect page of your server (as seen in the second image in this article). Then you're type something like

 

ssh -i _my_ssh_key_.pem _user_name_@_IP_address_

To pass files to and from your server with scp, we will imagine you are on your home computer. Then do as follows:

  1. server to local
    scp -i _my_ssh_key_.pem _user_name_@_IP_address_:/full/path/to/files/on/server/my_script.R /local/path/to/files/on/local/computer/
  1. local to server
    scp -i _my_ssh_key_.pem /local/path/to/files/on/local/computer/my_script.R _user_name_@_IP_address_:/full/path/to/files/


To pass directories (and do the full thing you'll need to do the same as above but add

 

scp -i _my_ssh_key.pem -r ...