How to create Ubuntu VM in Azure

In this article, we will see how to create a Linux virtual machine with Xfce desktop step by step. Xfce desktop is very lightweight and easy to use for a Windows user. If you don't have an Azure subscription, create a free account before you begin.

Sign in to the Azure portal.

Click on Create a resource and choose Ubuntu Server 18.04 VM

Also Read - How to connect SharePoint with PHP

In the Basics tab, under Project details, make sure the correct subscription is selected and then choose to Create new under Resource group. In the pop-up, type myResourceGroup for the name of the resource group and then choose OK.

 Give a valid Virtual Machine Name to your VM and choose region. And In the Image column it will select Ubuntu Server 18.04 VM by default. If you want to changes Size then you can change it. Then choose Authentication type as Password as in the image. If you choose SSH public type, provide an RSA public key in single line format. (It is more complicated than giving a password. So I chose Password authentication.)

Under Inbound port rules > Public inbound ports, choose Allow selected ports and then select SSH (22) , HTTP (80) , HTTPS (443) and RDP (3389) from the drop-down. 
 and click on Next: Disks

Also Read - How to change the Status (StateCode) field value in MS Dynamics 365 using JavaScript.
Also Read - How to create a clone record in MS Dynamics 365 using JavaScript


 Leave the remaining Tabs defaults.  select the Review + create button at the bottom of the page.


Also Read - How to connect Quickbooks Online using Microsoft Flow 

On the Create a virtual machine page, you can see the details about the VM you are about to create. When you are ready, select Create.


After some time our VM will be created successfully. Navigate to the   Icon. click on the go to Resouce after successfully deployment.

If you check in the inbound port rules in the Networking tab, we can see below rules are added.


Now, our VM is ready to connect with RDP and SSH.

 Now we have to option to istall Xfce desktop.

1- Using Command Promp (CMD)
2- Using PuTTY Client.

So first we will use CMD

Open CMD.  (Use window + R and Type CMD and Press Enter or Press Window Key or Click on  then search CMD/ Command Prompt )

Now go Back to Azure VM and Click on Overview Tab  and then Click On Connect.

Now Click on the SSH and then Copy Login VM using Local Account detail.

 and Paste that in the CMD and Press enter then type Yes and again press enter and Now type your Password which you created.


Now You will see like this that means you are now logged in UBUNTU.

Now, we are going to install the Xfce desktop.
Xfce is a lightweight desktop for Linux operating system.
You can get more details of Xfce from this website. Xfce Desktop
Please type below command in the CMD.
sudo apt-get update
This will check the latest version of Ubuntu and will install it from the global repository.
Now, we are going to install Xfce the desktop.
Please type the below command in the CMD.
sudo apt-get install xfce4
As we know, Xfce is a package and needs additional disk space. So it will ask for a confirmation like below.

Type  y.

Also Read - How to sync custom Fields in Outlook from SharePoint

Now, we have a desktop environment installed in our VM, configure a remote desktop service to listen for incoming connections. xrdp is an open source Remote Desktop Protocol (RDP) server that is available on most Linux distributions and works well with Xfce. Install xrdp on your Ubuntu VM as follows:
sudo apt-get install xrdp
Now we have to tell xrdp what desktop environment to use when you start your session. Configure xrdp to use Xfce as your desktop environment as follows,
echo xfce4-session >~/.xsession
Restart the xrdp service for the changes to take effect as follows:
sudo service xrdp restart

One more step -- you need to establish a remote connection.
To change access from root only to all users we simply edit the file /etc/X11/Xwrapper.config
This can be done by running the following command to make the changes.
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
You can connect our Linux VM from any of the Windows systems using RDP connection. For that, you can download the remote connection shortcut from the Azure portal.
Please click the Connect button in the overview pane and choose the RDP section as given below.


 Open RDP file. It will ask for the username and password. Please give the correct details.

Finally, our Xfce desktop is ready to use.