Azure is a great place to host a Linux VPS. In this video, explore the options available to you and learn how to connect to a remote Azure instance.
- [Instructor] Let's take a look at using Linux on Azure. Azure is Microsoft's cloud platform. And it might surprise you to learn that as of 2017, 40% of the machines running in Azure, were Linux. You can connect to Azure in your browser by visiting portal.azure.com. And there you can sign up for a free introductory account or for a paid account. I won't go through the steps to create an account here, but once you've done that you can jump into the management interface called the Dashboard. To create a virtual machine to use, click on Create a Resource.
And here, you can see some recommended machine images to use. I can search or just use one of these. I'll choose Ubuntu Server 18.04. In the create virtual machine blade, we have four steps to go through. The first blade sets up the basics. The name, which I'll set. And the storage, the type of hard disk that the machine runs from. SSD is fast but is a little bit more expensive. And HDD is magnetic storage and is a little cheaper.
For learning and experimenting, HDD is totally fine. But for serving an application that needs performance, you may want to use SSD. You can switch between modes later, too. Then you're asked for a username. The user you'll use to log into the machine. After that, you can choose whether to connect with a key or with a password. A key is more secure and if you're going to be connecting from a terminal on your machine, it's a good idea to use one. But to use the Azure cloud shell, it's easier to use a password. Just make sure you set a secure one.
If you use a password, it's a good idea to shut down your VM when you're not using it. To keep things easy here, I'll set a password. You can choose which subscription to apply the cost of this machine to. And because resources on Azure are managed in groups, we need to create a new resource group on a brand new account. And then we can choose where the resources are located. You'll want to select a region that's physically closest to you, in order to help improve response times. There's no reason to access your machine from halfway across the world.
With that blade filled out, you can choose what size of machine to create. When that blade's filled out, you can continue and choose which size of machine to create. Azure machines come with a set of predefined resources. Virtual CPUs, memory, and storage. And you can see what the monthly cost is estimated to be, as well. The free account allocates a few hundred dollars to these resources. So even though it looks like you'll be charged immediately, you'll have to run through that credit before you actually owe money. I'll pick the smallest one here.
That's fine for exploring the command line and learning about configuration and system operations. If you need to use a machine that's optimized for some metric, there are machines that have more memory or more CPUs, more storage, and so on. But the general purpose images are fine for getting started. I'll click select. Here I'm given options for high availability and I'm given the opportunity again, to choose what kind of storage medium I want to use. I'll scroll past that, down to Network.
We can configure virtual network settings but I'll leave these as they are. To get started, we don't need fancy network settings, but if you're building out a more complex system, you may need to change these settings. And I can choose whether to open up public outbound ports. I'll choose port 22 for SSH so we can connect from a client later on. We can also choose to have the machine shut down automatically at a specific time every day. Depending on how you plan to use your VM, you might want to turn this on.
I'll click on CloudMine. This shows me the status of the machine and some other information. Like the IP address of the machine. Below that, there are some graphs for activity of various kinds. Which can be kind of interesting to watch. I'll copy this IP address, which, keep in mind is a real public IP address exposed to the internet. And I'll switch to my terminal application and connect via SSH. On recent versions of Windows 10, on Mac OS, and on Linux, you'll have SSH available.
On older versions of Windows, you'll need to use a program like PuTTY to connect via SSH. So I'll write ssh, the username that I set up in the configuration step, and I'll paste in the IP address. I'll accept the key and type in the password that I set. Again, if you're going to be using this machine for anything sensitive, or if you're going to be keeping it online for awhile, it's better to use a key to connect. I'm logged in. Let's take a look at things.
I'll take a look at how much memory I have, how much disk space I have, what the CPU looks like, and some information about the kernel. Not luxurious, but not bad. This will definitely be enough to explore Linux and learn about the command line. I can connect to this machine from any machine that has SSH installed. And pick up right where I left off before. No need to have a virtual machine or dedicated hardware. And that's pretty handy. I can install software, change configurations, and so on.
Just remember, if you install something that needs firewall access, you'll need to open ports both locally, on this VM's firewall and you'll also need to visit the networking section of the machine's configuration. And add rules allowing access through ports there, as well. For now, I'll close this terminal session. I'll type exit. And that disconnects me from my machine. I want to show you another option for accessing this machine which is pretty neat. I'll go back to the Dashboard and here on my machine details, I'll scroll down toward the bottom to serial console.
This shows a console window here in the browser, just like a regular text console for a physical machine with a display. It takes a moment to connect and from time to time you'll see some diagnostic information get printed to the screen. I'll press Enter and log in with my username and password. And here's my system. So if you don't have access to terminal software, you can just use the browser to connect to your Azure machine.
I want to make one note here. If you shut down your virtual machine from the command line, it'll still be taking up resources. To remove the resources it's using, and stop incurring some charges, you need to stop the machine from the Dashboard. Which will deallocate it. And if you decide that you don't need a VM anymore, you can delete it. Just remember to delete its resource group, as well. Have fun with your new virtual machine. And be sure to keep an eye on costs.
Note: Because this is an ongoing series, viewers will not receive a certificate of completion.