Skip to content

Intermediate · Microsoft Azure essentials · topic 26 of 50 · 35 min

Azure networking, Functions, databases and monitoring

Explanation

An Azure VNet is your private network, split into subnets and protected by network security groups whose rules are checked by priority, lowest number first. Peering, VPN Gateway and ExpressRoute connect networks; Load Balancer, Application Gateway and Front Door spread traffic. Azure Functions is the serverless option, Azure SQL Database and Cosmos DB are the main managed databases, and Azure Monitor with Log Analytics (queried in KQL) watches it all.

VNets and subnets

An Azure Virtual Network (VNet) is the same idea as an AWS VPC: a private address range, such as 10.10.0.0/16, in one region. You split it into subnets, such as 10.10.1.0/24 for web servers and 10.10.2.0/24 for databases. Azure reserves 5 addresses in every subnet (the first four and the last), so a /24 gives 251 usable addresses. One difference from AWS: Azure subnets span all availability zones in the region.

Microsoft is retiring the old automatic "default outbound access" to the internet for VMs in new networks. Plan an explicit way out, such as a NAT gateway or a load balancer outbound rule, and check the current docs.

Network security groups (NSGs)

An NSG is a list of allow and deny rules for traffic. You attach it to a subnet, a network interface, or both. Each rule has a priority from 100 to 4096, a source and destination (an IP range or a service tag such as Internet or VirtualNetwork), a port, a protocol, a direction and an action. Azure checks rules from the lowest number upwards and stops at the first match. NSGs are stateful: if inbound traffic is allowed, the reply is allowed automatically.

Default inbound rulePriorityEffect
AllowVNetInBound65000Allow traffic from inside the VNet (and connected networks)
AllowAzureLoadBalancerInBound65001Allow Azure load balancer health probes
DenyAllInBound65500Deny everything else

Outbound has matching defaults: AllowVnetOutBound, AllowInternetOutBound and DenyAllOutBound. You cannot delete default rules, but your own rules (100 to 4096) are checked first, so they can override them.

bash
az network nsg rule create --resource-group rg-web --nsg-name nsg-web \
  --name Allow-HTTPS --priority 300 --direction Inbound --access Allow \
  --protocol Tcp --source-address-prefixes Internet --destination-port-ranges 443
Allow HTTPS from the internet with priority 300.

Connecting networks

  • VNet peering joins two VNets over Microsoft's backbone, in the same or different regions. Address ranges must not overlap, and peering is not transitive: if A peers with B and B with C, A cannot reach C through B.
  • VPN Gateway connects your office or data centre over an encrypted IPsec tunnel across the internet (site-to-site), or single laptops (point-to-site).
  • ExpressRoute is a private connection through a connectivity provider that does not travel over the public internet. It gives steadier speed for banks and large firms, at a higher price.

Spreading traffic

ServiceLayer and reachUse it for
Azure Load BalancerLayer 4 (TCP/UDP), regionalSpreading any TCP or UDP traffic across VMs
Application GatewayLayer 7 (HTTP/HTTPS), regional, optional WAFWeb apps: URL path routing, TLS termination, a web application firewall
Azure Front DoorLayer 7, global, at Microsoft's edge, with WAF and cachingGlobal websites: send users to the nearest healthy region, CDN

Azure Functions

Azure Functions is Azure's serverless compute, like AWS Lambda. Each function has exactly one trigger, the event that runs it: an HTTP request, a timer, a new blob, a queue message, a Cosmos DB change and more. Bindings connect a function to other services without boilerplate code: an input binding reads data in, an output binding writes data out, for example to a storage queue.

python
import azure.functions as func

app = func.FunctionApp()

@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
def hello(req: func.HttpRequest) -> func.HttpResponse:
    name = req.params.get("name", "friend")
    return func.HttpResponse(f"Namaste, {name}!")

@app.timer_trigger(schedule="0 30 2 * * *", arg_name="timer")
def nightly(timer: func.TimerRequest) -> None:
    print("Nightly clean-up ran")
