In the previous lesson we saw that a "machine in the cloud" is really a set of resources that are combined and billed separately. Now we are going to open that set up piece by piece. The three pillars of IaaS are compute (virtual machines and their sizes), storage (disks, shared folders, and object storage), and networking (virtual networks, traffic rules, load balancers, VPN, and DNS). Choosing each piece well is what separates a migration that works first time from one that turns out slow, expensive, or insecure: a disk with too few IOPS will make SQL Server crawl however huge the VM is, and one overly open network rule will expose the ERP to the internet. By the end of the lesson you will have the complete design of the target architecture for Hortalia's ERP in Azure and the first commands to build its network.

  1. Compute: families, sizes, and purchasing options

1.1 What a vCPU is

A vCPU (virtual CPU) is the processing unit the hypervisor assigns to a VM. In most sizes with modern x86 processors, one vCPU corresponds to a hardware thread, not to a whole physical core: with hyperthreading (SMT) technology, each physical core offers two threads, so a 4 vCPU VM usually amounts to 2 physical cores. There are exceptions (some ARM or AMD processor series assign one physical core per vCPU), so it is worth reading the datasheet of each series.

This matters for two reasons: when comparing with a physical server ("it had 8 cores") and when licensing software per core, as with SQL Server, which in the cloud is licensed per vCPU with a minimum of 4.

1.2 VM families

Providers group their sizes into families according to the CPU-to-memory ratio and the special hardware they include:

Family Typical memory/vCPU ratio What it is for Azure AWS Google Cloud
General purpose 4 GB per vCPU Application servers, small and medium databases, most workloads D series (Dsv5, Dsv6...) M (m7i, m8g...) N2, N4, E2
Burstable Variable, low baseline CPU with credits Workloads with light usage and occasional peaks: testing, small websites B series (B1s, B2s, Bsv2...) T (t3, t4g) Shared-core E2
Compute optimised 2 GB per vCPU Intensive calculation, CPU-heavy web servers, video encoding F series C (c7i, c8g...) C3, C4
Memory optimised 8 GB or more per vCPU Large databases, SAP, in-memory caches E and M series R and X M3, M4
Storage optimised Variable, with very fast local NVMe disks NoSQL databases, data warehouses L series I Z3
With GPU / accelerators Variable AI, machine learning, rendering, graphics desktops NC, ND, NV series P, G A3, G2

1.3 How to read the name of a size in Azure

The size Laura used in module 1, Standard_D4s_v5, breaks down like this:

Part Meaning
Standard Tier (practically every current size is Standard)
D Family: general purpose
4 Number of vCPUs
s Supports premium SSD disks
v5 Generation of the series (the higher, the more recent the hardware)

Other frequent letters: a (AMD processor), p (ARM processor), d (includes a local temporary disk), l (less memory per vCPU). So Standard_D4as_v5 is the same idea with an AMD processor. In AWS the logic is similar (m7i.xlarge: M family, 7th generation, Intel, xlarge size = 4 vCPUs), and in Google Cloud the name is more explicit (n2-standard-4: N2 series, standard profile, 4 vCPUs).

To see what sizes exist in a region and whether there are restrictions for your subscription:

az vm list-skus \
    --location spaincentral \
    --resource-type virtualMachines \
    --size Standard_D4 \
    --output table
  • az vm list-skus: lists the resource types (SKUs) available.
  • --location spaincentral: in the Madrid region.
  • --resource-type virtualMachines: VM sizes only (the command also lists disks and others).
  • --size Standard_D4: filters by sizes whose name starts like that (D4s_v5, D4as_v5, D4s_v6...).
  • In the table, the Zones column shows which availability zones the size exists in, and Restrictions warns you if your subscription cannot use it (for example, NotAvailableForSubscription).

1.4 Size by measuring, not by copying

The typical mistake in a migration is to copy the specifications of the physical server. Hortalia's ERP server has 8 cores and 32 GB of RAM, but Laura has measured for two weeks with Windows Performance Monitor (fictional data): average CPU of 15% with peaks of 55% on close days, around 12 GB of memory in use (SQL Server included), and around 800 IOPS of disk at the peaks.

