Module 5
Module 5
Learning objectives
After completing this module, you’ll be able to:
You can even create or use an already created image to rapidly provision
VMs. You can create and provision a VM in minutes when you select a
preconfigured VM image. An image is a template used to create a VM and
may already include an OS and other software, like development tools or
web hosting environments.
Instead, with virtual machine scale sets, Azure automates most of that work.
Scale sets allow you to centrally manage, configure, and update a large
number of VMs in minutes. The number of VM instances can automatically
increase or decrease in response to demand, or you can set it to scale
based on a defined schedule. Virtual machine scale sets also automatically
deploy a load balancer to make sure that your resources are being used
efficiently. With virtual machine scale sets, you can build large-scale
services for areas such as compute, big data, and container workloads.
Update domain: The update domain groups VMs that can be rebooted
at the same time. This setup allows you to apply updates while knowing
that only one update domain grouping is offline at a time. All of the
machines in one update domain update. An update group going through
the update process is given a 30-minute time to recover before
maintenance on the next update domain starts.
Fault domain: The fault domain groups your VMs by common power
source and network switch. By default, an availability set splits your VMs
across up to three fault domains. This helps protect against a physical
power or networking failure by having VMs in different fault domains
(thus being connected to different power and networking resources).
Best of all, there’s no additional cost for configuring an availability set. You
only pay for the VM instances you create.
During testing and development. VMs provide a quick and easy way
to create different OS and application configurations. Test and
development personnel can then easily delete the VMs when they no
longer need them.
When running applications in the cloud. The ability to run certain
applications in the public cloud as opposed to creating a traditional
infrastructure to run them can provide substantial economic benefits. For
example, an application might need to handle fluctuations in demand.
Shutting down VMs when you don't need them or quickly starting them
up to meet a sudden increase in demand means you pay only for the
resources you use.
When extending your datacenter to the cloud: An organization can
extend the capabilities of its own on-premises network by creating a
virtual network in Azure and adding VMs to that virtual network.
Applications like SharePoint can then run on an Azure VM instead of
running locally. This arrangement makes it easier or less expensive to
deploy than in an on-premises environment.
During disaster recovery: As with running certain types of applications
in the cloud and extending an on-premises network to the cloud, you can
get significant cost savings by using an IaaS-based approach to disaster
recovery. If a primary datacenter fails, you can create VMs running on
Azure to run your critical applications and then shut them down when the
primary datacenter becomes operational again.
VM Resources
When you provision a VM, you’ll also have the chance to pick the resources
that are associated with that VM, including:
You could use the Azure portal, the Azure CLI, Azure PowerShell, or an
Azure Resource Manager (ARM) template.
az vm create \
--resource-group "[sandbox resource group name]" \
--name my-vm \
--public-ip-sku Standard \
--image Ubuntu2204 \
--admin-username azureuser \
--generate-ssh-keys
Your VM takes a few moments to come up. You named the VM my-vm.
You use this name to refer to the VM in later steps.
2. Run the following az vm extension set command to configure Nginx
on your VM:
az vm extension set \
--resource-group "[sandbox resource group name]" \
--vm-name my-vm \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--version 2.1 \
--settings '{"fileUris":
["https://raw.githubusercontent.com/MicrosoftDocs/mslearn-
welcome-to-azure/master/configure-nginx.sh"]}' \
--protected-settings '{"commandToExecute": "./configure-
nginx.sh"}'
This command uses the Custom Script Extension to run a Bash script on
your VM. The script is stored on GitHub. While the command runs, you
can choose to examine the Bash script from a separate browser tab. To
summarize, the script:
1. Runs apt-get update to download the latest package information
from the internet. This step helps ensure that the next command
can locate the latest version of the Nginx package.
2. Installs Nginx.
3. Sets the home page, /var/www/html/index.html, to print a welcome
message that includes your VM's host name.
04-Describe Azure virtual desktop
Another type of virtual machine is the Azure Virtual Desktop. Azure Virtual
Desktop is a desktop and application virtualization service that runs on the
cloud. It enables you to use a cloud-hosted version of Windows from any
location. Azure Virtual Desktop works across devices and operating
systems, and works with apps that you can use to access remote desktops
or most modern browsers.
Enhance security
Azure Virtual Desktop provides centralized security management for users'
desktops with Microsoft Entra ID. You can enable multifactor authentication
to secure user sign-ins. You can also secure access to data by assigning
granular role-based access controls (RBACs) to users.
With Azure Virtual Desktop, the data and apps are separated from the local
hardware. The actual desktop and apps are running in the cloud, meaning
the risk of confidential data being left on a personal device is reduced.
Additionally, user sessions are isolated in both single and multi-session
environments.
Imagine your website back-end reaches capacity, but the front end and
storage aren't stressed. With containers, you could scale the back-end
separately to improve performance. If something necessitated such a
change, you could also choose to change the storage service or modify the
front end without impacting any of the other components.
06-Describe application hosting options
If you need to host your application on Azure, you might initially turn to a
virtual machine (VM) or containers. Both VMs and containers provide
excellent hosting solutions. VMs give you maximum control of the hosting
environment and allow you to configure it exactly how you want. VMs also
may be the most familiar hosting method if you’re new to the cloud.
Containers, with the ability to isolate and individually manage different
aspects of the hosting solution, can also be a robust and compelling option.
There are other hosting options that you can use with Azure, including Azure
App Service.
Azure App Service is a robust hosting option that you can use to host your
apps in Azure. Azure App Service lets you focus on building and maintaining
your app, and Azure focuses on keeping the environment up and running.
Web apps
API apps
WebJobs
Mobile apps
App Service handles most of the infrastructure decisions you deal with in
hosting web-accessible apps:
All of these app styles are hosted in the same infrastructure and share these
benefits. This flexibility makes App Service the ideal choice to host web-
oriented applications.
Web apps
App Service includes full support for hosting web apps by using ASP.NET,
ASP.NET Core, Java, Ruby, Node.js, PHP, or Python. You can choose either
Windows or Linux as the host operating system.
API apps
Much like hosting a website, you can build REST-based web APIs by using
your choice of language and framework. You get full Swagger support and
the ability to package and publish your API in Azure Marketplace. The
produced apps can be consumed from any HTTP- or HTTPS-based client.
WebJobs
You can use the WebJobs feature to run a program (.exe, Java, PHP,
Python, or Node.js) or script (.cmd, .bat, PowerShell, or Bash) in the same
context as a web app, API app, or mobile app. They can be scheduled or run
by a trigger. WebJobs are often used to run background tasks as part of
your application logic.
Mobile apps
Use the Mobile Apps feature of App Service to quickly build a back end for
iOS and Android apps. With just a few actions in the Azure portal, you can:
On the mobile app side, there's SDK support for native iOS and Android,
Xamarin, and React native apps.
07-Describe Azure virtual networking
Azure virtual networks and virtual subnets enable Azure resources, such as
VMs, web apps, and databases, to communicate with each other, with users
on the internet, and with your on-premises client computers. You can think of
an Azure network as an extension of your on-premises network with
resources that link other Azure resources.
For name resolution, you can use the name resolution service built into
Azure. You also can configure the virtual network to use either an internal or
an external DNS server.
Internet communications
You can enable incoming connections from the internet by assigning a public
IP address to an Azure resource, or putting the resource behind a public
load balancer.
Virtual networks can connect not only VMs but other Azure resources,
such as the App Service Environment for Power Apps, Azure Kubernetes
Service, and Azure virtual machine scale sets.
Service endpoints can connect to other Azure resource types, such as
Azure SQL databases and storage accounts. This approach enables you
to link multiple Azure resources to virtual networks to improve security
and provide optimal routing between resources.
Route tables allow you to define rules about how traffic should be
directed. You can create custom route tables that control how packets
are routed between subnets.
Border Gateway Protocol (BGP) works with Azure VPN gateways, Azure
Route Server, or Azure ExpressRoute to propagate on-premises BGP
routes to Azure virtual networks.
Network security groups are Azure resources that can contain multiple
inbound and outbound security rules. You can define these rules to allow
or block traffic, based on factors such as source and destination IP
address, port, and protocol.
Network virtual appliances are specialized VMs that can be compared to
a hardened network appliance. A network virtual appliance carries out a
particular network function, such as running a firewall or performing wide
area network (WAN) optimization.
User-defined routes (UDR) allow you to control the routing tables between
subnets within a virtual network or between virtual networks. This allows for
greater control over network traffic flow.
08-Exercise - Configure network access
In this exercise, you configure the access to the virtual machine (VM) you
created earlier in this module.
To verify the VM you created previously is still running, use the following
command:
az vm list
Right now, the VM you created and installed Nginx on isn't accessible from
the internet. You create a network security group that changes that by
allowing inbound HTTP access on port 80.
IPADDRESS="$(az vm list-ip-addresses \
--resource-group "[sandbox resource group name]" \
--name my-vm \
--query "
[].virtualMachine.network.publicIpAddresses[*].ipAddress"
\
--output tsv)"
This message means that the VM wasn't accessible within the timeout
period.
3. As an optional step, try to access the web server from a browser:
1. Run the following to print your VM's IP address to the console:
echo $IPADDRESS
1. Run the following az network nsg list command to list the network
security groups that are associated with your VM:
my-vmNSG
You see a large block of text in JSON format in the output. In the next
step, you'll run a similar command that makes this output easier to read.
3. Run the az network nsg rule list command a second time. This
time, use the --query argument to retrieve only the name, priority,
affected ports, and access (Allow or Deny) for each rule. The --
output argument formats the output as a table so that it's easy to read.
You see the default rule, default-allow-ssh. This rule allows inbound
connections over port 22 (SSH). SSH (Secure Shell) is a protocol that's
used on Linux to allow administrators to access the system remotely.
The priority of this rule is 1000. Rules are processed in priority order,
with lower numbers processed before higher numbers.
By default, a Linux VM's NSG allows network access only on port 22. This
port enables administrators to access the system. You need to also allow
inbound connections on port 80, which allows access over HTTP.
For learning purposes, here you set the priority to 100. In this case, the
priority doesn't matter. You would need to consider the priority if you had
overlapping port ranges.
2. To verify the configuration, run az network nsg rule list to see the
updated list of rules:
You see both the default-allow-ssh rule and your new rule, allow-http:
Note : After you update the NSG, it may take a few moments before the
updated rules propagate. Retry the next step, with pauses between
attempts, until you get the desired results.
2. As an optional step, refresh your browser tab that points to your web
server. You see the home page:
Nice work. In practice, you can create a standalone network security group
that includes the inbound and outbound network access rules you need. If
you have multiple VMs that serve the same purpose, you can assign that
NSG to each VM at the time you create it. This technique enables you to
control network access to multiple VMs under a single, central set of rules.
Clean up
The sandbox automatically cleans up your resources when you're finished
with this module.
When you're working in your own subscription, it's a good idea at the end of
a project to identify whether you still need the resources you created.
Resources that you leave running can cost you money. You can delete
resources individually or delete the resource group to delete the entire set of
resources.
09-Describe Azure virtual private
networks
A virtual private network (VPN) uses an encrypted tunnel within another
network. VPNs are typically deployed to connect two or more trusted private
networks to one another over an untrusted network (typically the public
internet). Traffic is encrypted while traveling over the untrusted network to
prevent eavesdropping or other attacks. VPNs can enable networks to
safely and securely share sensitive information.
VPN gateways
A VPN gateway is a type of virtual network gateway. Azure VPN Gateway
instances are deployed in a dedicated subnet of the virtual network and
enable the following connectivity:
When setting up a VPN gateway, you must specify the type of VPN - either
policy-based or route-based. The primary distinction between these two
types is how they determine which traffic needs encryption. In Azure,
regardless of the VPN type, the method of authentication employed is a
preshared key.
Use a route-based VPN gateway if you need any of the following types of
connectivity:
High-availability scenarios
If you’re configuring a VPN to keep your information safe, you also want to
be sure that it’s a highly available and fault tolerant VPN configuration.
There are a few ways to maximize the resiliency of your VPN gateway.
Active/standby
By default, VPN gateways are deployed as two instances in an
active/standby configuration, even if you only see one VPN gateway
resource in Azure. When planned maintenance or unplanned disruption
affects the active instance, the standby instance automatically assumes
responsibility for connections without any user intervention. Connections are
interrupted during this failover, but they typically restore within a few
seconds for planned maintenance and within 90 seconds for unplanned
disruptions.
Active/active
With the introduction of support for the BGP routing protocol, you can also
deploy VPN gateways in an active/active configuration. In this configuration,
you assign a unique public IP address to each instance. You then create
separate tunnels from the on-premises device to each IP address. You can
extend the high availability by deploying an additional VPN device on-
premises.
ExpressRoute failover
Another high-availability option is to configure a VPN gateway as a secure
failover path for ExpressRoute connections. ExpressRoute circuits have
resiliency built in. However, they aren't immune to physical problems that
affect the cables delivering connectivity or outages that affect the complete
ExpressRoute location. In high-availability scenarios, where there's risk
associated with an outage of an ExpressRoute circuit, you can also
provision a VPN gateway that uses the internet as an alternative method of
connectivity. In this way, you can ensure there's always a connection to the
virtual networks.
Zone-redundant gateways
In regions that support availability zones, VPN gateways and ExpressRoute
gateways can be deployed in a zone-redundant configuration. This
configuration brings resiliency, scalability, and higher availability to virtual
network gateways. Deploying gateways in Azure availability zones physically
and logically separates gateways within a region while protecting your on-
premises network connectivity to Azure from zone-level failures. These
gateways require different gateway stock keeping units (SKUs) and use
Standard public IP addresses instead of Basic public IP addresses.
10-Describe Azure ExpressRoute
Azure ExpressRoute lets you extend your on-premises networks into the
Microsoft cloud over a private connection, with the help of a connectivity
provider. This connection is called an ExpressRoute Circuit. With
ExpressRoute, you can establish connections to Microsoft cloud services,
such as Microsoft Azure and Microsoft 365. This feature allows you to
connect offices, datacenters, or other facilities to the Microsoft cloud. Each
location would have its own ExpressRoute circuit.
Global connectivity
You can enable ExpressRoute Global Reach to exchange data across your
on-premises sites by connecting your ExpressRoute circuits. For example,
say you had an office in Asia and a datacenter in Europe, both with
ExpressRoute circuits connecting them to the Microsoft network. You could
use ExpressRoute Global Reach to connect those two facilities, allowing
them to communicate without transferring data over the public internet.
Dynamic routing
ExpressRoute uses the BGP. BGP is used to exchange routes between on-
premises networks and resources running in Azure. This protocol enables
dynamic routing between your on-premises network and services running in
the Microsoft cloud.
Built-in redundancy
Each connectivity provider uses redundant devices to ensure that
connections established with Microsoft are highly available. You can
configure multiple circuits to complement this feature.
Any-to-any networks
With any-to-any connectivity, you can integrate your wide area network
(WAN) with Azure by providing connections to your offices and datacenters.
Azure integrates with your WAN connection to provide a connection like you
would have between your datacenter and any branch offices.
Security considerations
With ExpressRoute, your data doesn't travel over the public internet,
reducing the risks associated with internet communications. ExpressRoute
is a private connection from your on-premises infrastructure to your Azure
infrastructure. Even if you have an ExpressRoute connection, DNS queries,
certificate revocation list checking, and Azure Content Delivery Network
requests are still sent over the public internet.
11-Describe Azure DNS
Azure DNS is a hosting service for DNS domains that provides name
resolution by using Microsoft Azure infrastructure. By hosting your domains
in Azure, you can manage your DNS records using the same credentials,
APIs, tools, and billing as your other Azure services.
Security
Azure DNS is based on Azure Resource Manager, which provides features
such as:
Ease of use
Azure DNS can manage DNS records for your Azure services and provide
DNS for your external resources as well. Azure DNS is integrated in the
Azure portal and uses the same credentials, support contract, and billing as
your other Azure services.
Because Azure DNS is running on Azure, it means you can manage your
domains and records with the Azure portal, Azure PowerShell cmdlets, and
the cross-platform Azure CLI. Applications that require automated DNS
management can integrate with the service by using the REST API and
SDKs.
Alias records
Azure DNS also supports alias record sets. You can use an alias record set
to refer to an Azure resource, such as an Azure public IP address, an Azure
Traffic Manager profile, or an Azure Content Delivery Network (CDN)
endpoint. If the IP address of the underlying resource changes, the alias
record set seamlessly updates itself during DNS resolution. The alias record
set points to the service instance, and the service instance is associated
with an IP address.
Important : You can't use Azure DNS to buy a domain name. For an annual
fee, you can buy a domain name by using App Service domains or a third-
party domain name registrar. Once purchased, your domains can be hosted
in Azure DNS for record management.