Python v2 programming model: an HTTP trigger and a timer trigger. Timer schedules have six fields, starting with seconds, and use UTC by default.

Function apps run on a hosting plan. Flex Consumption is the current recommended serverless plan (pay per use, scale to zero), Premium keeps warm instances for no cold starts, and a Dedicated plan runs on an App Service plan you already pay for. Timeouts, memory and scaling limits differ by plan and change over time, so check the hosting options page.

Databases

Azure SQL Database is managed SQL Server: Microsoft handles patching, backups (with point-in-time restore) and high availability. You choose a purchasing model (vCore or DTU), and a serverless compute tier can pause when idle. Azure Cosmos DB is a globally distributed NoSQL database. You pick an API (NoSQL, MongoDB, Cassandra, Gremlin or Table), a partition key, and throughput in request units (RU/s), or the serverless mode. It offers five consistency levels, from strong to eventual.

Azure Monitor and Log Analytics

Azure Monitor collects metrics and logs from every resource. Logs go into a Log Analytics workspace, where you query them with KQL (Kusto Query Language). The Activity Log records control-plane operations in a subscription, such as who deleted a VM, much like AWS CloudTrail. Application Insights watches application performance. Alerts send notifications through action groups (email, SMS, webhook).

output
Heartbeat
| summarize LastSeen = max(TimeGenerated) by Computer
| where LastSeen < ago(10m)

AppRequests
| where TimeGenerated > ago(1h)
| summarize requests = count(), failed = countif(Success == false), p95 = percentile(DurationMs, 95) by bin(TimeGenerated, 5m)
Two KQL queries: machines that stopped reporting in the last 10 minutes, and request counts, failures and p95 latency every 5 minutes.

Microsoft Defender for Cloud checks your subscriptions against security best practices, gives a secure score with recommendations, and with paid Defender plans adds threat protection for servers, storage, databases and containers.

AWS to Azure: the services in this module

AWSAzure
AWS account / Organizations OUSubscription / management group
IAM users, groups and rolesMicrosoft Entra ID plus Azure RBAC
IAM role for EC2 or LambdaManaged identity
EC2 / Auto Scaling groupVirtual Machines / VM Scale Sets
Elastic BeanstalkApp Service
LambdaAzure Functions
S3 / EBS / EFSBlob storage / Managed Disks / Azure Files
VPC / security groupVNet / network security group
Network Load Balancer / Application Load Balancer + WAFAzure Load Balancer / Application Gateway + WAF
CloudFrontAzure Front Door
Site-to-Site VPN / Direct ConnectVPN Gateway / ExpressRoute
RDS for SQL Server / DynamoDBAzure SQL Database / Cosmos DB
CloudWatch / CloudTrailAzure Monitor / Activity Log
CloudFormationARM templates and Bicep
Careful: Common mistakes: (1) Giving an NSG rule priority 4096 and wondering why a deny rule at 200 wins: the lower number is checked first. (2) Opening RDP 3389 or SSH 22 to Internet; use Azure Bastion or a VPN instead. (3) Peering VNets with overlapping address ranges, which Azure refuses. (4) Expecting peering to be transitive. (5) Using Application Gateway for a global site when Front Door fits better.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Azure networking, Functions, databases and monitoring · 1/8

Networking, Functions, data, monitoring

This lesson covers Azure networking, serverless Functions, databases and monitoring, and maps each to the AWS service you already know.

Prefer a video by a teacher? Find free videos on “azure vnet network security group priority azure functions triggers bindings tutorial” on YouTube ↗

In real life: A UPI payments startup moves an API to Azure

A payments startup in Gurugram runs its API on VM Scale Sets in two subnets of a VNet in Central India. Application Gateway with WAF receives HTTPS traffic and blocks common attacks. The app subnet's NSG allows port 8080 only from the gateway subnet, and the database subnet allows 1433 only from the app subnet; everything else falls to DenyAllInBound. Settlement files from the bank arrive as blobs and trigger an Azure Function that checks them and writes results to Azure SQL Database. The office connects through a site-to-site VPN Gateway. A KQL alert on failed requests above 2% pages the on-call engineer through an action group.