With those figures, a Standard_D4s_v5 (4 vCPUs, 16 GB) is a reasonable starting point. If SQL Server needed more memory, the alternative would be a Standard_E4s_v5 (4 vCPUs, 32 GB): the same CPU and therefore the same SQL Server licenses, but twice the memory. And if a database needed a lot of memory with few vCPUs, Azure offers constrained vCPU sizes (for example, Standard_E8-4s_v5: the memory of an E8 with only 4 active vCPUs), designed precisely to save on per-core licensing.

1.5 Special purchasing options: spot and dedicated hosts

  • Spot VMs (Azure Spot, AWS Spot Instances, Google Spot VMs, formerly preemptible): they use the provider's spare capacity with discounts that can exceed 60-90% off the on-demand price. In exchange, the provider can evict the VM when it needs the capacity, with very short notice (around 30 seconds in Azure and Google Cloud, 2 minutes in AWS). Ideal for batch jobs that can be repeated, rendering, or continuous integration environments. Never for the ERP.
  • Dedicated hosts (Azure Dedicated Host, AWS Dedicated Hosts, Google sole-tenant nodes): a physical server reserved for a single customer, on which they create their VMs. They are used for compliance or licensing requirements that demand dedicated hardware. They are considerably more expensive and only pay off with many VMs or because of a specific obligation.

  1. Storage: block, file, and object

2.1 Block storage: the VM disks

Block storage is presented to the VM as a disk: the operating system formats it (NTFS, ext4...) and uses it as if it were physical. In the cloud, these disks are not inside the server but in a replicated network storage system, which makes it possible to detach them from one VM and attach them to another. They are the managed disks (Managed Disks in Azure, EBS in AWS, Persistent Disk and Hyperdisk in Google Cloud).

Their performance is measured with two magnitudes:

  • IOPS (input/output operations per second): how many small reads or writes it can do. Critical for databases.
  • Throughput (MB/s): how much data it can move. Critical for backups, analytics, and large files.

