Use Azure Bastion to connect to a virtual machine

Use Azure Bastion to connect to a virtual machine

What is Azure Bastion?

According to the official MS Docs (About Azure Bastion | Microsoft Learn) Azure Bastion is a service you deploy that lets you connect to a virtual machine using your browser and the Azure portal, or via the native SSH or RDP client already installed on your local computer.?

It provides RDP/SSH connectivity to all the virtual machines in the virtual network it’s provisioned in.?

Some of the benefits of Azure Bastion are:?

  • RDP and SSH through the Azure portal?
  • No public IP address on the Azure VM?
  • No need to manage a separate bastion host?

and many others.?

Azure Bastion is deployed in a virtual network which means it supports virtual network peering.

To learn more about virtual network peering I suggest you read the following MS Docs (Azure Virtual Network peering | Microsoft Learn).

No alt text provided for this image

Creating a virtual network

Let’s start with creating a new virtual network.?

Go to the Azure portal and in the search type 'virtual networks'.?

No alt text provided for this image

Next, click on the '+ Create' button to start creating a new virtual network.

No alt text provided for this image

Fill in the details similar to below:

No alt text provided for this image

Next go to 'IP Addresses', fill in the address space and add a new subnet like in the following image:?

No alt text provided for this image

Click on 'Review + create' and finish creating the virtual network.??After it succeeds, you can go to the resource.?

No alt text provided for this image

Now it’s time to create a new virtual machine.??

Creating a virtual machine

In the Azure portal, search for 'Virtual Machines'.?

No alt text provided for this image

Click on '+ Create' to start creating a new virtual machine.?

No alt text provided for this image

Be careful when filling out the details in the next section.?

No alt text provided for this image

In the 'Networking' part, for the virtual network choose the previously created virtual network and the previously created subnet. Set the 'Public inbound ports' to 'Allow selected ports' and set 'Select inbound ports' to RDP (3389).

No alt text provided for this image

Finish creating the virtual machine.

No alt text provided for this image

Connecting to the virtual machine

Now go to the virtual machine created previously and click on the 'Connect' option on the left menu.?

No alt text provided for this image

Select RDP and download the RDP file.

No alt text provided for this image

Now double click on it and enter the credentials you specified when creating the virtual machine.

No alt text provided for this image

Observe that we have successfully connected to our virtual machine. This RDP was directly through the internet on port 3389.

No alt text provided for this image

Now let’s configure Azure Bastion.

Setting up Azure Bastion

Click on the 'Bastion' section which is located in the same menu where you clicked on 'RDP'.

No alt text provided for this image

It will give you the option to either deploy Bastion or configure it manually. For this example, we will just click on 'Deploy Bastion'.

No alt text provided for this image

Wait for the deployment to finish.

No alt text provided for this image

Now when you come back to the 'Bastion' tab it will give you the option to use Bastion.?

No alt text provided for this image

Enter the Username and Password for the virtual machine and click on 'Connect'.?

No alt text provided for this image

Observe that we connected to our virtual machine successfully through the Azure portal.

No alt text provided for this image

Next, go to 'Networking' and observe the rule 'RDP'. Let’s delete the rule.

No alt text provided for this image

Now, double click on the RDP file you downloaded and try to connect to the virtual machine. We will get the following error, because remote desktop is no longer exposed to the internet.

No alt text provided for this image

Using Bastion, try connection to the virtual machine. You will see that we are still able to connect our virtual machine.

No alt text provided for this image

Perfect. We have successfully configured and used Azure Bastion to connect to our virtual machine through the Azure portal and without having our virtual machine expose RDP/SSH ports to the outside world.?

Thanks for sticking to the end of another article from?"Iliev Talks Tech".?#ilievtalkstech

Next steps:

Frank James, MBA, PMP

Building Solutions to Drive Business Value

2 年

Nice Article Dimitar! Thanks for sharing!

要查看或添加评论,请登录

Dimitar Iliev ??的更多文章

社区洞察

其他会员也浏览了