Azure Classroomnotes 09/Jul/2023

Azure Networking Workshop

Goal

  • Lets try to create a multi – region active passive network with application deployed
  • For all the network configuration, lets use Azure CLI
  • For vm and traffic manager we will be using Azure portal
  • Ideally every thing should be created from infra provisioning tools like ARM Templates, Terraform or Azure Bicep

Azure CLI

  • Refer Here for installation
  • Azure cli helps us in interacting with azure over CLI
  • Azure CLI will have commands in the following form
az section [sub-section] action [--arg1 value1] .. [--argn valuen]
  • Azure CLI Docs Refer Here
  • Find a commands to
    • create a resource group
    • Create a vnet in that resource group
    • Create a subnet in vnet created above
    • Create a load balancer
  • Ensure Azure CLI Tools Extension is installed in Visual Studio Code
  • Azure CLI to create a resource group and vnet with one subnet
# Create a resource group
az group create `
    --location 'eastus' `
    --name 'workshop' `
    --tags Purpose=learning Environment=Dev

# Create a virtual network with cidr range 10.0.0.0/16 with name 
# ntier-primary with location east us
az network vnet create `
    --location 'eastus' `
    --resource-group 'workshop' `
    --address-prefixes '10.0.0.0/16' `
    --name 'ntier-primary'


# Add one subnet to ntier-primary called as app subnet with 
# cidr range 10.0.0.0/24
az network vnet subnet create `
    --name 'app' `
    --resource-group 'workshop' `
    --vnet-name 'ntier-primary' `
    --address-prefixes '10.0.0.0/24'
  • Lets try to create something reusable Refer Here for the changes done to make the script reusable
#!/bin/bash

resource_group_name='workshop1'
primary_vnet_name='ntier-primary'
secondary_vnet_name='ntier-secondary'
primary_location='eastus'
secondary_location='westus'
subnet_name='app'
primary_vnet_cidr='10.0.0.0/16'
secondary_vnet_cidr='10.1.0.0/16'
primary_subnet_cidr='10.0.0.0/24'
secondary_subnet_cidr='10.1.0.0/24'

function create_network_with_subnet() {
    location=$1
    resource_group_name=$2
    vnet_cidr=$3
    vnet_name=$4
    subnet_name=$5
    subnet_cidr=$6

    az network vnet create \
        --location $location \
        --resource-group $resource_group_name \
        --address-prefixes $vnet_cidr \
        --name $vnet_name

    az network vnet subnet create \
        --name $subnet_name \
        --resource-group $resource_group_name \
        --vnet-name $vnet_name \
        --address-prefixes $subnet_cidr

}

# Creates a resource group if it does not exist

if [ $(az group exists --name $resource_group_name) = false ]; then 
   az group create \
    --name $resource_group_name \
    --location $primary_location

    # create a virtual network in primary region
    create_network_with_subnet $primary_location $resource_group_name $primary_vnet_cidr $primary_vnet_name $subnet_name $primary_subnet_cidr

    # Create a virtual network in secondary region
    create_network_with_subnet $secondary_location $resource_group_name $secondary_vnet_cidr $secondary_vnet_name $subnet_name $secondary_subnet_cidr

else
   echo "$resource_group_name already exists"
fi

  • Now lets create two vms in primary region and install any application spring petclinic
  • and repeat the same in secondary region
  • Note spring petclinic installation on ubuntu
sudo apt upate
sudo apt install openjdk-11-jdk -y
cd /tmp
wget https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/spring-petclinic-2.4.2.jar
java -jar /tmp/spring-petclinic-2.4.2.jar

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%