Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 36 of 47
❮Prev Next❯

Connect to VMs Securely with Azure Bastion

Module 4: Networking ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Azure Bastion is a managed service that lets you RDP and SSH to VMs on their private IPs from the Azure portal over TLS 443, so VMs need no public IP and no open 3389 or 22 to the internet. It's deployed into a subnet named exactly AzureBastionSubnet, /26 or larger, with a Standard public IP, and it reaches VMs in its own VNet and peered VNets. SKUs are Developer (free, shared, no subnet), Basic, Standard (adds host scaling, native client support with az network bastion ssh/rdp, IP-based connection, shareable links) and Premium (adds session recording and private-only deployment).

    Simulate it » No Azure account needed

    Exam objective: 4.2.3 Implement Azure Bastion. (Skills measured as of April 17, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Deploy Azure Bastion and connect to a VM with no public IP Deploy Bastion and connect to a VM with no public IP.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Search for <strong>Bastions</strong>.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Search for Bastions.
    2. Type bastions in the search bar and pick Bastions under Services.
    3. Bastion needs AzureBastionSubnet (/26 or larger) and a Standard public IP. The VMs themselves need neither.
    4. On Advanced, turn on Native client support (Standard or Premium only) if admins want to use their own SSH or RDP client.
    5. Review and Create. It takes about 10 minutes.
    6. Open the VM app01. It has no public IP. Select Connect.
    7. Choose Connect via Bastion, enter the username and key or password, and the SSH session opens in a browser tab over TLS 443.
    8. Admins can see and end sessions here. No VM exposes port 22 or 3389 to the internet.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    Admins RDP to VMs through public IPs and the logs show brute-force attempts all day.

    😊 THE SOLUTION

    Remove the public IPs and connect through Azure Bastion on private IPs.

    • Port 3389 open to the world✓ No public IP on the VM
    • Jump box to patch and secure✓ Managed PaaS host
    • Admins want their own client✓ Standard SKU with native client
    🛠️ Solved with: Azure Bastion

    Start with a question

    How does a hotel let a plumber into room 214 without giving them a master key?

    The plumber signs in at the front desk. Someone walks them up, opens 214, and stays while they work. The plumber never gets a key, and no room door faces the street.

    Azure Bastion is that front desk. Admins sign in through the Azure portal over HTTPS, and Bastion opens the RDP or SSH session to the VM’s private address. The VMs don’t need public IPs, so there’s no door on the street for attackers to try.

    Explain it like I’m 10

    The technical explanation

    How it works

    1. The admin opens the VM in the portal and selects Connect → Connect via Bastion (or runs the native client command).
    2. The browser talks to Bastion over TLS 443, after Microsoft Entra sign-in and Azure RBAC checks.
    3. Bastion opens RDP (3389) or SSH (22) to the VM’s private IP inside the VNet.

    Bastion is a hardened, managed host: no OS for you to patch, no jump box to secure.

    What you need

    RequirementDetail
    SubnetNamed exactly AzureBastionSubnet, /26 or larger (a /26 gives room for host scaling)
    Public IPStandard, static (not needed for Developer or private-only Premium)
    ReachVMs in the same VNet and in peered VNets
    VM NSGAllow 3389/22 from the AzureBastionSubnet range (or VirtualNetwork)
    PermissionsReader on the VM, its NIC and the Bastion resource

    If you put an NSG on AzureBastionSubnet itself, it needs specific rules (inbound 443 from Internet and from GatewayManager, outbound to the VNet on 3389/22, to AzureCloud on 443, and so on). Route tables aren’t supported on that subnet.

    SKUs

    FeatureDeveloperBasicStandardPremium
    Portal RDP/SSH✅✅✅✅
    Dedicated host, peered VNetsNo✅✅✅
    Host scaling (2 to 50 instances)NoNo✅✅
    Native client (az network bastion ssh/rdp)NoNo✅✅
    IP-based connection, shareable linkNoNo✅✅
    Session recording, private-only deploymentNoNoNo✅

    You can upgrade a SKU in place but not downgrade. Price feel: Basic is around $0.19 an hour plus outbound data (illustrative), Standard costs more per hour plus per extra instance.

    Portal and CLI

    Portal: create AzureBastionSubnet in the VNet, then Bastions → + Create (tier, instance count, VNet, public IP) and on Advanced tick Native client support if needed. You can also choose Enable Azure Bastion on the Security tab when creating a VNet.

    az network vnet subnet create -g rg-net-paas --vnet-name vnet-paas -n AzureBastionSubnet --address-prefixes 10.30.3.0/26
    az network public-ip create -g rg-net-paas -n pip-bastion --sku Standard --allocation-method Static
    az network bastion create -g rg-net-paas -n bas-paas --vnet-name vnet-paas \
      --public-ip-address pip-bastion --sku Standard --enable-tunneling true --location eastus
    az network bastion ssh -g rg-net-paas -n bas-paas --target-resource-id <vm-resource-id> \
      --auth-type AAD
    az network bastion update -g rg-net-paas -n bas-paas --scale-units 4

    PowerShell: New-AzBastion -ResourceGroupName rg-net-paas -Name bas-paas -PublicIpAddress $pip -VirtualNetwork $vnet -Sku Standard.

    Architect level Bastion or just-in-time VM access?

    Microsoft Defender for Cloud’s just-in-time access opens a management port on the NSG for a short time to one source IP. It reduces exposure but still needs a public IP on the VM. Bastion removes the public exposure entirely. Many teams use Bastion for everyday admin and keep VPN or ExpressRoute for bulk access from the office.

    Real-world business scenario

    Manufacturing

    Fabrikam Manufacturing (fictional)

    The problem
    Every factory-floor VM had a public IP with RDP open so contractors could support it. The security team counted 40,000 failed sign-ins a day.
    What they used
    Azure Bastion Standard in the hub VNet with native client support, peered to every factory spoke. Public IPs removed from VMs, and spoke NSGs allow 3389 and 22 only from the AzureBastionSubnet range.
    Why that choice
    Contractors still connect, through the portal or their own clients, but no VM is reachable from the internet.
    The result
    Failed sign-in attempts on VMs dropped to zero, and the audit log shows who opened every session.

    When to use it and when not to

    ✓ Use it when…

    • Admins need RDP or SSH to VMs that must not have public IPs.
    • A hub and spoke network where one Bastion can serve every peered VNet.
    • Contractors who need access without VPN clients (shareable links on Standard).

    ✕ Think twice when…

    • Connecting whole offices or apps to a VNet. Use a VPN gateway or ExpressRoute.
    • Expecting native client or host scaling on Basic.
    • Tiny subnets: anything smaller than /26 fails.

    ↔ Alternatives to consider

    • Point-to-site VPN when admins need full network access, not just RDP/SSH.
    • Just-in-time VM access in Defender for Cloud to open ports briefly.
    • Bastion Developer for free, one-at-a-time access in dev and test.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    You plan to deploy Azure Bastion to VNet1. Which subnet configuration should you create?

    Question 2

    Question 2 of 5

    Administrators must connect to Azure VMs by using the native SSH client on their workstations through Azure Bastion. Which Bastion configuration meets the requirement?

    Question 3

    Question 3 of 5

    Azure Bastion is deployed in a hub virtual network. VM1 is in a spoke virtual network that is peered with the hub. VM1 has no public IP address. Can administrators use the Bastion host to connect to VM1?

    Question 4

    Question 4 of 5

    You deploy Azure Bastion. Administrators cannot connect to VM1 through Bastion. The subnet of VM1 has an NSG. Which inbound rule should the NSG include?

    Question 5

    Question 5 of 5 · Select 2

    Which two features require the Standard or Premium SKU of Azure Bastion? Each correct answer presents a complete solution.

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Why use Azure Bastion instead of giving each VM a public IP?

    Model answer

    With a public IP and port 3389 or 22 open, the VM is exposed to the whole internet and gets brute-force attempts within minutes. Bastion keeps the VMs private. Admins connect to Bastion over HTTPS, and Bastion opens RDP or SSH to the VM's private IP.

    Intermediate What does Bastion need to deploy?

    Model answer

    A subnet named exactly AzureBastionSubnet in the VNet, at least /26, and a Standard static public IP (except the Developer SKU). It's billed per hour plus outbound data, so I usually put one in the hub and let it serve peered spokes.

    Experienced developer An admin wants to SSH from their laptop terminal through Bastion. What do you set up?

    Model answer

    Upgrade Bastion to Standard or Premium and enable native client support. Then the admin runs az network bastion ssh with the VM's resource ID, or az network bastion rdp on Windows. Basic only supports connecting from the portal.

    Scenario Bastion is in the hub, but you can't connect to a VM in a spoke. What do you check?

    Model answer

    That the spoke is peered with the hub and both links are Connected. Then the NSG on the VM's subnet: it must allow 3389 or 22 from the AzureBastionSubnet range. And that the VM is running and the user has Reader on the VM, its NIC and the Bastion resource.

    Quick revision

    Key points

    • Bastion gives RDP/SSH over TLS 443 to private IPs. VMs need no public IP.
    • AzureBastionSubnet, exact name, /26 or larger, plus a Standard public IP.
    • Reaches VMs in its VNet and peered VNets.
    • Developer (free, shared), Basic, Standard (scaling, native client, shareable link, IP-based), Premium (session recording, private-only).
    • You can upgrade a SKU but not downgrade it.

    Important terminology

    Azure Bastion
    A fully managed PaaS service that provides RDP and SSH to VMs over TLS from the portal or a native client, using the VMs' private IPs.
    AzureBastionSubnet
    The dedicated subnet Bastion is deployed into. The name must be exact and the size /26 or larger.
    Native client support
    A Standard or Premium setting (tunneling) that lets you connect with your local SSH or RDP client through az network bastion ssh or rdp.
    Host scaling
    Changing the number of Bastion instances (Standard and Premium, 2 to 50) to support more concurrent sessions.
    Shareable link
    A Standard feature that gives a user a URL to connect to one VM through Bastion without portal access.
    Developer SKU
    A free, shared Bastion option for dev and test that connects one VM at a time, with no dedicated subnet or public IP.

    Common mistakes

    • Naming the subnet BastionSubnet or making it a /27.
    • Expecting az network bastion ssh to work on the Basic SKU.
    • Blocking 3389/22 from the Bastion subnet in the VM's NSG.

    Exam tips

    • "Connect to VMs without public IPs, from the browser" = Azure Bastion.
    • "Use the local SSH client through Bastion" = Standard or Premium + native client support.
    • "Minimum subnet size for Bastion" = /26.

    Five quick revision questions

    1. 1.What must the Bastion subnet be called?Show

      AzureBastionSubnet.

    2. 2.What is the minimum size of that subnet?Show

      /26.

    3. 3.Which port does the admin use to reach Bastion?Show

      TCP 443 (HTTPS).

    4. 4.Can Bastion connect to VMs in peered VNets?Show

      Yes.

    5. 5.Which SKUs support native client connections?Show

      Standard and Premium.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Service Endpoints vs Private Endpoints for PaaS

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.