Author: Alan

  • 10 – Azure Policy and Governance – Terraform Mini Project

    Table of Contents

    1. Step 1 – Create Resource Group and Base Terraform Setup
    2. Step 2 – Create Mandatory Tag Policy
    3. Step 3 – Create Allowed VM Size Policy
    4. Step 4 – Create Allowed Location Policy
    5. Final Outcome of This Mini Project

    In this mini project, we implement Azure governance using Terraform. The goal is to enforce organizational standards at the subscription level using Azure Policy—so that resources follow rules for:

    • Mandatory tags
    • Allowed VM sizes
    • Allowed deployment locations

    Everything is automated using Terraform infrastructure as code.


    Step 1 – Create Resource Group and Base Terraform Setup

    We start by creating:

    • A resource group
    • Variables for locations, VM sizes, and allowed tags
    • Output to display current subscription ID

    Resource Group – rg.tf

    resource "azurerm_resource_group" "rg" {
      name     = "rgminipro7878"
      location = "Central US"
    }
    

    Read Current Subscription – main.tf

    data "azurerm_subscription" "subscriptioncurrent" {}
    

    Output Subscription ID – output.tf

    output "subscription_id" {
      value = data.azurerm_subscription.subscriptioncurrent.id
    }
    

    Variables – variables.tf

    variable "location" {
      type    = list(string)
      default = ["eastus", "westus"]
    }
    
    variable "vm_sizes" {
      type    = list(string)
      default = ["Standard_B2s", "Standard_B2ms"]
    }
    
    variable "allowed_tags" {
      type    = list(string)
      default = ["department", "project"]
    }
    

    After running:

    terraform apply
    

    ✔ Resource group was created
    ✔ Subscription ID output was verified


    Step 2 – Create Mandatory Tag Policy

    Next, we enforce that every resource must contain two tags:

    • department
    • project

    If either tag is missing → resource creation is denied.

    Policy Definition – policy1.tf

    resource "azurerm_policy_definition" "tagpolicy" {
    
      name         = "allowed-tag"
      policy_type  = "Custom"
      mode         = "All"
      display_name = "Allowed tags policy"
    
      policy_rule = jsonencode({
        if = {
          anyOf = [
            {
              field  = "tags[${var.allowed_tags[0]}]"
              exists = false
            },
            {
              field  = "tags[${var.allowed_tags[1]}]"
              exists = false
            }
          ]
        }
    
        then = {
          effect = "deny"
        }
      })
    }
    

    Assign Policy to Subscription

    resource "azurerm_subscription_policy_assignment" "tag_assign" {
    
      name = "tag-assignment"
    
      policy_definition_id = azurerm_policy_definition.tagpolicy.id
    
      subscription_id = data.azurerm_subscription.subscriptioncurrent.id
    }
    

    ⚠ Important
    To create and assign policies, your account must have:
    Resource Policy Contributor role.

    Testing the Policy – testrg.tf

    resource "azurerm_resource_group" "bad" {
      name     = "bad-rg"
      location = "Central US"
    
      tags = {
        department = "IT"
        project    = "Demo"
      }
    }
    

    ✔ Without tags → RG creation blocked
    ✔ With tags → RG creation allowed


    Step 3 – Create Allowed VM Size Policy

    Now we restrict which VM sizes can be used.

    Allowed sizes:

    • Standard_B2s
    • Standard_B2ms

    Policy Definition – policy2.tf

    resource "azurerm_policy_definition" "vm_size" {
    
      name         = "vm-size"
      policy_type  = "Custom"
      mode         = "All"
      display_name = "Allowed vm policy"
    
      policy_rule = jsonencode({
        if = {
          field = "Microsoft.Compute/virtualMachines/sku.name"
    
          notIn = [
            var.vm_sizes[0],
            var.vm_sizes[1]
          ]
        }
    
        then = {
          effect = "deny"
        }
      })
    }
    

    Assign VM Size Policy

    resource "azurerm_subscription_policy_assignment" "vm_assign" {
    
      name = "size-assignment"
    
      policy_definition_id = azurerm_policy_definition.vm_size.id
    
      subscription_id = data.azurerm_subscription.subscriptioncurrent.id
    }
    

    ✔ Any VM outside allowed list → blocked
    ✔ Governance enforced at subscription level


    Step 4 – Create Allowed Location Policy

    Finally, we restrict deployments only to:

    • eastus
    • westus

    Policy Definition – policy3.tf

    resource "azurerm_policy_definition" "location" {
    
      name         = "location"
      policy_type  = "Custom"
      mode         = "All"
      display_name = "Allowed location policy"
    
      policy_rule = jsonencode({
        if = {
          field = "location"
    
          notIn = [
            var.location[0],
            var.location[1]
          ]
        }
    
        then = {
          effect = "deny"
        }
      })
    }
    

    Assign Location Policy

    resource "azurerm_subscription_policy_assignment" "loc_assign" {
    
      name = "location-assignment"
    
      policy_definition_id = azurerm_policy_definition.location.id
    
      subscription_id = data.azurerm_subscription.subscriptioncurrent.id
    }
    

    ✔ Resources in other regions → denied
    ✔ Standardized deployment geography


    Final Outcome of This Mini Project

    Using Terraform + Azure Policy we achieved:

    ✔ Mandatory tagging for all resources
    ✔ Standard VM sizes enforced
    ✔ Controlled allowed regions
    ✔ Governance at subscription level
    ✔ Fully automated with IaC

    This approach is ideal for:

    • Enterprise governance
    • Cost control
    • Security compliance
    • Standardization across teams
  • 🎯 What You’ll Learn

    In this blog, we dive deeper into Azure Application Gateway and explore how it can be used as a smart and secure entry point for multiple web applications. By the end of this guide, you will understand how to design real-world traffic routing and protect your applications from common web attacks.

    Here’s what we will be doing:

    • Understand what Azure Application Gateway is and why it works at Layer 7 (Application Layer)
    • Deploy two Ubuntu virtual machines running Nginx as independent web servers
      • One serving video content
      • One serving image content
    • Configure Network Security Groups (NSG) to allow:
      • SSH access for administration
      • HTTP access for users
    • Create an Application Gateway as the single public entry point
    • Implement URL-based routing so that:
      • /videos → goes to the video server
      • /images → goes to the image server
    • Keep backend servers private and protected, exposing only the gateway to the internet
    • Enable Web Application Firewall (WAF) to defend against:
      • SQL Injection
      • Cross-Site Scripting (XSS)
      • Protocol violations and other malicious requests
    • Learn the difference between:
      • Detection mode – monitor attacks
      • Prevention mode – actively block threats

    By the end of this blog, you will have a clear, hands-on understanding of how Application Gateway can:

    ✅ Route traffic intelligently
    ✅ Secure multiple apps with one public IP
    ✅ Protect web applications using enterprise-grade WAF

    Let’s get started 🚀

    STEP 1 : 🖥️ Creating Two Ubuntu Web Servers

    To demonstrate URL-based routing with Application Gateway, we first need two separate web servers. Each server will handle a different type of content, and later the gateway will decide where to send traffic based on the request URL.

    🎯 Goal of This Setup

    • Create 2 Ubuntu Virtual Machines in the same subnet
    • One VM will serve video pages
    • The other VM will serve image pages
    • Application Gateway will later route:
      • /videos → Video VM
      • /images → Image VM

    💡 We do NOT attach NSG directly to each VM.
    Instead, we attach a single NSG to the subnet for centralized control.


    🔐 Network & NSG Configuration

    While creating the VMs:

    • You can assign Public IPs to make SSH access easy for testing
    • Skip NSG at VM level (we manage it at subnet level)

    Modify NSG Rules

    We need two inbound rules:

    1️⃣ Allow SSH to the VMs

    • Destination: Private IPs of the VMs
    • Service: SSH (port 22)
    • Purpose: Admin access to configure the servers

    2️⃣ Allow HTTP Traffic

    Since these VMs will act as web servers:

    • Source: Internet (Service Tag)
    • Destination Port: 80 (HTTP)
    • Destination: Private IPs of the VMs

    This allows users to browse the pages hosted on the servers.


    🧰 Install Nginx on Both VMs

    Now we turn both Ubuntu machines into web servers.

    SSH into each VM and run:

    sudo apt update
    sudo apt install nginx
    

    After installation, Nginx starts serving files from:

    /var/www/html
    

    🎬 Configure First VM – Video Web Server

    On VM 1, we create content for videos:

    cd /var/www/html
    sudo chmod 777 /var/www/html
    mkdir videos
    cd videos
    echo "Videos for you" > Default.html
    

    Now this server responds to:

    👉 http://<VM1-Public-IP>/videos/Default.html

    and shows:

    Videos for you


    🖼️ Configure Second VM – Image Web Server

    On VM 2, repeat the same steps but for images:

    cd /var/www/html
    sudo chmod 777 /var/www/html
    mkdir images
    cd images
    echo "Images for you" > Default.html
    

    This server is available at:

    👉 http://<VM2-Public-IP>/images/Default.html

    and displays:

    Images for you


    ✅ What We Have Achieved So Far

    At this stage:

    ✔ Two independent Ubuntu web servers are running
    ✔ Both are in the same subnet
    ✔ NSG allows SSH and HTTP access
    ✔ Each server serves different content
    ✔ We can browse them directly using their IPs

    But users currently need to remember two different IP addresses

    In the next step, we will:

    Use Application Gateway to provide a single entry point and route traffic automatically based on URL 🚦

    STEP 2:🚦 Implement URL Routing Using Application Gateway

    Now that we have two web servers ready—one for videos and one for images—it’s time to place Application Gateway in front of them.
    The goal is simple:

    Users will access a single public IP, and the gateway will decide which VM should handle the request based on the URL.


    🧱 Prerequisite – Empty Subnet for Application Gateway

    Application Gateway must be deployed in its own dedicated subnet.
    It cannot share a subnet with VMs or other resources.

    So first ensure:

    ✔ A separate subnet exists (e.g., appgw-subnet01)
    ✔ No VMs or other services are inside this subnet


    🌐 Create Frontend IP

    While creating the Application Gateway:

    1. Add a new Public IP address
    2. This IP becomes the single entry point for all users

    💡 After this setup, users will no longer connect directly to the web servers—only to this frontend IP.


    🧩 Create Backend Pools

    We need two backend pools, one for each server:

    • 🎬 videoserver → points to Video VM
    • 🖼️ imageserver → points to Image VM

    Each pool contains the private IP of the corresponding Ubuntu VM.


    🎧 Configure Listener

    The Listener decides when routing rules should be applied.

    We create a listener with:

    • Protocol: HTTP
    • Port: 80
    • Frontend IP: Application Gateway public IP

    📌 Listener = “Wait for requests on this IP and port before applying any routing logic.”


    🎯 Configure Backend Targets

    Next we connect the listener to a backend pool:

    1. Select a backend pool (e.g., videoserver)
    2. Create Backend Settings
      • Just provide a name like settings01

    Backend settings define how the gateway communicates with the servers.


    🔀 Add Path-Based Routing Rules

    This is the heart of the demo 🔥.

    We click:

    👉 Add multiple targets to create a path-based rule

    Then create two paths:

    Rule 1 – Videos

    • Path: /videos/*
    • Target: videoserver
    • Backend settings: settings01

    Rule 2 – Images

    • Path: /images/*
    • Target: imageserver
    • Backend settings: settings01

    🧠 Now the gateway can read the URL and decide where to send the request.


    🧪 Test the Setup

    Access the Application Gateway public IP:

    👉 http://<appgw-ip>/videos/Default.html
    ➡ Shows “Videos for you”

    👉 http://<appgw-ip>/images/Default.html
    ➡ Shows “Images for you”

    🎉 URL-based routing is working!


    🔐 Final Architecture Result

    ✔ Only Application Gateway needs a public IP
    ✔ Web servers can stay private
    ✔ Users access one endpoint
    ✔ Traffic is routed intelligently by URL

    URLDestination
    /videosVideo VM
    /imagesImage VM

    💡 What We Achieved

    • Implemented Layer 7 routing
    • Reduced public exposure
    • Centralized traffic control
    • Prepared foundation for WAF security

    In the next section, we will:

    Enable Web Application Firewall (WAF) to protect these applications from real attacks 🛡️.

    🛡️ Web Application Firewall (WAF)

    So far, we have used Application Gateway for routing traffic intelligently.
    Now we add the most important layer — Web Application Firewall (WAF).

    💡 WAF is enabled and managed directly from the Application Gateway resource, not from the backend VMs or App Service.

    WAF protects web applications from common and dangerous attacks such as:

    • 💉 SQL Injection
    • 🧨 Cross-Site Scripting (XSS)
    • 🚫 Protocol violations
    • 🤖 Malicious bots and scanners

    Instead of exposing our web servers directly to the internet, WAF acts like a smart shield in front of them.


    🆕 Creating a WAF Policy

    To enable WAF on the Application Gateway:

    1. Open the Application Gateway resource
    2. Go to the Web Application Firewall blade
    3. Click Create new to create a WAF policy

    This policy will be attached to the gateway and will inspect all incoming requests.


    🔍 Detection Mode vs Prevention Mode

    After the policy is created, its default mode is:

    👉 Detection Mode

    • WAF only logs suspicious requests
    • Traffic is still allowed to reach the application
    • Useful for testing without blocking real users

    You can switch to:

    👉 Prevention Mode

    • Malicious requests are actively blocked
    • Real protection for production environments

    💡 Best Practice
    Start with Detection, monitor logs, then move to Prevention.


    📦 Managed Rules

    Inside the WAF policy:

    1. Go to Policy settings → Managed rules

    Here you will see a large set of built-in rules provided by Microsoft (based on OWASP standards).

    These rules automatically detect:

    • SQL injection patterns
    • XSS payloads
    • Illegal HTTP methods
    • Malformed requests

    ✅ No need to write complex security logic — WAF handles it for you.


    ✍ Adding Custom Rules

    Apart from managed rules, we can create our own logic.

    From the Custom rules blade:

    1. Click + Add custom rule
    2. Define conditions such as:
    • Block specific IP addresses
    • Allow only certain countries
    • Rate-limit requests
    • Deny traffic matching patterns

    Example:

    Block traffic if request comes from a specific IP range → Deny traffic

    This gives full control over application security.


    🧠 What We Achieved

    By enabling WAF:

    ✔ Application Gateway inspects every request
    ✔ Common attacks are detected and blocked
    ✔ Security is centralized
    ✔ Backend VMs stay protected


    🏁 Final Architecture

    User → Internet
    ➡ Application Gateway + WAF
    ➡ URL Routing
    ➡ Video / Image Web Servers

    Our web apps are now not just reachable — they are secure and enterprise-ready 🔐.

  • 🔐 3- Security For Web App Hosted in App Service

    Table of Contents

    1. 🎯 What You’ll Learn in This Blog
    2. 🧠 Core Security Concepts
    3. ⚠️ Insecure Way: Exposing VM Web App
    4. 🏢 NSG at NIC vs Subnet
    5. ☁️ Azure Web App Service
    6. 🆚 VM Hosting vs App Service Hosting
    7. 🛡️ How to Secure App Service
    8. 🏰 Analogy – The Mansion Outside the Gate
    9. 🚦 Application Gateway – The Smart Security Guard
    10. 🧪 Demo: Protect App Service with Application Gateway
    11. 💡 What We Understood from the Demo
    12. 🚇 Better Approach – Private Endpoint
    13. 🏁 Final Architecture
    14. ✅ Key Takeaways

    🎯 What You’ll Learn in This Blog

    In this guide we will:

    • Understand how Network Security Groups (NSG) protect Azure resources
    • Learn how IP addresses, protocols, and ports control network traffic
    • Compare security between:
      • Web app hosted in Virtual Machine
      • Web app hosted in Azure App Service
    • Explore why NSG cannot be used for App Service
    • Implement security using:
      • ✅ Service Endpoints
      • ✅ Private Endpoints
      • ✅ Access Restrictions
    • Protect apps using Azure Application Gateway + WAF

    By the end, you’ll know how to secure an App Service web app like an enterprise architect 🛡️.


    🧠 Core Security Concepts

    🔒 Network Security Group (NSG)

    An NSG is a set of rules that decide:

    • Who can access a VM or subnet
    • Which traffic should be allowed or denied

    NSG can be attached to:

    • 🖥️ A VM’s Network Interface (NIC)
    • 🏢 An entire Subnet

    🌐 How Data Travels on a Network

    To send data from System A → System B we need:

    1. IP Address – where to send
    2. Protocol – how to send (TCP/IP)

    📬 What Are Ports?

    Just like physical ports:

    • USB
    • HDMI
    • Ethernet

    Computers also have virtual ports identified by numbers.

    PortPurpose
    80HTTP
    443HTTPS
    22SSH
    3389RDP
    25SMTP

    NSG rules filter traffic using:

    • Source IP
    • Destination IP
    • Port
    • Protocol

    💡 Think of NSG as a digital security guard checking:
    “Where are you coming from? Which door are you using?”


    ⚠️ Insecure Way: Exposing VM Web App

    To make a VM-hosted app public, people usually:

    1. Add NSG rule to allow port 8080
    2. Disable VM firewall

    ❌ This is extremely risky and NOT recommended.


    🏢 NSG at NIC vs Subnet

    Option 1 – Attach NSG to NIC

    • Works per VM
    • Hard to manage at scale

    Option 2 – Attach NSG to Subnet

    • Centralized control
    • Best practice

    📝 Note:
    NSG cannot be applied to the entire VNet—only to subnets or NICs.


    ☁️ Azure Web App Service

    Azure App Service lets you host apps without managing VMs.

    ✔ No OS patching
    ✔ No IIS management
    ✔ Auto scaling
    ✔ Managed platform

    But…

    ❗ You don’t control its VNet or subnet
    ❗ NSG is NOT applicable
    ❗ App is public by default


    🆚 VM Hosting vs App Service Hosting

    FeatureVM HostedApp Service
    Infrastructure controlFullLimited
    NSG supportYesNo
    Public by defaultNoYes
    Management effortHighLow

    So we need different security methods for App Service.


    🛡️ How to Secure App Service

    Two main approaches:

    1. Service Endpoint + Access Restriction
    2. Private Endpoint + Access Restriction

    And on top of that:

    👉 Application Gateway + WAF


    🏰 Analogy – The Mansion Outside the Gate

    • VNet = Gated community
    • Subnet = Building
    • App Service = Mansion outside the gate

    By default → anyone can enter the mansion 😱

    We must:

    1. Restrict public access
    2. Allow only members of our VNet
    3. Create a private tunnel

    🚦 Application Gateway – The Smart Security Guard

    Application Gateway is:

    • Layer 7 load balancer
    • Web traffic inspector
    • Security filter

    Capabilities

    URL-based routing – Direct traffic to different back-end resources based on the requested URL
    Multi-site hosting – Host multiple websites behind a single gateway
    SSL termination – Handle HTTPS encryption at the gateway level
    WAF protection – Block common web attacks using Web Application Firewall

    Key Components of Application Gateway

    1. Front-end IP

    This is the public or private IP address exposed by the Application Gateway.
    All external users connect to this IP first.

    2. HTTP Listener

    The listener receives HTTP or HTTPS requests from users and passes them to routing rules for further processing.

    3. Back-end Pool

    This contains the actual resources where web apps are hosted, such as:

    • Virtual Machines running IIS
    • Azure App Service web apps
    • Or a combination of both

    These resources remain protected behind the Application Gateway and are not directly exposed to the internet.

    4. Routing Rules

    Routing rules decide which back-end resource should handle a particular request based on:

    • URL path
    • Host name
    • Listener configuration

    5. Backend Settings

    These settings define:

    • Whether traffic to the backend should be HTTP or HTTPS
    • Port number
    • Session affinity
    • Health probe configuration

    🧱 Architecture
    Internet → Application Gateway → App Service
    NOT → Internet → App Service directly


    🧪 Demo: Protect App Service with Application Gateway

    🛠️ Step 1 – Create Application Gateway

    To secure the App Service web app, we first deploy an Application Gateway that will act as the single, controlled entry point from the internet to our application.

    Basic Details

    While creating the Application Gateway, provide the following:

    • Name – for example: appgw-webapp
    • Region – same region as the App Service
    • Tier – Standard v2 or WAF v2 (recommended for security)
    • Virtual Network – the VNet that the Application Gateway will trust and operate within

    💡 The selected VNet is important because only resources inside this VNet can communicate privately with the Application Gateway.


    Frontend Configuration

    In the Frontend tab, choose:

    • Public IP address – for internet-facing applications
    • Private IP – only for internal applications

    Since our web app must be accessed from the internet, we select Public IP.


    Backend Pool Configuration

    In the Backend tab:

    • Choose App Service as the backend target
    • Select the App Service created earlier

    ✅ This configuration tells the gateway:
    “Forward incoming requests to this App Service.”


    Routing Rule Configuration

    The routing rule defines how traffic flows through the gateway.
    It has two main parts:

    1. Listener – receives incoming requests
    2. Backend Target – forwards requests to the destination

    Listener Settings Explained

    The listener controls how the gateway accepts traffic.

    • Frontend IP – public IP exposed by the gateway
    • Protocol – HTTP or HTTPS
    • Port – 80 for HTTP, 443 for HTTPS
    • Listener Type – Basic or Multi-site

    For this demo we used:

    • Protocol: HTTP
    • Port: 80
    • Listener Type: Basic

    📌 Use Multi-site listener when hosting multiple websites behind one gateway.

    1️⃣ Listener (Port 80) – How Users Talk to Application Gateway

    The listener defines how users on the internet connect to the Application Gateway. When we choose HTTP on port 80, we are saying that public users will access the gateway using a normal web request like http://22.22.22.22. At this stage, the App Service is not involved yet—the listener only handles traffic between the user and the gateway.


    Backend Target Settings Explained

    This section links the listener to the App Service.

    1. Backend Pool

    Select the pool containing the App Service:

    👉 backendpoolappservice

    This means all requests from the listener will be sent to this App Service.


    2. Backend Settings

    Key values used:

    • Backend protocol: HTTPS – App Service requires secure communication
    • Port: 443 – default HTTPS port
    • Trusted certificate: Yes – App Service uses Microsoft-issued certificates

    2️⃣ Backend Settings (Port 443) – How Gateway Talks to App Service

    After receiving the request, the Application Gateway must forward it to the App Service. Azure App Service only accepts HTTPS traffic on port 443, so the backend settings use protocol HTTPS and port 443. This means there are two separate connections: one from the user to the gateway on port 80, and another secure connection from the gateway to the App Service on port 443.


    3. Host Name Override (Critical Setting)

    Enabled options:

    • ✅ Override with new host name – Yes
    • ✅ Pick host name from backend target
    Why this is important?

    3️⃣ Host Name Override – Why It Is Required

    Think of the App Service like a person whose real name is “myapp.azurewebsites.net.”
    When a user visits the Application Gateway IP, the gateway originally calls the app like:

    “Hey 22.22.22.22, give me the website!”

    But the App Service replies:

    “That’s not my name — I don’t recognize you!” ❌

    When we enable Host Name Override, the gateway changes the message to:

    “Hey myapp.azurewebsites.net, give me the website!”

    Now the App Service says:

    “Yes, that’s me!” ✅

    and it returns the page correctly.
    So Host Name Override simply makes the gateway call the App Service by its real domain name instead of the gateway IP.

    App Service expects requests with its original domain such as:

    myapp.azurewebsites.net
    

    Without host name override, the request comes with the gateway IP and App Service may return:

    ❌ 404 error
    ❌ Host not recognized

    💡 This setting ensures Application Gateway sends the correct host header to the App Service.

    Now the app is reachable via:

    👉 Application Gateway public IP


    🛠️ Step 2 – Add Service Endpoint

    Before we can restrict access to the App Service, the Application Gateway subnet must be authorized to talk to Microsoft Web services.
    This is done using a Service Endpoint.

    💡 If we skip this step and try to add access restrictions first, Azure will show:
    “No service endpoint is present for this subnet.”


    1️⃣ Open the Virtual Network of Application Gateway

    1. Go to the Virtual Network where your Application Gateway is deployed
    2. From the left menu, select Service endpoints

    This page shows which Azure platform services are allowed to be accessed from this VNet.


    2️⃣ Add the Microsoft.Web Service Endpoint

    1. Click + Add
    2. In the Service dropdown, select:

    👉 Microsoft.Web

    This option represents Azure App Service and other web-related PaaS services.


    3️⃣ Select the Application Gateway Subnet

    1. Choose the Subnet in which your Application Gateway is located
    2. Confirm and save the configuration

    This tells Azure:

    “Devices inside this subnet (Application Gateway) are allowed to securely access Azure Web App services.”


    What This Step Actually Does

    After adding the service endpoint:

    • The App Service can now recognize the Application Gateway subnet
    • Traffic from this subnet is treated as trusted Azure backbone traffic
    • We are allowed to create access restriction rules referencing this subnet

    Without this:

    Before we can restrict access to the App Service, the Application Gateway subnet must be authorized to talk to Microsoft Web services.
    This is done using a Service Endpoint.

    💡 If we skip this step and try to add access restrictions first, Azure will show:
    “No service endpoint is present for this subnet.”


    1️⃣ Open the Virtual Network of Application Gateway

    1. Go to the Virtual Network where your Application Gateway is deployed
    2. From the left menu, select Service endpoints

    This page shows which Azure platform services are allowed to be accessed from this VNet.


    2️⃣ Add the Microsoft.Web Service Endpoint

    1. Click + Add
    2. In the Service dropdown, select:

    👉 Microsoft.Web

    This option represents Azure App Service and other web-related PaaS services.


    3️⃣ Select the Application Gateway Subnet

    1. Choose the Subnet in which your Application Gateway is located
    2. Confirm and save the configuration

    This tells Azure:

    “Devices inside this subnet (Application Gateway) are allowed to securely access Azure Web App services.”


    What This Step Actually Does

    After adding the service endpoint:

    • The App Service can now recognize the Application Gateway subnet
    • Traffic from this subnet is treated as trusted Azure backbone traffic
    • We are allowed to create access restriction rules referencing this subnet

    Without this:

    • App Service cannot be locked down to the gateway
    • Access restriction configuration will fail

      🛠️ Step 3 – Block Direct Access to App Service

      Right now, the web app hosted in App Service is publicly accessible by default.
      Anyone on the internet can open the app directly using:

      👉 https://myapp.azurewebsites.net

      Our goal is:

      ❌ Users must NOT access the App Service directly
      ✅ Users should access it ONLY through the Application Gateway

      To achieve this, we configure Access Restrictions in the App Service.


      1️⃣ Check Current Access Status

      1. Open your App Service in the Azure Portal
      2. Go to the Networking blade
      3. Under Inbound traffic configuration, you will see:

      Public network access: Enabled with no access restrictions

      This means the web app is currently open to the entire internet, which is not secure.


      2️⃣ Change Public Access Mode

      1. Click on Public network access
      2. Select the option:

      👉 Enabled from select virtual networks and IP addresses

      This setting tells Azure:

      “Allow access only from specific VNets or IP addresses, and block everyone else.”


      3️⃣ Add an Access Restriction Rule

      Now we create a rule that allows traffic only from the Application Gateway subnet.

      1. Open Access Restrictions
      2. Click + Add

      Enter the following details:

      • Type: Virtual Network
      • Virtual Network: the VNet where Application Gateway is deployed
      • Subnet: Application Gateway subnet
      • Description: e.g., restrictaccessappservice
      1. Click Save

      What This Configuration Achieves

      After applying this rule:

      • ❌ Direct access to
        https://myapp.azurewebsites.net → will be BLOCKED
      • ✅ Access through
        http://<Application-Gateway-IP> → will be ALLOWED

      Because now:

      Only traffic coming from the trusted Application Gateway subnet is permitted.


      Step 4 – Add Access Restriction

      In App Service:

      • Networking → Public Access
      • Allow only:
        • Selected VNet
        • Gateway subnet

      🧪 Result:

      • Direct App Service URL → BLOCKED
      • Gateway URL → WORKS ✅

      💡 What We Understood from the Demo

      When creating the Application Gateway, we place it inside a specific VNet and subnet, and this subnet becomes the network that the gateway trusts.
      Next, we go to that same subnet and enable a Service Endpoint for Microsoft.Web. This step allows resources inside that subnet—mainly the Application Gateway—to securely reach the Azure App Service over the Azure backbone network.

      After enabling the service endpoint, we configure Access Restrictions in the App Service to allow traffic only from this VNet/subnet. As a result:

      1. Application Gateway resides in a trusted subnet
      2. That subnet is authorized to communicate with App Service
      3. App Service accepts traffic only from that subnet and blocks all other public access

      🏰 Analogy Explanation

      Think of it like this:

      • The VNet/subnet is a walled housing community
      • The Application Gateway is the security guard at the gate
      • The App Service is a mansion located outside the wall

      Step 1 – Trust the Guard
      We first tell the system:

      “People coming from this walled community can be trusted to visit the mansion.”

      Step 2 – Give a Special Pass
      By adding the Service Endpoint, we give members of that community a valid pass to reach the mansion through a secure path.

      Step 3 – Lock the Mansion
      Inside the mansion (App Service) we set up a rule:

      “Only people with that pass — meaning traffic from the Application Gateway subnet — are allowed to enter.”

      Everyone else from the public street is blocked 🚫


      🚇 Better Approach – Private Endpoint

      Problem with Service Endpoint

      It still uses public IP internally.

      Private Endpoint = Underground Tunnel

      Benefits:

      • Uses Azure backbone
      • No public IP involved
      • Most secure option

      Steps for Private Endpoint

      1. Create Private Endpoint for App Service
      2. Use separate subnet (no service endpoint)
      3. Disable Public Network Access

      🔐 Final Result
      App can ONLY be accessed via Application Gateway


      🏁 Final Architecture

      ✔ Internet → Application Gateway (WAF)
      ✔ Gateway → Private Endpoint
      ✔ Private Endpoint → App Service
      ❌ Direct internet → App Service


      ✅ Key Takeaways

      • NSG works for VMs, NOT App Service
      • App Service is public by default
      • Use:
        • Service Endpoint
        • Private Endpoint
        • Access Restrictions
        • Application Gateway

      🚀 Enterprise Best Practice
      Never expose App Service directly to internet

    1. 🌍 2 – Web App In Virtual Network

      Table of Contents

      1. 🎯 What You’ll Learn in This Blog
      2. 🖥️ Hosting a Web App Inside a Virtual Machine
      3. 💻 Creating the Web App in Visual Studio
      4. 🚀 Hosting the App in IIS
      5. ❗ Local Access vs Public Access
      6. 🔐 Securing the Web App in VM
      7. 🛡️ The Right Solution – Application Gateway
      8. 🧩 Final Thoughts

      🎯 What You’ll Learn in This Blog

      In this blog, we will:

      • Deploy a web application inside an Azure Virtual Machine
      • Install and configure IIS + .NET 8 Hosting Bundle
      • Create an ASP.NET Core MVC app using Visual Studio
      • Publish the app and host it on the VM using IIS on port 8080
      • Understand why the app is accessible only locally and not via public IP
      • Learn the security risks of exposing VMs directly to the internet
      • See how Azure Application Gateway protects the web app

      By the end, you’ll know how to host a real web app in a VM—and more importantly, how to secure it 🔐.


      🖥️ Hosting a Web App Inside a Virtual Machine

      To run a web application inside a VM, we must first turn the VM into a web server.

      🧰 Step 1 – Connect to the VM

      • Use Remote Desktop (RDP) to log in to your Azure VM
      • Open Server Manager

      🌐 Step 2 – Install IIS (Web Server)

      1. Go to
        👉 Server Manager → Add Roles and Features
      2. Select:
        Web Server (IIS) role
        ✔ Under features, enable IIS 6 Management Compatibility
      3. Wait for installation to finish ⏳

      After installation you will see:

      C:\inetpub\wwwroot
      

      This folder contains the default IIS landing page.

      ✅ You can test it inside the VM by opening:
      http://localhost


      ⚙️ Step 3 – Install .NET 8 Hosting Bundle

      Download and install the latest .NET 8 Hosting Bundle inside the VM so IIS can run ASP.NET Core apps.

      💡 Without this bundle, IIS cannot host .NET applications.


      💻 Creating the Web App in Visual Studio

      🧪 Step 4 – Build an ASP.NET Core App

      1. Open Visual Studio
      2. Create a project:
        👉 ASP.NET Core Web App (Model–View–Controller)
      3. Make a small UI change to:
        • Home → Index.cshtml
          (so you can recognize your app later)

      📦 Step 5 – Publish as Folder

      1. Right click project → Publish
      2. Choose → Publish to Folder

      In settings select:

      • Self-contained deployment
        (so app runs without external dependencies)
      1. Copy the published folder into the VM.

      🚀 Hosting the App in IIS

      🛠️ Step 6 – Configure IIS Website

      1. Open IIS Manager in the VM
      2. Remove the default website
      3. Click Add Website

      Configure:

      • 📁 Physical path → your published folder
      • 🌐 Port → 8080

      📌 The publish folder must be the parent of the wwwroot folder.


      👀 Step 7 – Test Locally

      Click Browse :8080

      Your web app opens at:

      👉 http://localhost:8080

      🎉 The app is now running inside the VM!


      ❗ Local Access vs Public Access

      Right now:

      • ✅ App works inside the VM
      • ❌ App is NOT accessible using the VM’s public IP

      You could open port 8080 to the internet…
      👉 But this is a BAD idea.


      🔐 Securing the Web App in VM

      Exposing a VM directly to the internet introduces serious risks.

      ⚠️ Common Security Threats

      1. 🚨 DDoS Attacks
        Bots flood your app with requests so real users cannot access it.
      2. 🧨 Cross-Site Scripting (XSS)
        Malicious scripts injected into your pages.
      3. 💉 SQL Injection
        Attackers manipulate database queries.
      4. 📉 HTTP Protocol Violations
        Malformed requests to crash or exploit the app.

      ❌ Opening inbound port 8080 is NOT recommended
      Even RDP port should be closed in production.


      🛡️ The Right Solution – Application Gateway

      Instead of exposing the VM:

      • All traffic should enter through Azure Application Gateway
      • Gateway validates and filters requests
      • Only safe traffic reaches the web app

      ✅ Benefits

      • Web Application Firewall (WAF)
      • DDoS protection
      • SSL termination
      • Central entry point
      • No direct VM exposure

      🧠 Architecture Idea
      Internet → Application Gateway → VM Web App
      NOT → Internet → VM directly


      🧩 Final Thoughts

      You have now learned:

      • How to convert a VM into a web server
      • Host an ASP.NET Core app in IIS
      • Why local access ≠ public access
      • The dangers of exposing VMs
      • The importance of Application Gateway

      🚀 Real-world rule:
      Never expose VMs directly—always use a gateway!

    2. 🌐 1 – Azure Virtual Network Basics

      Table of Contents

      1. 🎯 What You’ll Learn in This Blog
      2. 📘 Understanding Azure Virtual Network: Your Gateway to Secure Cloud Architecture
      3. 🏘️ Virtual Network as a Gated Community – Simple Analogy
      4. 🔢 IP Address and CIDR Notation Explained
      5. 🧩 VNet vs Subnet
      6. 🛠️ Creating VNets in Azure
      7. 🖥️ Adding a Virtual Machine to a VNet
      8. 🌍 Public IP vs Private IP
      9. 🤔 Why Do We Need Azure Virtual Network?
      10. ✅ Final Thoughts

      🎯 What You’ll Learn in This Blog

      In this blog, we will:

      • Understand why Azure Virtual Network (VNet) is required in cloud environments
      • Learn how VNets provide isolation and security on shared Azure infrastructure
      • Use a simple gated community analogy to visualize networking concepts
      • Understand IP addressing and CIDR notation
      • Explore the difference between VNet and Subnet
      • See how to create VNets and attach Virtual Machines
      • Understand Public IP vs Private IP and real-world security best practices

      By the end, you’ll clearly understand how Azure networking protects your resources and how traffic flows inside the cloud 🚀.


      📘 Understanding Azure Virtual Network: Your Gateway to Secure Cloud Architecture

      Azure resources such as Virtual Machines, databases, and applications run on shared physical servers. That means multiple organizations may be using the same underlying hardware.

      👉 So how does Azure keep your environment separate and secure?

      This is where Azure Virtual Network (VNet) comes in.

      VNets create a logically isolated network for your subscription so that:

      • Your data is separated from other organizations
      • Communication between your resources stays private
      • You can fully control inbound and outbound traffic

      🔐 Key Idea:
      Even though the hardware is shared, VNet ensures your network behaves like your own private data center.


      🏘️ Virtual Network as a Gated Community – Simple Analogy

      Let’s simplify Azure networking with a real-life example.

      Imagine a gated housing community:

      • 🏡 Entire community → Virtual Network (VNet)
      • 🧱 Boundary wall → Firewall
      • 🏢 Buildings → Subnets
      • 🏠 Apartments → Virtual Machines (VMs)
      • 👮 Main security guard → Application Gateway / Load Balancer
      • 🔑 Buzzer system → Network Security Group (NSG)

      What does the main security guard do?

      The Application Gateway or Load Balancer performs three major tasks:

      1. Check ID – Authenticate & authorize traffic
      2. Check availability – Is the destination healthy?
      3. Find alternative – Route to another VM if needed

      Each building (subnet) can also have its own security system—just like an NSG that filters traffic at subnet or VM level.

      🧠 Analogy Summary
      VNet = Community
      Subnet = Building
      VM = Apartment
      NSG = Door security
      Gateway = Main entrance guard


      🔢 IP Address and CIDR Notation Explained

      Whenever we create a VNet or subnet, we must define an IP address range.

      IPv4 Basics

      An IPv4 address looks like:

      97.87.3.1
      
      • It has 4 parts
      • Each part = 8 bits
      • Value ranges from 0 to 255 (because 2⁸ = 256)

      📐 What is CIDR Notation?

      CIDR notation defines how big a network is.

      Example:

      👉 100.8.0.0/24

      • /24 → first 24 bits = network portion
      • Remaining 8 bits = device addresses
      • Total addresses = 2⁸ = 256

      📌 Important Rule
      ➕ More bits for network → ➖ fewer devices
      ➖ Fewer bits for network → ➕ more devices


      🧩 VNet vs Subnet

      • VNet = Full address space
      • Subnet = Smaller range inside the VNet

      Example

      • VNet → 100.8.0.0/24 → 256 possible IPs
      • Subnet → 100.8.0.0/28 → only 16 IPs (2⁴)

      🏙️ Think of it like:
      City = VNet
      Neighborhood = Subnet


      🛠️ Creating VNets in Azure

      🛠️ Steps to Create a Virtual Network and Subnet in Azure

      Follow these steps in the Azure Portal to set up your Virtual Network (VNet) and subnet.


      ✅ Step 1 – Sign in to Azure Portal

      1. Open https://portal.azure.com
      2. Log in with your Azure account
      3. Click Create a resource from the home page

      ✅ Step 2 – Locate the Virtual Network Service

      1. In the search bar, type Virtual Network
      2. Select Virtual Network from the results
      3. Click Create

      ✅ Step 3 – Provide Basic Details

      In the Basics tab, enter:

      • Subscription – Choose your Azure subscription
      • Resource Group – Select existing or create new
      • Name – Example: MyVNet
      • Region – Choose the closest region

      Then click Next: IP Addresses


      ✅ Step 4 – Configure VNet Address Space

      Define the IP range for the whole network.

      • Default example: 10.0.0.0/16
      • Custom example: 100.8.0.0/24

      💡 The address range must not overlap with other VNets or on-prem networks.


      ✅ Step 5 – Add a Subnet

      1. Click Add Subnet
      2. Enter:
      • Subnet name – e.g., WebSubnet
      • Address range – e.g., 100.8.0.0/28
      1. Click Add

      ⚠️ Azure automatically reserves the first 5 IP addresses in every subnet for internal use.


      ✅ Step 6 – Optional Security Settings

      You may enable:

      • Azure Firewall
      • DDoS Protection
      • Bastion Host

      These can also be configured later.

      Click Next: Tags → then Review + Create

      While creating a VNet in the Azure portal you can:

      • Choose the address range
      • Rename the default subnet
      • Add additional subnets
      • Let Azure handle non-overlapping ranges

      We can add more subnets to an existing virtual network.

      ⚠️ Azure Reserved IPs

      Azure automatically reserves the first 5 IP addresses in every subnet for internal management.

      So they cannot be assigned to your VMs.

      💡 Example
      If subnet starts at 10.0.0.0
      → 10.0.0.0 to 10.0.0.4 are reserved by Azure


      🖥️ Adding a Virtual Machine to a VNet

      When creating a VM, Azure asks you to select:

      • The Virtual Network
      • The Subnet

      This ensures the VM becomes part of your private cloud network and follows all NSG and routing rules.


      🌍 Public IP vs Private IP

      🟢 Private IP

      • Used for communication inside VNet
      • Not reachable from the internet
      • Unique within the VNet

      🔴 Public IP

      • Used for global internet access
      • Exposes the resource to external traffic
      • Higher security risk

      ❓ Why Do We Need Both?

      To improve security:

      • ❌ Block public IP on individual VMs
      • ✅ Allow access only through Application Gateway
      • 🌐 Only the gateway gets a public IP

      🔐 Best Practice
      In real environments, all requests should enter via Application Gateway, not directly to VMs.

      This minimizes attack surface and gives full control.


      🤔 Why Do We Need Azure Virtual Network?

      Because in Azure:

      • Physical servers are shared
      • Multiple subscriptions coexist
      • Security and isolation are mandatory

      VNet ensures:

      • ✅ Organization-level isolation
      • ✅ Secure communication
      • ✅ Controlled internet exposure
      • ✅ Enterprise-grade networking

      🚀 Without VNet → open playground
      With VNet → secured private fortress


      ✅ Final Thoughts

      Azure Virtual Network is the foundation of cloud networking. Understanding:

      • VNets
      • Subnets
      • CIDR
      • NSG
      • Application Gateway
      • Public vs Private IP

      is essential for:

      • Azure administration
      • AZ-104 certification
      • Real-world cloud architecture

      You’ve now taken the first step toward mastering Azure networking 💪.

    3. 1 – Explore identity in Microsoft Entra ID 🔐☁️

      Table of Contents

    4. 1.1 – Explain the identity landscape 🌍

      Before diving into Microsoft Entra ID features, it’s important to understand how Microsoft views identity in modern security.

      The Identity Lifecycle Model

      Identity in Microsoft is built around five pillars:

      1️⃣ Zero Trust – Verify Explicitly | Use Least Privilege | Assume Breach
      2️⃣ Identity Sources – B2B, B2C, Verifiable Credentials
      3️⃣ Actions – Authenticate (AuthN), Authorize (AuthZ), Administer, Audit
      4️⃣ Usage – Access apps & data, security, licensing
      5️⃣ Maintain – Protect → Detect → Respond

      👉 The key message:

      Never grant access just because it was granted yesterday – always confirm again.

      Classic Identity vs Zero Trust 🆚

      Classic Model ❌Zero Trust Model ✅
      Everything inside network is trustedNothing is trusted by default
      One password = full accessContinuous verification
      Firewall focusedIdentity & policy focused

      In today’s world, one stolen credential can destroy everything. Zero Trust protects assets anywhere with central policy.


      1.2 – Explore Zero Trust with identity 🛡️

      Organizations now work in hybrid and multicloud environments. Users connect from home, mobile, and unmanaged devices. Zero Trust assumes:

      “Never trust, always verify.”

      Three Core Principles

      Six Pillars of Zero Trust

      🧑 Identity • 📱 Endpoints • 📂 Data • 🧩 Apps • 🏗️ Infrastructure • 🌐 Network

      Identity is the control plane that decides access to all others.

      Modern Architecture

      🎯 Goal: Only the right people get the right access at the right time.


      1.3 – Discuss identity as a control plane 🎛️

      A control plane decides how access flows—just like a traffic controller.

      In modern IT:

      👤 Identity is the common denominator.

      Every user, device, app, and service has an identity.
      If we don’t know who the user is → no other security matters.

      Once verified, access can be enforced across:


      1.4 – Explore why we have identity 🤔

      Identity enables four major capabilities:

      What is an Identity Provider (IdP)?

      An IdP is a trusted system that:

      👉 Example: Microsoft Entra ID

      Common Protocols


      1.5 – Define identity administration 🛠️

      Identity administration manages accounts from birth to retirement.

      Real-World Risk Story 🚨

      Juan leaves company → account not removed →
      password reused → phishing → breach using “valid” account!

      Core Administration Tasks

      Automation Options 🤖

      👉 Microsoft Graph = single endpoint to manage identities programmatically.


      1.6 – Contrast decentralized identity with central identity systems 🔄

      Centralized Identity 🏢

      Benefits:

      Decentralized Identity 🆔


      1.7 – Discuss identity management solutions 🧩

      IAM controls:

      Key Microsoft Entra Terms


      1.8 – Explain Microsoft Entra Business to Business 🤝

      Microsoft Entra External Identities

      Allows collaboration with partners using their own accounts.

      B2B Collaboration

      B2B Direct Connect

      Microsoft Entra B2C 👥


      1.9 – Compare Microsoft identity providers 🆚

      ServicePurpose
      Microsoft Entra IDCloud identity for SaaS
      AD DSOn-prem directory
      Entra Domain ServicesManaged AD in Azure

      👉 Entra ID can sync with AD DS for hybrid identity.


      1.10 – Define identity licensing 💳

      Important licenses:

      Subscription vs License


      1.11 – Explore authentication 🔑

      Authentication validates identity with:

      Federation

      Use on-prem AD as trusted source.

      Protocols

      Tokens 🎟️

      Claims = key/value info about user.


      1.12 – Discuss authorization 🚦

      Authorization = what you can do.

      Models

      New Feature

      Authentication Context – require stronger controls for sensitive data.


      1.13 – Explain auditing in identity 📊

      Auditing helps:

      Logs

      Governance is Critical 🧠

      Check:

      Lifecycle: Join → Move → Leave ♻️

      Monitoring Tools

    5. 9 – Terraform Provisioners in Azure : Local-Exec vs Remote-Exec vs File Provisioner (Hands-On Guide)

      When I started learning Terraform, I wondered:

      Terraform can create infrastructure… but how do we run scripts, install software, or copy files after a VM is created?

      That is where Terraform Provisioners come into the picture.

      In this hands-on mini project I implemented:

      • Local-Exec Provisioner
      • Remote-Exec Provisioner
      • File Provisioner

      and understood their real purpose, limitations, and practical usage.

      Table of Contents

      1. Project Goal
      2. Architecture Overview
      3. Step 1 – Create Core Azure Infrastructure
      4. Step 2 – Create VM and Verify SSH
      5. Step 3 – Local-Exec Provisioner
      6. Step 4 – Remote-Exec Provisioner
      7. Debug Steps and Errors Faced
      8. Step 5 – File Provisioner
      9. Understanding Provisioners
      10. Important Reality
      11. Final Learning Outcome

      Project Goal

      Build an Azure Linux VM using Terraform and:

      1. Run a command on my local PC during deployment
      2. Install Nginx inside the VM automatically
      3. Copy a configuration file from my laptop to the VM

      Architecture Overview

      The infrastructure consists of:

      • Resource Group
      • Virtual Network and Subnet
      • Network Security Group (SSH + HTTP)
      • Public IP
      • Network Interface
      • Linux Virtual Machine

      Step 1 – Create Core Azure Infrastructure

      Resource Group

      resource "azurerm_resource_group" "rg" {
        name     = "rgminipro878933"
        location = "Central US"
      }
      

      Virtual Network & Subnet

      resource "azurerm_virtual_network" "vnet" {
        name                = "vnetminipro7678678"
        address_space       = ["10.0.0.0/16"]
        location            = azurerm_resource_group.rg.location
        resource_group_name = azurerm_resource_group.rg.name
      }
      

      Network Security Group

      Inbound rules were added to allow:

      • Port 22 → SSH
      • Port 80 → HTTP

      Step 2 – Create VM and Verify SSH

      Generate SSH Keys

      ssh-keygen -t rsa -b 4096
      

      Create Linux VM

      The VM was created using azurerm_linux_virtual_machine with SSH key authentication.

      Test Connection

      ssh -i key1 azureuser@<public-ip>
      

      ✔ SSH login successful.


      Step 3 – Local-Exec Provisioner

      What Local-Exec Means

      Local-exec runs a command on:

      The machine where Terraform is executed
      NOT inside the Azure VM.

      Implementation

      provisioner "local-exec" {
        command = "echo Deployment started at ${timestamp()} > deployment.log"
      }
      

      Result

      A file deployment.log was created on my laptop — proof that the command executed locally.

      Real-World Uses

      • Trigger Ansible after Terraform
      • Call REST API or webhook
      • Notify Slack/Email
      • Generate inventory files
      • Write audit logs

      Step 4 – Remote-Exec Provisioner

      Purpose

      Run commands inside the VM after creation.

      Goal

      Install Nginx and deploy a simple webpage automatically.

      Implementation

      provisioner "remote-exec" {
        inline = [
          "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 2; done",
          "sudo apt-get update -y",
          "sudo apt-get install -y nginx",
          "echo '<h1>Terraform Provisioner Demo Working!</h1>' | sudo tee /var/www/html/index.html",
          "sudo systemctl restart nginx"
        ]
      }
      

      Result

      Opening:

      👉 http://<public-ip>/

      displayed the custom webpage ✔

      Debug Lesson

      Initially nginx was not installed because:

      • VM was not fully ready
      • apt was locked by cloud-init

      Adding a wait for:

      /var/lib/cloud/instance/boot-finished
      

      fixed the issue.

      Debug Steps and Errors Faced

      While implementing this project, I faced several real-world issues. These are the exact steps that helped me troubleshoot.

      SSH Key Permission Issue on Windows

      Azure SSH login failed initially because Windows was treating the private key as insecure.

      Fix: Restrict key permissions in PowerShell

      icacls <key file path> /inheritance:r
      icacls <key file path> /grant:r "$($env:USERNAME):(R)"
      icacls <key file path> /remove "Authenticated Users" "BUILTIN\Users" "Everyone"
      

      After this, SSH worked correctly:

      ssh -i <key file path> azureuser@<public ip>
      

      Important: The key must be stored on an NTFS formatted drive (not FAT/external USB) for permissions to work.


      Web Page Not Loading After Remote-Exec

      Even though Terraform apply was successful, the browser showed:

      ERR_CONNECTION_REFUSED

      Debug Steps Inside VM

      1. SSH into the VM
      ssh -i key1 azureuser@<public-ip>
      
      1. Check if nginx is installed
      which nginx
      sudo systemctl status nginx
      
      1. Test locally inside VM
      curl http://localhost
      

      Root Cause

      • Remote-exec ran before the VM was fully ready
      • cloud-init was still configuring the system
      • apt was locked at the time of execution

      Fix Implemented

      Added wait for cloud-init before installing nginx:

      while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 2; done
      

      After this change, the webpage loaded correctly.


      Lesson Learned

      Terraform showing “Apply complete” does not always mean:

      • Software is installed
      • Services are running
      • VM is fully ready

      Provisioners need proper waiting and validation logic.


      Step 5 – File Provisioner

      Purpose

      Copy files from local machine → VM.

      Implementation

      provisioner "file" {
        source      = "configs/sample.conf"
        destination = "/home/azureuser/sample.conf"
      }
      

      Verification in VM

      ls -l /home/azureuser
      cat sample.conf
      

      ✔ File successfully transferred.


      Understanding Provisioners

      Local-Exec

      • Runs on local computer
      • Used for logs, notifications, triggers

      Remote-Exec

      • Runs inside the VM
      • Installs software, configures OS

      File Provisioner

      • Copies files to remote system

      Important Reality

      Terraform provisioners are:

      • ❌ Not guaranteed
      • ❌ Not idempotent
      • ❌ Not recommended for production

      Better Alternatives

      • cloud-init
      • Custom VM images
      • Ansible
      • Azure VM Extensions

      Final Learning Outcome

      This mini project helped me understand:

      • How Terraform builds infrastructure
      • Difference between the 3 provisioners
      • Debugging real deployment issues
      • Basic Linux + Azure networking

      It connected multiple skills:

      Terraform + Azure + Linux + Automation

    6. 8 – 🚀 Deploy Azure Functions with Terraform — QR Code Generator Mini Project (Step-by-Step)

      In this post, I’ll walk you through a complete, working mini project where we deploy an Azure Linux Function App using Terraform and then deploy a Node.js QR Code Generator function using Azure Functions Core Tools.

      This is not just theory — this is exactly what I built, debugged, fixed, and verified end-to-end. I’ll also call out the gotchas I hit (especially in Step 2), so you don’t lose hours troubleshooting the same issues.

      Table of Contents

      1. 🔹 What We Are Building
      2. 🧱 Step 1: Create Core Azure Infrastructure with Terraform
      3. ⚙️ Step 2: Create the Linux Function App (Most Important Step)
      4. 📦 Step 3: Prepare the QR Code Generator App
      5. 🔐 Add local.settings.json (Local Only)
      6. 🚫 Add .funcignore
      7. 🛠 Install Azure Functions Core Tools (Windows)
      8. 🚀 Deploy the Function Code
      9. 🧪 Step 4: Test the Function End-to-End
      10. ✅ What This Demo Proves
      11. 🧠 Final Notes
      12. 🎯 Conclusion

      🔹 What We Are Building

      • Azure Resource Group
      • Azure Storage Account
      • Azure App Service Plan (Linux)
      • Azure Linux Function App (Node.js 18)
      • A Node.js HTTP-triggered Azure Function that:
        • Accepts a URL
        • Generates a QR code
        • Stores the QR image in Azure Blob Storage
        • Returns the QR image URL as JSON

      🧱 Step 1: Create Core Azure Infrastructure with Terraform

      In this step, we create the base infrastructure required for Azure Functions.

      Resource Group (rg.tf)

      resource "azurerm_resource_group" "rg" {
        name     = "rgminipro767676233"
        location = "Central US"
      }
      

      Storage Account (sa.tf)

      Azure Functions require a storage account for:

      • Function state
      • Logs
      • Triggers
      • Blob output (our QR codes)
      resource "azurerm_storage_account" "sa" {
        name                     = "saminipro7833430909"
        resource_group_name      = azurerm_resource_group.rg.name
        location                 = azurerm_resource_group.rg.location
        account_tier             = "Standard"
        account_replication_type = "LRS"
      }
      

      ⚠️ Storage account names must be globally unique and lowercase.

      App Service Plan (splan.tf)

      This defines the compute for the Function App.

      resource "azurerm_service_plan" "splan" {
        name                = "splanminipro8787"
        resource_group_name = azurerm_resource_group.rg.name
        location            = azurerm_resource_group.rg.location
        os_type             = "Linux"
        sku_name            = "B1"
      }
      

      Apply Terraform

      terraform apply
      

      ✅ Verify in Azure Portal:

      • Resource Group created
      • Storage Account exists
      • App Service Plan is Linux (B1)

      ⚙️ Step 2: Create the Linux Function App (Most Important Step)

      This step required multiple fixes for the app to actually run, so pay close attention.

      Linux Function App (linuxfa.tf)

      resource "azurerm_linux_function_app" "linuxfa" {
        name                = "linuxfaminipro8932340"
        resource_group_name = azurerm_resource_group.rg.name
        location            = azurerm_resource_group.rg.location
      
        storage_account_name       = azurerm_storage_account.sa.name
        storage_account_access_key = azurerm_storage_account.sa.primary_access_key
        service_plan_id            = azurerm_service_plan.splan.id
      
        app_settings = {
          FUNCTIONS_WORKER_RUNTIME = "node"
      
          # Required by Azure Functions runtime
          AzureWebJobsStorage = azurerm_storage_account.sa.primary_connection_string
      
          # Used by our application code
          STORAGE_CONNECTION_STRING = azurerm_storage_account.sa.primary_connection_string
      
          # Ensures package-based deployment
          WEBSITE_RUN_FROM_PACKAGE = "1"
        }
      
        site_config {
          application_stack {
            node_version = 18
          }
        }
      }
      

      Why Each Setting Matters

      • FUNCTIONS_WORKER_RUNTIME
        • Tells Azure this is a Node.js function app
      • AzureWebJobsStorage
        • Mandatory for Azure Functions to start
      • STORAGE_CONNECTION_STRING
        • Used by our QR code logic to upload images
      • WEBSITE_RUN_FROM_PACKAGE
        • Ensures consistent zip/package deployment
      • node_version = 18
        • Must match your app runtime

      Apply Terraform Again

      terraform apply
      

      ✅ Verify in Azure Portal:

      • Function App is Running
      • Runtime stack shows Node.js 18
      • No startup errors

      📦 Step 3: Prepare the QR Code Generator App

      Download the App

      Clone or download the QR code generator repository:

      git clone https://github.com/rishabkumar7/azure-qr-code
      

      Navigate to the function root directory (where host.json exists).

      Run npm install

      npm install
      

      This creates the node_modules folder — without this, the function will fail at runtime.

      Expected Folder Structure

      qrCodeGenerator/
      │
      ├── GenerateQRCode/
      │   ├── index.js
      │   └── function.json
      │
      ├── host.json
      ├── package.json
      ├── package-lock.json
      ├── node_modules/
      

      🔐 Add local.settings.json (Local Only)

      {
        "IsEncrypted": false,
        "Values": {
          "AzureWebJobsStorage": "<Storage Account Connection String>",
          "FUNCTIONS_WORKER_RUNTIME": "node"
        }
      }
      

      ❗ This file is NOT deployed to Azure and should never be committed.


      🚫 Add .funcignore

      This controls what gets deployed.

      .git*
      .vscode
      local.settings.json
      test
      getting_started.md
      *.js.map
      *.ts
      node_modules/@types/
      node_modules/azure-functions-core-tools/
      node_modules/typescript/
      

      ✅ We keep node_modules because this project depends on native Node packages.


      🛠 Install Azure Functions Core Tools (Windows)

      winget install Microsoft.Azure.FunctionsCoreTools
      

      Restart PowerShell and verify:

      func -v
      

      🚀 Deploy the Function Code

      Navigate to the directory where host.json exists:

      cd path/to/qrCodeGenerator
      

      Publish the function:

      func azure functionapp publish linuxfaminipro8932340 --javascript --force
      

      Successful Output Looks Like This

      Upload completed successfully.
      Deployment completed successfully.
      Functions in linuxfaminipro8932340:
          GenerateQRCode - [httpTrigger]
              Invoke url: https://linuxfaminipro8932340.azurewebsites.net/api/generateqrcode
      

      🧪 Step 4: Test the Function End-to-End

      Invoke the Function

      https://linuxfaminipro8932340.azurewebsites.net/api/generateqrcode?url=https://example.com
      

      Sample Response

      {
        "qr_code_url": "https://saminipro7833430909.blob.core.windows.net/qr-codes/example.com.png"
      }
      

      Download the QR Code

      Open the returned Blob URL in your browser:

      https://saminipro7833430909.blob.core.windows.net/qr-codes/example.com.png
      

      🎉 You’ll see the QR code image stored in Azure Blob Storage.


      ✅ What This Demo Proves

      • Terraform successfully provisions Azure Functions infrastructure
      • App settings are critical for runtime stability
      • Azure Functions Core Tools deploy code from the current directory
      • Missing npm install causes runtime failures
      • Blob Storage integration works end-to-end
      • Azure Functions can be tested via simple HTTP requests

      🧠 Final Notes

      • Warnings about extension bundle versions were intentionally ignored
      • This demo focuses on learning Terraform + Azure Functions, not production hardening
      • In real projects, code deployment is usually handled via CI/CD pipelines

      🎯 Conclusion

      This mini project demonstrates how Infrastructure as Code (Terraform) and Serverless (Azure Functions) work together in a practical, real-world scenario.

      If you can build and debug this, you’re well on your way to mastering Azure + Terraform.

      Happy learning 🚀

    7. 2 – Understanding Document Library In SharePoint; With Video Explanation

      Table of Contents

      1. Managing Files in SharePoint
      2. Editing Files and Using Version History in SharePoint
      3. Versioning and Check-In/Check-Out in SharePoint
      4. Accessing SharePoint Files Offline with OneDrive
      5. Using Templates and Managing the New Menu in SharePoint
      6. Associating Metadata with Uploaded Files in SharePoint
      7. Organize SharePoint Files Smarter with Metadata
      8. Track and Analyze Expenses in SharePoint Using Currency Metadata
      9. Visually Enhance SharePoint Lists with Conditional Formatting and Column Styling
      10. Customizing Columns in a SharePoint Document Library
      11. Creating and Managing Custom Views in SharePoint Document Libraries
      12. Document Library Top Menu: A Quick Guide
      13. Organize Your SharePoint Site with a New Document Library
      14. Create and Manage Site Navigation Links in SharePoint
      15. Create and Use a Picture Library in SharePoint
      16. A Quick Guide to SharePoint Library Settings
    8. Managing Files in SharePoint

      Microsoft SharePoint provides a simple and powerful way to store, organize, and collaborate on files with your team. You can upload documents, create new ones directly in the site, edit files in your browser, and share them with others—all in one place.

      In this section, we’ll look at how to navigate the Documents library and how to work with files effectively, including organizing and opening them.

      Video Explanation


      The Documents library is the main area where files are stored and managed in a SharePoint site. It’s designed to make adding and organizing files easy.

      You can create new content or upload existing files from your computer.

      👉 How to add documents:

      1. Open your SharePoint site.
      2. Select Documents from the left menu.
      3. Click the New button at the top left.
      4. Choose one of the following:
      5. When uploading, choose either:

      Once uploaded, your files appear in the document library and are ready to use.

      ✨ Example: You might upload a Word file, an Excel sheet, and a PowerPoint file to quickly build your document library.


      Working with Files in SharePoint

      After files are added, you can work with them directly online. This allows quick collaboration without needing to download files first.

      👉 Common file actions:

      Open and Edit Online

      Share with Colleagues

      View File Details

      Quick Access from the Homepage

      ✨ This makes editing, sharing, and reviewing files smooth and collaborative.


      Creating Files and Folders

      You don’t always need to upload files—SharePoint lets you create them directly.

      However, relying only on folders is considered an older method of organization in SharePoint.


      Organizing with Metadata (Columns)

      SharePoint offers metadata features to organize files more effectively than folders alone.

      Using metadata helps teams find files faster without deep folder structures.


      Opening and Reading Files

      SharePoint provides multiple ways to open and read files:

      1. Open in App
      2. Open in Browser
      3. Immersive Reader

      By using document libraries, online editing, sharing tools, and metadata, SharePoint makes file management organized and team-friendly.

      Editing Files and Using Version History in SharePoint

      Microsoft SharePoint makes file editing and collaboration simple by allowing you to work directly in your browser or in desktop apps. There’s no need to download and re-upload files after every change. Even better, SharePoint automatically saves your work and supports real-time collaboration, so teams can edit together without confusion.

      Another key feature is Version History, which quietly tracks changes and lets you restore earlier versions if needed. Together, these tools make file management safer and more efficient.

      Video Explanation


      Editing Files in SharePoint

      One of the biggest advantages of SharePoint is how easy it is to edit files. You can open a file and start working immediately, with changes saved automatically.

      How editing works:

      👉 Steps to edit a file:

      1. Go to your Documents Library.
      2. Click the file name (for example, a Word or Excel file).
      3. The file opens in a new browser tab.
      4. Start typing or making changes — they save automatically.

      More editing options:

      When others are editing the same file, you’ll see their initials or cursors in real time. This makes teamwork smooth and avoids duplicate versions.


      File Version History in SharePoint

      Version History is a built-in safety feature. Every time a file is saved, SharePoint keeps a record of previous versions. This allows you to review or restore older copies if needed.

      Why Version History matters:

      👉 Steps to access Version History:

      1. In the Documents Library, find your file.
      2. Click the three dots () next to it.
      3. Select Version History.
      4. A list of saved versions appears.

      Options for each version:

      If you restore a version, SharePoint rolls the file back while still keeping newer versions stored. This ensures you never permanently lose important work.

      Versioning and Check-In/Check-Out in SharePoint

      Versioning is one of the most valuable features in Microsoft SharePoint for managing files. It helps teams track edits, collaborate confidently, and restore earlier versions when needed. Instead of saving files as “v1,” “v2,” or “final-final,” SharePoint automatically keeps a history of changes for you.

      In this section, we’ll look at how versioning works, how check-out/check-in supports controlled editing, and how versioning applies to non-Office files.

      Video Explanation


      Understanding Versioning

      Versioning allows you to track and manage changes made to a file over time. Every time a file is edited and saved, SharePoint records a new version in the background.

      Why versioning is useful:

      SharePoint also supports simultaneous editing, meaning multiple users can work on the same file at the same time. You may see another user’s cursor or presence indicator while they are editing, which helps avoid conflicts.

      If unwanted edits are made, you can simply restore a previous version from the version history.


      Check-Out and Check-In

      Sometimes, you may want to prevent others from editing a file while you work on it. That’s where check-out and check-in come in.

      How it works:

      When checking a file back in, you can add comments describing your changes. These comments appear in the version history and help track what was updated.

      When to use check-out/check-in:


      Versioning for Non-Office Files

      Versioning also works for non-Office files such as videos, images, or PDFs. The main difference is that these files cannot be edited by multiple users at the same time in SharePoint.

      How versioning works for non-Office files:

      SharePoint recognizes this as a new version of the file.

      You can then:

      This is especially helpful for files like videos or design assets that go through multiple revisions.


      Using versioning together with check-in and check-out gives teams strong control over file edits while still supporting collaboration. It ensures that changes are tracked, recoverable, and organized without extra manual effort.

      Accessing SharePoint Files Offline with OneDrive

      Working offline doesn’t mean you have to stop using SharePoint. With OneDrive integration, you can sync your SharePoint document libraries to your computer and access them directly from File Explorer—even without a constant internet connection. Any changes you make offline will automatically sync once you’re back online.

      In this section, you’ll learn how to add a SharePoint library shortcut to OneDrive and then access those files from your PC.

      Video Explanation


      Add a SharePoint Library Shortcut to OneDrive

      Adding a shortcut connects your SharePoint document library to your OneDrive. This lets you view and manage the same folders from both SharePoint and OneDrive.

      👉 Steps to add the shortcut:

      1. Open your SharePoint document library.
      2. At the top, click Add shortcut to OneDrive.
      3. Wait for the confirmation notification.

      👉 Verify in OneDrive:

      1. Sign in to the Microsoft 365 portal.
      2. Open OneDrive from the side navigation.
      3. Click the folder icon in the OneDrive menu to view your files.
      4. Look for a folder named after your SharePoint site followed by the library name.
      5. Open it to confirm the folder structure matches SharePoint.

      Key Point: The folder structure you see in OneDrive mirrors your SharePoint library.


      Access OneDrive from Your Windows PC

      Once synced, you can access your SharePoint files directly from your PC using OneDrive.

      👉 Steps to access files from a PC:

      1. Log into a Windows PC using your organizational account.
      2. Complete multi-factor authentication if prompted.
      3. Open File Explorer.
      4. Select OneDrive from the left sidebar.
      5. Sign in if requested.

      You’ll now see the same folders that appear in OneDrive on the web, including your SharePoint site folders.


      Creating and Syncing Files Offline

      You can create or edit files locally, and they will sync automatically.

      👉 Example workflow:

      When you later open SharePoint in your browser and navigate to the same folder, you’ll see that file there.

      Key Point: Any changes made on your PC sync seamlessly to SharePoint, keeping files updated across devices.


      Using OneDrive with SharePoint gives you the flexibility to work from your desktop while still benefiting from cloud storage and collaboration features provided by Microsoft 365.

      Using Templates and Managing the New Menu in SharePoint

      Templates and the New menu in Microsoft SharePoint are simple features that can make a big difference in daily work. They help teams create consistent documents, save time, and reduce repetitive formatting. Instead of starting from scratch each time, users can begin with a ready-made structure.

      In this section, you’ll learn how to upload and use templates, and how to control what appears in the New menu so it fits your team’s needs.

      Video Explanation

      Why this matters:


      Upload and Use a Template File

      Templates are pre-formatted files that users can open, fill in, and save as new documents. They’re useful for quotes, forms, reports, or any document with a standard layout.

      A template can be almost any file type, such as Word, Excel, or PowerPoint.

      How templates help:

      👉 Steps to upload a template:

      1. Open any document library.
      2. Click the New button at the top.
      3. From the dropdown, select Add template (usually at the bottom).
      4. Upload your desired file.

      Once uploaded, your template appears as an option under the New button.

      👉 How it’s used in practice:

      This keeps documents uniform and organized.


      Edit the New Menu

      The New menu appears in every document library and lets users quickly create files, folders, or template-based documents. If the menu shows options you don’t need, you can customize it.

      Why edit the New menu:

      👉 Steps to edit the New menu:

      1. Open your document library.
      2. Click the New button.
      3. Select the Edit option in the menu.
      4. A panel opens on the right with checkboxes.
      5. Check or uncheck items to show or hide them.
      6. Save your changes.

      If a template is no longer needed, simply uncheck it so it doesn’t appear in the New menu.


      Using templates together with a well-managed New menu helps teams work faster, stay consistent, and keep document creation simple.

      Associating Metadata with Uploaded Files in SharePoint

      Using metadata in SharePoint is a powerful way to organize files beyond simple folder structures. Instead of relying only on file names or deep folders, metadata lets you tag files with useful information like department, project, or document type. This makes searching, filtering, and managing documents much easier as your library grows.

      In this section, you’ll learn how to upload files and assign metadata so your documents stay organized and easy to find.

      Video Explanation

      Why metadata is important:


      Upload Files to a Document Library

      Before adding metadata, you first need files in your library.

      👉 Steps to upload files:

      1. Open any document library.
      2. (Optional) Open a folder if you want to upload there.
      3. Click Upload.
      4. Choose Files or Folder from your computer.
      5. Wait for the upload to complete.

      Once uploaded, you’ll see files in the library with default columns such as:

      At this point, filenames may be the only clue about content—but metadata will improve that.


      Create a Metadata Column

      Metadata is added through columns in the document library. Each column stores a specific type of information.

      👉 Example: Create a “Department” column

      1. In the document library, click Add column.
      2. Choose a column type.
      3. Click Next.

      👉 Configure the column:

      1. Click Save.

      Your new metadata column is now ready.


      Assign Metadata to Files

      After creating the column, you need to assign values to your files.

      Method 1: File Details Panel (One-by-One)

      Best for small updates.

      1. Click the three dots () next to a file.
      2. Select Details.
      3. In the panel, choose the correct department.

      Method 2: Edit in Grid View (Bulk Editing)

      Best for multiple files.

      1. Click Edit in Grid View from the top menu.
      2. The library switches to an Excel-like view.
      3. Click cells under the Department column.
      4. Assign departments to multiple files quickly.
      5. Exit grid view when finished.

      This method is much faster when tagging many files.


      Good Practice Tips


      Adding metadata transforms a simple document library into a smart, searchable system. With the right columns in place, teams can quickly filter, group, and find files without digging through folders.

      Organize SharePoint Files Smarter with Metadata

      In Microsoft SharePoint, organizing documents doesn’t have to rely on folders alone. Instead, you can use metadata—custom fields such as Department or Expense Type—to tag files with meaningful information. This approach is far more flexible than traditional folders and makes it easier to search, filter, group, and manage large volumes of documents.

      Metadata helps you see your files from different perspectives without moving or duplicating them. The same document can belong to multiple logical views, something folders simply can’t handle well.

      Video Explanation


      Filtering Files Using Metadata

      Once files are tagged with metadata, you can quickly narrow down what you see.

      How filtering works:

      Steps to filter files:

      1. Go to the column header (for example, Department).
      2. Click the dropdown arrow.
      3. Select Filter.
      4. In the right-hand pane, check the values you want to see (for example, Accounting).
      5. Click Apply.

      Now, only files tagged with that department are displayed.

      To clear filters:


      Grouping Files by Metadata

      Grouping lets you visually organize files into expandable sections based on metadata values. This is especially useful when working with many related documents.

      How grouping helps:

      Steps to group files:

      1. Click the dropdown on a metadata column (for example, Department).
      2. Select Group by Department.

      Files are now grouped under headers like Accounting, Sales, or HR. Each group has an arrow that lets you collapse or expand it.

      You can also:


      Switching Between Different Metadata Views

      You’re not limited to one way of grouping.

      At the top of the file list, you’ll also find:

      These options help you quickly switch between a high-level overview and a detailed view.


      By using metadata with filtering and grouping, SharePoint turns a simple document library into a powerful, flexible file management system—making it much easier to find, organize, and work with your files at scale.

      Track and Analyze Expenses in SharePoint Using Currency Metadata

      Microsoft SharePoint can do much more than store documents—it can also help you track and analyze financial data using metadata. Instead of organizing expense files with folders or relying on filenames, you can use structured metadata such as Department, Expense Type, and Currency (Amount) to gain clear, real-time insights directly within a document library.

      This approach turns a standard SharePoint library into a lightweight financial tracking and reporting tool that’s easy for teams to use.

      Video Explanation


      Add a Currency Metadata Column

      To begin tracking expenses, you first need a currency-based metadata column.

      Steps to create a currency column:

      1. Open your SharePoint document library.
      2. Click Add column.
      3. Select Currency as the column type and click Next.
      4. Enter a column name such as Amount.
      5. Choose the currency format (for example, USD or EUR).
      6. Optionally set a default value or description.
      7. Click Save.

      The new Amount column will now appear alongside your files.


      Enter Financial Values

      Once the column exists, you can start adding values to your files.

      Efficient data entry:

      This method is ideal for entering or updating values across many files at once.


      Sort, Filter, and Group Expense Data

      With currency values in place, SharePoint’s built-in tools let you analyze the data quickly.

      Using the Amount column, you can:

      Grouping makes it easy to compare expenses across teams or cost categories without exporting data.


      Use Totals for Instant Insights

      One of the most powerful features is Totals, which provides quick summaries directly in the library view.

      How to enable totals:

      1. Click the dropdown on the Amount column.
      2. Select Totals.
      3. Choose a calculation such as:

      When combined with grouping, totals become even more valuable. For example:

      You can remove summaries at any time by setting totals back to None.


      Why This Approach Works

      Using currency metadata in SharePoint allows you to:

      With metadata, filtering, grouping, and totals, SharePoint becomes a practical and flexible solution for managing and analyzing expense-related documents.

      Visually Enhance SharePoint Lists with Conditional Formatting and Column Styling

      Microsoft SharePoint makes it easy to store and manage data—but good visual design makes that data far easier to understand and act on. By using view formatting and column styling, you can highlight important information such as high expenses, specific categories, or outliers directly within a list or document library.

      In this section, you’ll learn how to apply alternating row styles, conditional formatting, and column-level styling to make your SharePoint lists more readable, informative, and user-friendly.

      Video Explanation


      Open the Format Current View Panel

      All list-level formatting starts from the same place.

      Steps to open formatting options:

      1. Go to your SharePoint list or document library.
      2. In the top menu, click the All Documents (or current view) dropdown.
      3. Select Format current view.

      You’ll see two tabs:


      Apply Alternating Row Styles

      Alternating row styles improve readability by visually separating rows.

      How to apply:

      1. In the Format view tab, choose Alternating row styles.
      2. Select background colors for:
      3. Click Save to apply.

      ⚠️ This styling is purely visual and does not depend on data values.


      Use Conditional Formatting (Row-Level)

      Conditional formatting lets you style rows based on metadata values such as Expense Type or Department.

      Steps to apply conditional formatting:

      1. In Format view, select Conditional formatting.
      2. Reset any default styling by choosing No style.
      3. Click Add rule.
      4. Choose a column (for example, Expense Type).
      5. Set a condition (for example, equals Travel).
      6. Choose a background color.
      7. Save the rule.

      Only rows matching the condition will be highlighted, making important entries stand out instantly.


      Workaround: Enable Formatting for Currency Columns

      By default, Currency columns cannot be used in view-level conditional formatting. A simple workaround solves this.

      Steps to update the column:

      1. Click the dropdown on the Amount column.
      2. Select Column settings → Edit.
      3. Change the column type from Currency to Number.
      4. In More options, enable Require that this column contains information.
      5. Choose a currency symbol if needed.
      6. Click Save.

      The column will now be available for conditional formatting rules.


      Add Conditional Formatting Based on Amount

      Now you can highlight high-value items automatically.

      Example: highlight large expenses

      1. Open Format current view → Conditional formatting.
      2. Clear any default styles.
      3. Click Add rule.
      4. Choose the Amount column.
      5. Set a condition (for example, Amount is greater than 3000).
      6. Choose a strong color such as red.
      7. Save.

      Any row exceeding that amount will be visually emphasized—even when sorting or filtering the list.


      Use Column Formatting for Individual Cells

      If you prefer to highlight only one column instead of the entire row, use column formatting.

      Steps:

      1. Click the dropdown on the Amount column.
      2. Select Column settings → Format this column.

      You’ll see two powerful options:

      Data bars are especially useful for financial data:


      Reset the View to Default

      If you want to remove all formatting and return to the standard view:

      1. Open Format current view.
      2. Disable Conditional formatting.
      3. Click Save.

      Your list will return to the default white-background layout.


      Why Formatting Matters

      Using conditional formatting and column styling in SharePoint helps you:

      With the right formatting in place, SharePoint lists become easier to scan, analyze, and act on—right where your data lives.

      Customizing Columns in a SharePoint Document Library

      Microsoft SharePoint document libraries become far more useful when columns are arranged and displayed in a way that matches how people actually work. SharePoint provides simple, built-in options to move, hide, show, and pin columns—allowing users to personalize their views without writing code or changing advanced settings.

      In this section, you’ll learn how to adjust column layouts to create a cleaner, more productive document library experience.

      Video Explanation


      Reorder Columns (Move Left or Right)

      Reordering columns helps bring the most important information into focus.

      Method 1: Use Column Settings

      1. Click the dropdown arrow next to the column header.
      2. Select Column settings.
      3. Choose Move left or Move right.

      Method 2: Drag and Drop

      Both methods instantly update the column order in the current view.


      Hide and Show Columns

      If certain columns are not relevant, hiding them reduces clutter and makes the list easier to read.

      Hide a column:

      1. Click the dropdown on the column header.
      2. Select Column settings → Hide this column.

      The column is removed from the view but not deleted.

      Show hidden columns:

      1. Click the dropdown on any visible column.
      2. Go to Column settings → Show/Hide columns.
      3. In the panel that appears, check the columns you want to display (for example, Modified or File size).
      4. Click Apply.

      This is a quick way to bring back hidden columns or add built-in ones.


      Pin Columns to the Filter Pane

      Pinning columns makes filtering faster and more intuitive for users.

      How to pin a column:

      1. Click the dropdown on the column header.
      2. Select Column settings → Pin to filter pane.

      Once pinned:

      To unpin a column:


      Why Column Customization Matters

      Customizing columns in SharePoint helps you:

      With just a few clicks, you can transform a crowded document library into a clean, organized, and highly usable workspace tailored to your team’s needs.

      Creating and Managing Custom Views in SharePoint Document Libraries

      Microsoft SharePoint document libraries can quickly become crowded as files and metadata grow. Views solve this by letting you present the same data in different ways—using filters, sorting, grouping, and totals—without changing the underlying files. Each view is simply a saved configuration, making it easy to tailor what different users see based on their needs.

      Video Explanation


      What Is a View in SharePoint?

      A view is a customized way to display files in a list or document library. With views, you can:

      Views are especially useful for role-based work—finance, sales, or managers can all look at the same library through different lenses.


      Create and Save a Filtered View

      You can quickly turn a temporary filter into a reusable view.

      Steps:

      1. Open the document library.
      2. Click the dropdown arrow on a column header (for example, Department).
      3. Choose Filter by and select the value you want (for example, Sales).
      4. Once the list updates, open the view selector at the top (usually labeled All Documents).
      5. Select Save view as….
      6. Enter a name (for example, Sales Files) and click Save.

      The view is now saved and available in the view selector.


      Create a New View from Scratch

      For more control, you can build a view with detailed settings.

      Steps:

      1. Open the view selector and choose Create new view.
      2. Enter a name and click Create.
      3. Open the view selector again and choose Edit current view.

      From the configuration page, you can customize:

      1. Click OK to save the view.

      Switching Between Views

      All saved views appear in the view selector at the top of the library. You can switch between them at any time, and each view keeps its own layout, filters, grouping, and totals.

      Best practice: Use views where files are consistently tagged with metadata. Views rely on metadata to work correctly and are most effective in well-organized libraries.


      By using custom views strategically, you can transform a single SharePoint document library into multiple, purpose-built workspaces—each tailored to how different teams need to see and analyze the same information.

      Document Library Top Menu: A Quick Guide

      The top menu in a Microsoft SharePoint document library provides quick access to the most important file and metadata management actions. Understanding what each option does helps you work faster, keep files organized, and take full advantage of SharePoint’s document management capabilities.

      In this section, we’ll walk through the key options you’ll find in the document library’s top menu and when to use them.

      Video Explanation


      New, Upload, and Edit in Grid View

      These options focus on adding content and managing metadata.


      These options help you share access without moving files.


      Sync and Add Shortcut to OneDrive

      These options connect your document library to OneDrive and your local machine.


      Download vs. Export to Excel

      These options are often confused but serve different purposes.


      View Options (List, Compact, Tiles)

      You can change how files are visually displayed.


      Files That Need Attention

      Sometimes you may see a red dot next to the All Documents (view selector) dropdown.

      This often happens when:

      Best practice:
      If different document types require different metadata, place them in separate document libraries (for example, one for expense files and another for contracts).


      By using the document library top menu effectively, SharePoint becomes more than file storage—it becomes a structured, metadata-driven document management system that supports collaboration, reporting, and long-term organization.

      Organize Your SharePoint Site with a New Document Library

      When working with different types of files in Microsoft SharePoint, placing everything inside the default Documents library can quickly lead to clutter. Files with different purposes often require different metadata, views, and permissions. A much cleaner and more scalable approach is to create separate document libraries for distinct categories—such as one dedicated library for expense files.

      Using multiple document libraries keeps content organized, simplifies metadata management, and makes the site easier to maintain over time.

      Video Explanation


      Why Create a New Document Library?

      Creating a dedicated document library allows you to:

      For example, storing all expense-related documents in an Expenses library keeps them isolated from contracts, project files, or general documents.


      Steps to Create a New Document Library

      Follow these steps to create a new document library in your SharePoint site:

      1. Go to Site Contents
      2. Click New → App
      3. Switch to Classic Experience (if needed)
      4. Select the Document Library App
      5. Name Your Library
      6. Click Create

      Set Up and Use the New Library

      Once the library is created, you can:

      The new library will always be available under Site Contents, making it easy to return to and manage.


      Best Practice for Long-Term Organization

      Instead of using folders to separate file types, use multiple document libraries with clear purposes. This approach scales better, keeps metadata clean, and makes SharePoint easier for users to understand and use.

      Creating dedicated document libraries is one of the most effective ways to keep a SharePoint site organized, structured, and ready for growth.

      Site navigation links in Microsoft SharePoint make it easy for users to move around a site and quickly access important resources such as document libraries, lists, pages, or even external websites. A well-organized navigation panel improves usability and helps users find what they need without searching.

      In this section, you’ll learn how to add, edit, and remove links from the left-hand site navigation.

      Video Explanation


      You can add links to both internal SharePoint content and external websites.

      Steps to add a navigation link:

      1. Open your SharePoint site.
      2. Go to the left-hand navigation panel.
      3. Scroll to the bottom and click Edit.
      4. Hover between two existing links until a “+” (plus) icon appears.
      5. Click the + icon and select Link.
      6. Enter the link details:
      7. Click OK.
      8. When finished adding links, click Save at the bottom of the navigation panel.

      The new link will now appear in the site navigation.


      If a link is no longer needed, you can remove it easily.

      Steps to remove a link:

      1. Click Edit at the bottom of the navigation panel.
      2. Locate the link you want to remove.
      3. Click the trash (delete) icon next to it.
      4. Click Save to apply the change.

      The link will be removed from the navigation.


      Tip: Get the URL for a Document Library

      To add a navigation link to a document library (for example, Expenses):

      1. Go to Site Contents.
      2. Click the document library you want to link to.
      3. Copy the URL from the browser’s address bar
      4. Use this URL when creating the navigation link.

      By customizing site navigation links, you create a cleaner, more intuitive SharePoint site that helps users access important content quickly and efficiently.

      Create and Use a Picture Library in SharePoint

      A Picture Library in Microsoft SharePoint is a specialized type of library designed specifically for storing and viewing images. Unlike a standard document library, it provides a more visual, gallery-style experience, making it ideal for photos, graphics, or any image-heavy content.

      In this section, you’ll learn how to create a picture library, upload images, browse them easily, and optionally add the library to your site navigation for quick access.

      Video Explanation


      What Is a Picture Library?

      A Picture Library is optimized for images and offers features such as:

      It’s best used when the primary purpose of the library is to view and browse images, not documents.


      Steps to Create a Picture Library

      1. Go to Site Contents
      2. Create a New App
      3. Switch to Classic Experience
      4. Select Picture Library
      5. Name the Library

      Your new picture library is now created and listed under Site Contents.


      Upload and View Images

      1. Open the picture library from Site Contents.
      2. Click Upload and select image files from your computer.
      3. After uploading, images appear as tiles by default.

      Viewing images:

      This gallery-style navigation is what makes picture libraries different from standard document libraries.


      Change the Display Layout

      You can change how images are displayed based on your preference:

      These options let you balance visual appeal with organization.


      (Optional) Add the Picture Library to Site Navigation

      To make the picture library easy to access from anywhere on the site:

      1. Open the picture library and copy its URL (up to the library name, such as /Cars).
      2. Go to the left navigation menu.
      3. Click Edit at the bottom.
      4. Click the + (plus) icon where you want the link.
      5. Paste the URL and enter a display name (for example, Cars).
      6. Click OK, then Save.

      The picture library will now appear in the site navigation.


      When to Use a Picture Library

      A picture library is a great choice when:

      By using a picture library, you give users a clean, visual way to manage and explore images directly within SharePoint.

      A Quick Guide to SharePoint Library Settings

      In Microsoft SharePoint, document and picture libraries are more than just places to store files. Each library comes with a comprehensive Library Settings area that allows you to control behavior, structure, permissions, and user experience. Understanding these settings helps you design libraries that are secure, well-organized, and easy to use.

      This section provides a clear overview of how to access library settings and what each major area is used for.

      Video Explanation


      How to Access Library Settings

      Library settings are only available inside a library—they won’t appear if you’re on the site homepage.

      Steps to access:

      1. Open the document or picture library you want to manage (for example, Documents, Expenses, or Pictures).
      2. Click the Gear icon in the top-right corner.
      3. Select Library settings.
      4. On the settings page, click More library settings to open the full classic settings view.

      This classic page is where most configuration options live.


      General Settings

      General settings control the basic identity and behavior of the library.

      Common options include:

      Versioning is especially important for collaboration, auditing, and rollback.


      Advanced Settings

      Advanced settings define how the library behaves behind the scenes.

      Key options include:

      Most advanced settings can remain at their defaults unless you have specific requirements.


      Validation and Form Settings

      These settings help control how users enter data.

      These options are useful when accuracy and consistency are critical.


      Permissions and Management

      This section controls access and lifecycle management.

      Includes:

      Library-level permissions are helpful when access needs differ from the rest of the site.


      Column and View Settings

      This area controls how metadata and views work.

      You can:

      This is where libraries become structured, searchable, and user-friendly.


      Final Notes

      Library settings give you full control over how files are stored, accessed, and managed. Whether you’re building an HR document library, a finance repository, or a team knowledge base, properly configuring these settings ensures a secure, organized, and efficient SharePoint environment.

    9. 1 – Creating and Familiarizing A Simple SharePoint Site

      Table of Contents

      1. Accessing SharePoint and Creating a Site
      2. Familiarizing Yourself with the SharePoint Site Interface
    10. Accessing SharePoint and Creating a Site

      Microsoft 365 includes powerful tools for collaboration, and SharePoint is one of the most useful among them. It allows teams to share documents, organize information, and create dedicated spaces for projects or departments.

      In this section, you’ll learn how to log in to your Microsoft 365 portal and create a new SharePoint site. Even if you’re completely new, the process is simple and guided.

      Video Explanation


      Logging in to the Office Portal

      Before using SharePoint, you first need to sign in to your Microsoft 365 account. Once logged in, you can access all available apps from one place.

      Steps to log in:

      1. Open your browser and go to office.microsoft.com.
      2. Enter your work or school email and password.
      3. After signing in, you may be redirected to a different Microsoft 365 URL — this is normal.
      4. Use your organization account when prompted.
      5. After login, you’ll see the Microsoft 365 app launcher with apps like Outlook, Word, Teams, and SharePoint.
      6. Click SharePoint to open it.

      Key Point: SharePoint is included with Microsoft 365, so one login gives you access to all apps.


      Creating a SharePoint Site

      A SharePoint site acts as a central hub where your team can store files, share updates, and collaborate.

      Steps to create a site:

      1. On the SharePoint home page, click Create site (top-left corner).
      2. Choose Team site when asked for the site type.
      3. Select the default team template and click Use template.

      Configure your site:

      1. Click Create site.
      2. You can skip adding members for now and add them later.

      Key Point: A Private site keeps access limited to invited members, which is ideal for most teams and projects.


      Familiarizing Yourself with the SharePoint Site Interface

      A SharePoint site in Microsoft 365 is designed to make navigation and collaboration simple. Once you understand the layout, it becomes much easier to find information, manage files, and move between different areas of your site.

      In this section, we’ll walk through the main parts of a SharePoint site interface so you know what each area does and how it helps with daily work.


      Top Bar and Global Navigation

      At the very top of a SharePoint site, you’ll find tools that help you search and navigate across sites.

      Key areas:


      Site Home Page

      The site home page is made up of web parts, which you can think of as widgets that display different types of content.

      Common web parts include:

      1. News – Displays announcements and updates
      2. Quick Links – Provides shortcuts to important resources
      3. Documents – Shows recent or pinned documents
      4. Activity – Highlights recent actions on the site

      The home page acts like a dashboard where important information is grouped in one place.


      Site Apps and Left Navigation

      A SharePoint site is essentially a collection of apps (also called site contents). Each app serves a specific purpose and has its own screen and menu.

      The left-side navigation menu helps you move between these apps.

      Common apps include:

      To explore available content types, you can click New inside Site Contents and see what can be created.


      How Apps Work

      Each app in SharePoint has:

      For example, the Home page itself is an app with a layout and menu options.

      Understanding that a SharePoint site is built from apps makes it easier to manage and customize your site as your needs grow.


      Once you’re familiar with these areas, navigating SharePoint becomes much more intuitive, helping you find information faster and work more efficiently.