Disk types in Azure (performance figures indicative, according to the provider's documentation; check the current one):

Type Technology Example size IOPS / MB/s (indicative) Recommended use AWS / Google equivalent
Standard HDD Mechanical disk S10 (128 GB) Up to 500 / 60 Backups, rarely used data st1, sc1 / pd-standard
Standard SSD Entry-level SSD E10 (128 GB) Up to 500 / 100 Web servers, testing gp3 / pd-balanced
Premium SSD High-performance SSD P10 (128 GB) / P15 (256 GB) / P20 (512 GB) 500 / 100 · 1,100 / 125 · 2,300 / 150 Production, databases gp3 or io2 / pd-ssd
Premium SSD v2 SSD with IOPS and MB/s configurable separately from size Any size From a baseline of 3,000 / 125, expandable Databases with specific needs io2 / Hyperdisk Balanced
Ultra Disk Minimum latency Any size Hundreds of thousands of IOPS SAP HANA, critical high-volume databases io2 Block Express / Hyperdisk Extreme

Two nuances Laura must keep in mind:

  • The performance of a Premium SSD depends on its size. To get more IOPS you have to buy a larger disk (or move to Premium SSD v2, which separates the two).
  • The VM also has a limit. Each size has a maximum of total disk IOPS and MB/s; a D4s_v5 supports of the order of 6,400 IOPS and 145 MB/s uncached. A 20,000 IOPS disk is useless on a VM that can only use 6,400.

Besides, many VMs include a local temporary disk (the D: drive in Windows). It is fast but it is wiped when the VM is deallocated or moved: never store data there. It is only suitable for page files or for SQL Server's tempdb database, which is recreated at every start-up.

For the ERP, with measured peaks of 800 IOPS, Laura chooses a 256 GB Premium SSD P15 data disk (1,100 IOPS, 125 MB/s), which leaves room for the database to grow (around 40 GB today, growing by around 8 GB a year, fictional figures) and for the local backups.

2.2 File storage

This is a network shared folder that several machines connect to at once through standard protocols: SMB (the one behind Windows shared folders) or NFS (common on Linux). Examples: Azure Files, Amazon EFS (NFS) and Amazon FSx for Windows File Server (SMB), and Google Filestore. It replaces the classic file server or NAS; at Hortalia it could host, in the future, the network folder where the customer spreadsheets live today (although the idea is to replace them with a SaaS CRM).

2.3 Object storage

It stores objects (a file plus its metadata) in flat containers called buckets or containers, and they are accessed through an HTTP API, not as a disk. Examples: Azure Blob Storage, Amazon S3, and Google Cloud Storage. Its traits:

  • Practically unlimited capacity and extremely high durability (providers advertise of the order of "eleven nines", 99.999999999%, thanks to replication).
  • Access tiers (hot, cool, cold, archive) with decreasing prices per GB and increasing read costs. Old backups can move to cheap tiers on their own with life-cycle rules.
  • Immutability options (WORM, write once, read many): for a period, nobody, not even an administrator, can delete or modify the object. It is the best defence against ransomware for backups.

2.4 Comparison table

Criterion Block File Object
How it appears A disk on the VM A network folder A URL / API
Protocol Provider-internal (appears as SCSI/NVMe) SMB, NFS HTTPS (REST)
Simultaneous access Normally one VM (except specific shared disks) Many machines Unlimited
Latency Very low Low to medium Medium (milliseconds)
Typical scale GB to tens of TB GB to hundreds of TB Unlimited
Billing GB provisioned (whether you use them or not) GB provisioned or used GB used + operations + transfer
Typical use OS, databases Shared folders, content for several VMs Backups, archives, images, data for analytics
Azure Managed Disks Azure Files Blob Storage
AWS EBS EFS / FSx S3
Google Cloud Persistent Disk / Hyperdisk Filestore Cloud Storage

  1. Snapshots and backups

A snapshot is a copy of a disk at a specific moment. At the large providers they are usually incremental (they only store the blocks changed since the previous one) and are created in seconds. They are useful before a risky change: Laura will take a snapshot before every ERP update so she can roll back.

But beware of two confusions:

  • Consistency. A "hot" snapshot of a disk with SQL Server is crash consistent (as if the power had gone out): normally recoverable, but with no guarantees. For an application-consistent backup you have to coordinate with Windows and SQL Server (through VSS, the volume shadow copy service), which is what services such as Azure Backup or AWS Backup do.
  • A snapshot is not a full backup if it lives next to the original disk, with the same permissions: an administration error or an attacker with access to the subscription can delete both.

That is why Laura combines two mechanisms for the ERP:

  1. Native SQL Server backups (a full one daily and the transaction log every 30 minutes) sent directly to object storage, in a container with immutability.
  2. Snapshots of the disk before changes and, optionally, Azure Backup of the whole VM.

SQL Server 2022 can send backups directly to Blob Storage. A simplified example in T-SQL (SQL Server's language):

BACKUP DATABASE [HortaliaERP]
TO URL = 'https://sthortaliaerpcopias.blob.core.windows.net/sqlserver/HortaliaERP_completa_2026-10-05.bak'
WITH COMPRESSION, CHECKSUM;
  • BACKUP DATABASE [HortaliaERP]: copies the ERP database (fictional name).
  • TO URL = '...': the destination is an object in the sthortaliaerpcopias storage account, sqlserver container. SQL Server authenticates with a credential (a SAS token with limited permissions) created beforehand, not shown here.
  • WITH COMPRESSION: compresses the backup (fewer GB stored and transferred).
  • CHECKSUM: verifies the integrity of the pages as they are copied, to detect corruption.

The sqlserver container in the sthortaliaerpcopias account is the Azure equivalent of the hortalia-erp-copias bucket that Laura designed in The Shared Responsibility Model with AWS syntax, and it follows the same philosophy: the server's credential can only create and write backups, not read or delete them, and immutability prevents them from being destroyed for 30 days. Backups in another region for disaster recovery are covered in IaaS Use Cases.

  1. Networking: virtual network, subnets, and addressing

4.1 Virtual network and subnets

A virtual network (Virtual Network or VNet in Azure; VPC, Virtual Private Cloud, in AWS and Google Cloud) is your isolated private network inside the cloud. It is defined with a private address space in CIDR notation (for example, 10.20.0.0/16) and divided into subnets, which group resources with similar security needs.

A quick reminder of CIDR notation: the number after the slash says how many bits are fixed. /16 leaves 16 bits free (65,536 addresses); /24, 8 bits (256 addresses); /27, 5 bits (32 addresses). Azure reserves 5 addresses in every subnet for internal use, so a /24 offers 251 usable ones.

Differences between providers worth knowing:

Aspect Azure VNet AWS VPC Google Cloud VPC
Scope of the network Regional Regional Global (subnets are regional)
Scope of the subnet The whole region (spans all zones) A single availability zone One region
Traffic rules NSG (on subnet or interface) Security groups (instance) and NACL (subnet) VPC firewall rules

4.2 Private and public addressing

  • Private IP: an address within the VNet's space (for example, 10.20.1.10). It is only reachable from the network itself, from connected networks (VPN, peering), or through intermediate services. It is best made static for servers such as the ERP, which others connect to by address.
  • Public IP: an address routable on the internet, associated with a VM or, better, with an intermediate service (load balancer, VPN, NAT). In Azure, Standard public IPs are closed by default until a network rule allows traffic.
  • Outbound internet access: a VM without a public IP still needs to reach the internet to download patches. Azure is retiring "default outbound access" and, in new networks, subnets are private by default (check the current documentation); the recommended way to provide controlled outbound access is a NAT Gateway, which allows outbound connections but no inbound ones.

Golden rule of addressing: the VNet's space must not overlap with the networks it will be connected to. The network at Hortalia's warehouse is 192.168.10.0/24; if Laura used that same range in Azure, the VPN would not know which side to send each packet to. That is why she chooses 10.20.0.0/16, leaving room for other future networks as well (for example, 10.30.0.0/16 for test environments).

The quick VM from module 1, vm-prueba-erp, was created with the default values of az vm create: an automatically created 10.0.0.0/16 network, a public IP, and a rule that allowed RDP from any source. Laura will use it only for one-off tests and will delete it as soon as she has the final network.

  1. Network security groups

A network security group (NSG, Network Security Group, in Azure; security group in AWS; VPC firewall rules in Google Cloud) is a virtual firewall with rules that allow or deny traffic based on source, destination, port, and protocol. In Azure it is associated with a subnet (recommended, it affects everything inside it) or with one specific network interface.

How NSG rules work:

  • Every rule has a priority between 100 and 4096: they are evaluated from the lowest number upwards and the first match decides; the rest are ignored.
  • They are stateful: if an inbound connection is allowed, the response goes out automatically without needing an outbound rule.
  • There are default rules with priorities of 65000 and above that cannot be deleted, but can be overridden with rules of lower priority:
Default rule (inbound) Priority Effect
AllowVnetInBound 65000 Allows traffic coming from the VirtualNetwork tag
AllowAzureLoadBalancerInBound 65001 Allows the Azure load balancer health probes
DenyAllInBound 65500 Denies everything else

Pay attention to the first one: the VirtualNetwork tag includes not only the VNet itself, but also the networks connected by VPN and the peered VNets. In other words, by default the whole warehouse could reach any port on the ERP. To apply least privilege, Laura will add explicit rules for what she needs and a rule denying the rest of the internal traffic.

Priority Name Source Destination port Action Reason
100 Permitir-SQL-Almacen 192.168.10.0/24 TCP 1433 Allow The ERP clients at the warehouse connect to SQL Server
110 Permitir-RDP-Almacen 192.168.10.0/24 TCP 3389 Allow Administration from Laura's workstation
120 Permitir-RDP-Bastion 10.20.254.0/26 TCP 3389 Allow Remote administration through Azure Bastion
4000 Denegar-Resto-VNet VirtualNetwork Any Deny Overrides the default AllowVnetInBound rule

  1. Load balancers, VPN, dedicated connections, and DNS

6.1 Load balancers

They spread requests across several VMs and stop sending traffic to those that fail their health probes:

Type Layer Decides on Azure AWS Google Cloud
Network load balancer 4 (TCP/UDP) IP and port Azure Load Balancer Network Load Balancer Network Load Balancer
Application load balancer 7 (HTTP/HTTPS) URL, headers, cookies; can terminate TLS and add a WAF Application Gateway Application Load Balancer Application Load Balancer

The ERP, with a single VM, does not need a load balancer. Marc's online store, with several instances at Christmas, does (although in PaaS it comes built in).

6.2 Site-to-site and point-to-site VPN

A site-to-site VPN creates an encrypted tunnel (IPsec/IKEv2) over the internet between a site's network and the VNet, so that both behave as a single private network. In Azure three pieces are involved:

  • Virtual network gateway (VPN Gateway): the end of the tunnel in Azure. It lives in a special subnet that must be named exactly GatewaySubnet. You choose a SKU according to bandwidth and redundancy (for example, VpnGw1AZ, spread across zones).
  • Local network gateway: Azure's representation of the warehouse router: its public IP and the networks behind it (192.168.10.0/24).
  • Connection: joins the two with a pre-shared key (or certificates).

Here a problem from module 1 resurfaces: Hortalia has a single fibre line at the warehouse. With the ERP in the cloud, if that line is cut, the warehouse is left without an ERP. Laura will contract a second line from another operator before migrating, and will configure a second tunnel over it so that the VPN keeps working if one of the two goes down.

There is also the point-to-site VPN, which connects individual devices (laptops, phones) to the VNet with user authentication, for example with Microsoft Entra ID accounts and MFA. It is the gateway for the sales reps to check stock from outside without exposing the ERP to the internet, one of Hortalia's long-standing complaints.

6.3 Dedicated connections

When the internet is not enough (guaranteed latency, large volumes, regulatory requirements), you contract a private circuit through a telecommunications operator that connects the site with the provider without going over the internet: Azure ExpressRoute, AWS Direct Connect, or Google Cloud Interconnect. They offer anything from tens of Mbps to 10 or 100 Gbps, but with monthly fees and installation lead times of weeks. For an SME like Hortalia, with a 120-user ERP, two fibre lines with VPN are enough.

6.4 DNS

DNS translates names into IP addresses. In the cloud there are two uses:

  • Public zones (Azure DNS, Amazon Route 53, Cloud DNS): the names the internet sees, such as the online store's website.
  • Private zones (Azure Private DNS, private zones in Route 53 and Cloud DNS): names that only resolve inside the network.

Laura will create the private zone hortalia.internal with the record erp.hortalia.internal → 10.20.1.10, so that the ERP clients are configured with a name and not an IP. Since the machines at the warehouse use their router's DNS, she will add a conditional forwarder there for that zone towards Azure (through Azure DNS Private Resolver) or, as a first step, the record directly in the warehouse DNS.

  1. The target architecture of Hortalia's ERP in Azure

Putting all the pieces together, this is the design of the prototype Laura presents to management:

flowchart LR
    subgraph ALM["Hortalia warehouse - 192.168.10.0/24"]
        PC["ERP workstations"]
        RT["Router with two lines<br/>(main fibre + second operator)"]
        PC --> RT
    end
    COM["Sales reps<br/>(point-to-site VPN + MFA)"]
    subgraph AZ["Azure - spaincentral region - rg-hortalia-erp"]
        subgraph VNET["vnet-hortalia-spaincentral - 10.20.0.0/16"]
            GW["VPN Gateway vpng-hortalia<br/>GatewaySubnet 10.20.255.0/27"]
            BAS["Azure Bastion<br/>AzureBastionSubnet 10.20.254.0/26"]
            subgraph SNET["snet-erp - 10.20.1.0/24 - NSG nsg-snet-erp"]
                VM["vm-erp-01 - Standard_D4s_v5<br/>Windows Server 2022 + SQL Server 2022<br/>private IP 10.20.1.10, no public IP"]
                DISK[("Premium SSD P15 data disk<br/>256 GB for SQL Server")]
                VM --- DISK
            end
        end
        NAT["NAT Gateway<br/>(outbound only: patches)"]
        DNS["Private zone hortalia.internal<br/>erp.hortalia.internal"]
        ST[("Account sthortaliaerpcopias<br/>sqlserver container, immutable 30 days")]
    end
    RT ==>|"IPsec site-to-site VPN (2 tunnels)"| GW
    COM -.-> GW
    GW --> VM
    BAS -->|RDP| VM
    SNET --> NAT
    VM -->|"SQL backups (HTTPS)"| ST

Reading the diagram:

  • The ERP lives on vm-erp-01, in the snet-erp subnet, with no public IP. It can only be reached from the warehouse (over the VPN), from authenticated sales reps (point-to-site VPN), or from Azure Bastion for administration.
  • The nsg-snet-erp NSG applies the rules from the table in section 5.
  • SQL Server keeps its databases on a Premium SSD disk separate from the operating system disk.
  • Backups go out to sthortaliaerpcopias, with immutability, through a credential that can only write.
  • The NAT Gateway provides outbound internet access for Windows Update and the vendor's updates, without opening any inbound access.

Laura adds two notes: the VM is in a single zone (zone 1), with availability of the order of 99.9%, which already comfortably beats the cabinet; and recovery from a regional disaster will be designed separately, in IaaS Use Cases.

  1. Building the ERP network with the CLI

Laura starts with the network, which is the first thing that must exist. These commands can be run in Azure Cloud Shell or on a machine with the CLI installed.

8.1 Resource group, virtual network, and subnets

# Variables so values are not repeated (and to avoid typos)
RG=rg-hortalia-erp
LOC=spaincentral
VNET=vnet-hortalia-spaincentral

az group create --name $RG --location $LOC \
    --tags proyecto=erp entorno=prototipo propietario=laura

az network vnet create --resource-group $RG --name $VNET \
    --address-prefixes 10.20.0.0/16 \
    --subnet-name snet-erp --subnet-prefixes 10.20.1.0/24

az network vnet subnet create --resource-group $RG --vnet-name $VNET \
    --name GatewaySubnet --address-prefixes 10.20.255.0/27

az network vnet subnet create --resource-group $RG --vnet-name $VNET \
    --name AzureBastionSubnet --address-prefixes 10.20.254.0/26
  • RG=..., LOC=..., VNET=...: bash variables; afterwards they are used as $RG. If the name changes tomorrow, it is changed in one place only.
  • az group create ... --tags: creates the resource group with key=value tags. Sara will be able to filter the bill by proyecto=erp.
  • az network vnet create: creates the VNet with the 10.20.0.0/16 space and, at the same time, the first subnet snet-erp with 10.20.1.0/24.
  • The next two subnets have mandatory names: Azure only allows the VPN Gateway to be deployed in GatewaySubnet and Azure Bastion in AzureBastionSubnet (which must be at least a /26).

8.2 NSG with least-privilege rules

NSG=nsg-snet-erp
WAREHOUSE=192.168.10.0/24

az network nsg create --resource-group $RG --name $NSG

az network nsg rule create --resource-group $RG --nsg-name $NSG \
    --name Permitir-SQL-Almacen --priority 100 \
    --direction Inbound --access Allow --protocol Tcp \
    --source-address-prefixes $WAREHOUSE --source-port-ranges '*' \
    --destination-address-prefixes '*' --destination-port-ranges 1433

az network nsg rule create --resource-group $RG --nsg-name $NSG \
    --name Permitir-RDP-Almacen --priority 110 \
    --direction Inbound --access Allow --protocol Tcp \
    --source-address-prefixes $WAREHOUSE --source-port-ranges '*' \
    --destination-address-prefixes '*' --destination-port-ranges 3389

az network nsg rule create --resource-group $RG --nsg-name $NSG \
    --name Permitir-RDP-Bastion --priority 120 \
    --direction Inbound --access Allow --protocol Tcp \
    --source-address-prefixes 10.20.254.0/26 --source-port-ranges '*' \
    --destination-address-prefixes '*' --destination-port-ranges 3389

az network nsg rule create --resource-group $RG --nsg-name $NSG \
    --name Denegar-Resto-VNet --priority 4000 \
    --direction Inbound --access Deny --protocol '*' \
    --source-address-prefixes VirtualNetwork --source-port-ranges '*' \
    --destination-address-prefixes '*' --destination-port-ranges '*'

az network vnet subnet update --resource-group $RG --vnet-name $VNET \
    --name snet-erp --network-security-group $NSG

Explanation of the az network nsg rule create parameters:

  • --name: a descriptive name; it should say what the rule does.
  • --priority: evaluation order (lower number, earlier). Gaps are left (100, 110, 120) so rules can be slotted in later.
  • --direction Inbound: traffic entering the subnet.
  • --access Allow / Deny: allow or deny.
  • --protocol Tcp: SQL Server and RDP use TCP; '*' means any protocol.
  • --source-address-prefixes: where from. 192.168.10.0/24 is the warehouse network, which arrives over the VPN; VirtualNetwork is the service tag that groups the VNet and the connected networks.
  • --source-port-ranges '*': the source port is chosen at random by the client, so any is accepted. The quotes stop bash from interpreting the asterisk.
  • --destination-port-ranges: the service port: 1433 (SQL Server) or 3389 (RDP).
  • The last command, az network vnet subnet update ... --network-security-group, associates the NSG with the subnet. Without this step, the NSG exists but protects nothing: a very frequent mistake.

Note that there is no rule allowing traffic from Internet. Even if someone mistakenly associated a public IP with the VM, the default DenyAllInBound rule would block access.

To check the result:

az network nsg rule list --resource-group $RG --nsg-name $NSG \
    --query "[].{Priority:priority, Name:name, Access:access, Source:sourceAddressPrefix, Port:destinationPortRange}" \
    --output table
  • --query uses JMESPath, a query language over the JSON response: [] walks the list of rules and {Alias:field} picks and renames the columns we want to see.

8.3 The VPN with the warehouse (summary)

az network public-ip create --resource-group $RG --name pip-vpng-hortalia \
    --sku Standard --zone 1 2 3

az network vnet-gateway create --resource-group $RG --name vpng-hortalia \
    --vnet $VNET --public-ip-addresses pip-vpng-hortalia \
    --gateway-type Vpn --vpn-type RouteBased --sku VpnGw1AZ --no-wait

az network local-gateway create --resource-group $RG --name lgw-almacen \
    --gateway-ip-address 203.0.113.25 \
    --local-address-prefixes 192.168.10.0/24

az network vpn-connection create --resource-group $RG --name cn-almacen-fibra1 \
    --vnet-gateway1 vpng-hortalia --local-gateway2 lgw-almacen \
    --shared-key "$VPN_PSK"
  • az network public-ip create ... --zone 1 2 3: the gateway's public IP, redundant across the three zones.
  • az network vnet-gateway create: creates the VPN Gateway in the VNet's GatewaySubnet. --vpn-type RouteBased is the recommended type; --sku VpnGw1AZ sets the capacity and the zone redundancy. --no-wait returns control immediately, because creating it takes of the order of 30-45 minutes.
  • az network local-gateway create: describes the warehouse side. 203.0.113.25 is the (fictional) public IP of the main fibre line and --local-address-prefixes the networks behind it.
  • az network vpn-connection create: joins both ends. $VPN_PSK is a variable holding the pre-shared key, which is never written in the script or pushed to a repository; the same key is configured on the warehouse router. When the second line is in place (fictional IP 198.51.100.40), Laura will create lgw-almacen-fibra2 and a second connection.

With the network ready, what remains is to create vm-erp-01 inside snet-erp, with no public IP and with its data disk. We will not do it here: the complete step by step for a VM is the subject of the Hands-on Exercise: Setting Up a Virtual Machine, and writing all of this as reusable code, that of Automating IaaS: Infrastructure as Code.

Common Mistakes and Tips

  • Sizing by copying the physical server. Measure real CPU, memory, and IOPS over a representative period (closes included) and size with some headroom; resizing later is easy.
  • Choosing a small, cheap disk for a database. On Premium SSD, IOPS depend on the size. Also check the disk limit of the VM size.
  • Storing data on the temporary disk. It is lost on deallocation. Only for paging or tempdb.
  • Trusting snapshots as your only backup. They live next to the disk and with the same permissions. Add backups in object storage with immutability and, for disasters, in another region.
  • Overlapping IP ranges with the office. Plan the addressing before creating anything; changing the address space of a VNet that already has resources is very laborious.
  • Creating the NSG and forgetting to associate it. Check the association with az network vnet subnet show.
  • Opening RDP or SQL to 0.0.0.0/0 or to Internet. It is the favourite way in for automated attacks. Use a VPN, Bastion or, at the very least, your specific source IP.
  • Forgetting that AllowVnetInBound includes the networks connected by VPN. If you want least privilege, deny it explicitly with a high-priority rule.
  • Tip: draw the architecture (as in section 7) before typing commands. The diagram serves both to review it with others and as living documentation.

Exercises

Exercise 1. For each need, say which type of storage (block, file, or object) and which Azure service you would use: a) the ERP's SQL Server database; b) the ERP's nightly backups, which must be kept for 30 days with no possibility of deletion; c) a folder with delivery-note templates used at the same time by several Windows VMs; d) the product photos for the online store.

