Creating
a virtual machine on Azure or any cloud is easy peasy, but can be
overwhelming for the ones starting the journey to the cloud, so here I
give you a simple tutorial on how to deploy a virtual machine on Azure
Cloud.
1. Sign in or Create an account on Azure Cloud Portal
To get started you need to Sign in
to your Microsoft Azure Account or create a new one. Azure will give
you $200 credits if you haven't created an account before, so you can
start using it for whatever you want eg, this tutorial.
2. Create a Virtual Machine
In the Azure Portal go to Virtual Machines and click on Add > New Virtual Machine.
On the Basics tabs we are going to fill the following fields
A Resource Group is a virtual collection of resources that shares the
same policies, you can create as many RG as you want....it's free.
If
you click on the image list you will see a Windows, Linux, and Oracle
images you can choose any of them but for now I will choose Ubuntu
Server.
the
region is very important it tells azure in which datacenter deploys the
VM, this affects mainly 2 things, the price of the VM and also the
latency when you connect to it or when other resources use it, so pick
up the closes one to you.
Subscription -> Your Subscription
Resource Group -> Create a new one “rg-eus2-demo"
Virtual Machine Name -> “vm-eus2-demo"
Region -> East US 2 (you can choose the region closer to you)
Image -> Ubuntu Server 18.04 LTS
Size -> Standard_B2s (2 vcpus, 4Gib Ram) its hourly cost if $0.04/hour
Next, we will configure the Administrator Account
As
you can see there are 2 methods for the connection SSH public key and
password, you can use any of them but in terms of security, you should
store the password or the private key in some vault like Azure Key
Vault.
Here I'm going to authenticate using SSH public key
Authentication type -> SSH public key
Username -> demouser
Key pair name -> ssh-key-eus2-demo
Next we are going to configure inbound rules, this is basically which ports are we going to expose to the outside.
Im going to expose Http, Https and SSH.
When
we click on Next: Disks we can see that it is selected Premiun SSD by
default, this will make your VM boot or run disk operations faster but
the final cost of the VM increases, so im going to choose Standard HDD
if
you look at Data Disk you can create or attach an existing disk to the
VM or maybe acquire more space than the predefined one.
Next
in Networking we can define the Type of IP Address, public or dynamic,
and the vnet/subnet that the VM is going to use, if have created one
previously you can use it, if not Azure will create this resource for
you.
One
important thing to notice is the creation of a NSG Network Security
Group, this is a fine grade tuning of the network policies but applied
to a group of resources.
In the monitoring tab we can define where we are going to store logs and operations of the VM
As
you can see the subscription is protected by Azure Security Center by
default and Azure will create a log storage account for this VM,
something I like to enable is the use of Identity, that way other
resources can use this machine (Role-Based) and I don't need to give
them passwords or users.
something
you would like to enable is the automatic shutdown, this is a demo VM
and I don't want it to be on when I'm not using it, this will save some
credits for me...
Next
jump to Tags, tags is a way to group resources that share some feature
in common, like the resuources of a project, this way you can filter
them easily in the Cost Management menu.
If everything has been done correctly you will see the Validation Passed message and you are ready to create you VM.
Because I will use ssh for the connection Azure gives me the option to download the private key.
After a minute or two you will end up with something like this inside your Resource Group.
Now let's connect to the VM.
Linux:
Copy
your private key to ~/.ssh folder, then assign read-only permission to
it, and then connect to the VM using the ssh command, the public IP of
your VM, and username.
mv ssh-key-eus2-stackstorm.pem ~/.ssh/ssh-key-eus2-demo.pem
cd ~/.ssh
chmod 400 ssh-key-eus2-demo.pem
ssh -i ~/.ssh/ssh-key-eus2-demo.pem demouser@you-vm-ip
Windows:
Next go to SSH>Auth and browse for your primary key
Click Open and Then yes to add the fingerprint to the registry.
As you can see on the console you are now connected to the VM instance
0 comments :
Post a Comment