output
AzureActivity
| where TimeGenerated > ago(7d)
| where OperationNameValue endswith "DELETE"
| project TimeGenerated, Caller, OperationNameValue, ResourceGroup
Who deleted anything in the last week? The Activity Log answers like CloudTrail.

Practice (0/3 done)

Task 1 · Question

An NSG has "Deny SSH from Internet" at priority 200 and "Allow SSH from Internet" at priority 300. What happens to an SSH connection from the internet?

Task 2 · Code · Python

Write evaluate_nsg(rules, port, source_ip, protocol="TCP") for inbound traffic. Each rule is a dict with "name", "priority", "port" (an int, "*" for any, or a range string like "8000-8100"), "protocol" ("TCP", "UDP" or "*"), "source" ("*" or a CIDR like "203.0.113.0/24") and "access" ("Allow" or "Deny"). Check rules in priority order, lowest number first; the first rule that matches port, protocol and source decides. Return (access, rule_name). If nothing matches, return ("Deny", "DenyAllInBound"). For this task, ignore the other default rules. Tip: the ipaddress module checks whether an IP is inside a CIDR.

Task 3 · Practice

Design the network for a three-tier app (web, app, database) in one Azure VNet in Central India. Give the address ranges, the NSG rules for each subnet with priorities, how admins log in, and how you would watch it.

Quick quiz

Question 1

1.What is the valid priority range for your own NSG rules?

Question 2

2.VNet A is peered with B, and B is peered with C. Can A reach C through B by default?

Question 3

3.Which service gives global layer 7 routing at Microsoft's edge, with caching and WAF?

Question 4

4.In Azure Functions, what is a binding?

Question 5

5.Which language do you use to query logs in a Log Analytics workspace?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What is the valid priority range for your own NSG rules?

Answer: 100 to 4096

Custom rules use 100 to 4096. The default rules sit at 65000, 65001 and 65500.

VNet A is peered with B, and B is peered with C. Can A reach C through B by default?

Answer: No, peering is not transitive

Peering connects only the two VNets in the pair. Use a hub with a firewall or direct peering for A to C.

Which service gives global layer 7 routing at Microsoft's edge, with caching and WAF?

Answer: Azure Front Door

Front Door is global and HTTP-aware. Application Gateway is regional; Load Balancer is layer 4.

In Azure Functions, what is a binding?

Answer: A declared connection that reads input from or writes output to another service

Bindings save you writing connection code: for example an output binding that writes to a storage queue.

Which language do you use to query logs in a Log Analytics workspace?

Answer: KQL (Kusto Query Language)

Log Analytics and Azure Monitor Logs use KQL, with pipes such as | where and | summarize.

Which option gives a dedicated private line from your data centre to AWS?Related

Answer: AWS Direct Connect

Direct Connect is a dedicated connection through a partner location. VPN runs over the public internet.

From VPC security and connectivity

A private app server must download updates from the internet but must not accept connections from it. What does its subnet route to?Related

Answer: A NAT gateway

A NAT gateway lets private servers start outbound connections while blocking inbound ones.

From Virtualisation, VRFs and cloud networking

How many usable addresses does an AWS subnet 10.0.5.0/26 have?Related

Answer: 59

A /26 has 64 addresses; AWS reserves 5, leaving 59.

From VPC basics: CIDR, subnets and gateways

Which service runs your container, scales with traffic and can scale down to zero?Related

Answer: Cloud Run

Cloud Run is serverless containers with scale to zero.

From Core Google Cloud services

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. This is the last topic of “Microsoft Azure essentials”. The module exam comes next.
  2. Module 6 exam: Microsoft Azure essentials · 13 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, Google Cloud and comparing the clouds. 50 topics left in the course before the final exam.

← Previous: Azure compute and storage