Exercise 2. Laura wants to add a rule that lets her laptop at home, with fictional fixed public IP 81.44.20.7, connect over RDP to the ERP. Write the az network nsg rule create command and explain why, even so, it is preferable to use Azure Bastion or the point-to-site VPN.

Exercise 3. A colleague proposes the range 192.168.0.0/16 for the Azure VNet "because it is the one we all know". What problem would it cause with the warehouse VPN? Propose an alternative range and two extra subnets for a future test environment.

Solutions

Solution 1. a) Block: a Premium SSD Managed Disk (like the P15 chosen), attached to the VM. b) Object: Blob Storage with a 30-day immutability policy. c) File: Azure Files (SMB), mounted on every VM. d) Object: Blob Storage, served over HTTPS (ideally with a CDN in front).

Common mistake: keeping the backups on a second disk on the same VM. If the VM is compromised, the backups go down with it.

Solution 2.

az network nsg rule create --resource-group rg-hortalia-erp --nsg-name nsg-snet-erp \
    --name Permitir-RDP-CasaLaura --priority 130 \
    --direction Inbound --access Allow --protocol Tcp \
    --source-address-prefixes 81.44.20.7/32 --source-port-ranges '*' \
    --destination-address-prefixes '*' --destination-port-ranges 3389

The /32 limits the source to a single address. But there are two problems: the ERP VM has no public IP, so one would have to be assigned to it, breaking the principle that the ERP is not exposed to the internet; and if the home IP changes or someone else uses it (a shared network), access is left open to the wrong people. Azure Bastion allows the VM to be administered from the browser with an Entra ID identity and MFA, with no public IP on the VM; the point-to-site VPN gives access to the private network with user authentication.

Solution 3. 192.168.0.0/16 contains 192.168.10.0/24, the warehouse network: the ranges overlap and the VPN routing would be ambiguous (and Azure would reject the connection). Alternative: keep 10.20.0.0/16 for production and reserve 10.30.0.0/16 for testing, with subnets such as 10.30.1.0/24 (snet-erp-pruebas) and 10.30.2.0/24 (snet-herramientas). What matters is a documented addressing plan with no overlaps.

Conclusion

In this lesson you have taken IaaS apart into its three pillars. In compute, you have learned what a vCPU is, the VM families, how to read a size such as Standard_D4s_v5, how to size by measuring, and when to use spot VMs or dedicated hosts. In storage, you have compared block, file, and object, the disk types and their IOPS, and the difference between snapshots and real backups. In networking, you have seen VNets/VPCs, subnets and addressing without overlaps, NSGs and their default rules, load balancers, site-to-site and point-to-site VPN, dedicated connections, and private DNS. With all of that you have built the target architecture of Hortalia's ERP in Azure and the network with least-privilege NSG rules.

Laura chose Azure for the prototype almost on instinct: Windows, SQL Server, licenses. But what exactly do AWS, Google Cloud, and the rest of the IaaS providers, European ones included, have to offer? How do they compare and how do you evaluate one? We will see that in the next lesson: Popular IaaS Providers.

© Copyright 2026. All rights reserved