Download as pdf or txt
Download as pdf or txt
You are on page 1of 89

How To Make The Best Use Of Live Sessions

• Please log in 10 mins before the class starts and check your internet connection to avoid any network issues during the LIVE
session

• All participants will be on mute, by default, to avoid any background noise. However, you will be unmuted by instructor if
required. Please use the “Questions” tab on your webinar tool to interact with the instructor at any point during the class

• Feel free to ask and answer questions to make your learning interactive. Instructor will address your queries at the end of on-
going topic

• We have dedicated support team to assist all your queries. You can reach us anytime at: support@edureka.co

• Your feedback is very much appreciated. Please share feedback after each class, which will help us enhance your learning
experience

Copyright © edureka and/or its affiliates. All rights reserved.


Microsoft Azure Administrator
Certification (AZ-104)
COURSE OUTLINE
MODULE 03

01. Managing Azure Subscriptions And 11. Implementing And Managing Hybrid
Resource Groups Identities

02. Azure Virtual Networks And Network


10. Manage Azure Active Directory (AD)
Security

03. Overview Of Azure Virtual Machines 09. Monitoring And Access Management
For Cloud Resources

08. Integrate On-premises Network With


04. Overview Of Azure Storage Services
Azure Virtual Network

07. Network Traffic Distribution And


05. Secure And Manage Azure Storage Connectivity

06. Configure Virtual Machines For High


Availability
Recap

Copyright © edureka and/or its affiliates. All rights reserved.


Module 3 – Overview Of Azure Virtual
Machines

Copyright © edureka and/or its affiliates. All rights reserved.


Topics
Following are the topics covered in this module:

▪ Azure Virtual Machines ▪ Create a Managed Image of a Generalized VM


▪ Azure VM Design Considerations ▪ Create an Image from VM Snapshots
▪ Creating an Azure Virtual Machine ▪ Creating a Linux Virtual Machine
▪ Azure Resource Manager VM ▪ Virtual Machine Extensions
▪ Introduction to ARM Templates ▪ Configuration Management using PowerShell DSC
▪ Create a Custom Image of Azure VM ▪ Run Custom Scripts using Custom Script Extension

Copyright © edureka and/or its affiliates. All rights reserved.


Objectives
After completing this module, you should be able to:

▪ Explain VM use cases and general planning considerations

▪ Create Windows VMs in the Azure Portal, with Azure


PowerShell, or using ARM Templates

▪ Deploy Custom Images

▪ Connect to Linux VMs

▪ Automate configuration management by using PowerShell


Desired State Configuration (DSC) and Custom Script
Extension

Copyright © edureka and/or its affiliates. All rights reserved.


Azure Virtual Machines

Copyright © edureka and/or its affiliates. All rights reserved.


Overview Of Azure Virtual Machines
1 3
Azure VM is an on-demand, It is maintained by configuring,
scalable computing patching, and installing the
resources that Azure offers software that runs on it

2 4
It provides flexibility of
Azure VM offers a variety of VM
virtualization without having to
Virtual Machine sizes and compatibility with
buy and maintain the physical
Hyper-V fixed-size VHDs
hardware that runs it

Copyright © edureka and/or its affiliates. All rights reserved.


Different Purposes Of Azure VMs

Azure VMs offer a quick and


Virtual machines in an Azure
easy way to create a computer
virtual network can easily be
with specific configurations
connected to your organization’s
required to code and test an
network
application
Use of Azure VMs for your
application can be economically
viable (pay for extra VMs when
you need them and shut them
down when you don’t)

Copyright © edureka and/or its affiliates. All rights reserved.


Azure VM Design Considerations

Copyright © edureka and/or its affiliates. All rights reserved.


Azure VM Design Considerations
These are the important design aspects of a VM before you build out an application infrastructure in Azure:

Location where the resources are stored

Names of your application resources Size of the VM and Disk Types

Related resources that the VM needs Operating system that the VM runs

Maximum number of VMs that can be created

Copyright © edureka and/or its affiliates. All rights reserved.


Different VM Sizes And Use Case Domains
Type Sizes Description Use case

DSv2, Dv2, DS, D, Av2, A0- Development of test servers code repositories and most
General purpose Balanced CPU-to-memory ratio
7 applications

Suitable for scenarios like batch processing, web servers,


Compute optimized Fs, F High CPU-to-memory ratio
analytics and gaming

Large SQL and NoSQL databases, ERP, SAP, data warehousing


Memory optimized GS, G, DSv2, DS High memory-to-core ratio
solutions and enterprise-grade applications

For Big data and NoSQL databases such as Cassandra,


Storage optimized Ls High disk throughput and IO MongoDB, Cloudera and Redis and Data warehousing
applications, large transactional databases

Specialized virtual machines available with single


GPU NV, NC Graphics rendering, video editing, remote visualization
or multiple GPUs

Our fastest and most powerful CPU virtual


High performance Batch processing, analytics, molecular modeling and fluid
H, A8-11 machines with optional high-throughput
compute dynamics
network interfaces (RDMA)

Copyright © edureka and/or its affiliates. All rights reserved.


VM Disk Types
Azure Premium Disk Azure Standard Disk

Disk Type Solid State Drives (SSD) Hard Disk Drives (HDD)

SSD-based high-performance, low-latency disk support for


Overview VMs running IO-intensive workloads or hosting mission HDD-based cost effective disk support for Dev/Test VM scenarios
critical production environment

Dev/Test, non-critical,
Scenario Production and performance sensitive workloads
Infrequent access

Unmanaged Disks: 1 GB – 1 TB
Managed Disks:
P10: 128 GB S4: 32 GB
Disk Size P20: 512 GB S6: 64 GB
P30: 1024 GB S10: 128 GB
S20: 512 GB
S30: 1024 GB

Max Throughput per Disk 200 MB/s 60 MB/s

Max IOPS per Disk 5000 IOPS 500 IOPS

Copyright © edureka and/or its affiliates. All rights reserved.


Creating An Azure Virtual Machine

Copyright © edureka and/or its affiliates. All rights reserved.


Resources Used To Setup A VM In Azure
Below diagram shows which are the resources used to setup a Virtual Machine in Azure :

Copyright © edureka and/or its affiliates. All rights reserved.


Methods To Create An Azure VM
You have several methods for creating your Virtual Machine depending on the environment you are in:

Method Description

Azure Portal Create a Windows VM using the portal

Templates Create a Windows VM with a Resource Manager template

Azure PowerShell Create a Windows VM using PowerShell

Client SDKs Deploy Azure Resources using C#

REST APIs Create or update a VM

Copyright © edureka and/or its affiliates. All rights reserved.


Azure Portal – Choosing Deployment Model
Once you login to the Azure portal, to start creating any
resources, Select the Resource Manager as shown in the
example:

Classic Model

Azure Resource
Manager

Deployment Models Available in Azure

Copyright © edureka and/or its affiliates. All rights reserved.


Demo 1: Create An Azure Virtual
Machine Using Portal

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM
1. Choose Create a resource > in the search box, search for Windows Server 2016 Datacenter

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM (Contd…)
2. Select Windows Server 2016 Datacenter > click on Create

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM (Contd…)
3. Under Project Details, choose the
desired subscription and the resource
group, or Create new

4. Under Instance Details, provide a VM


name, region and specify the size of
disk (or leave at default)

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM (Contd…)
5. Under Administrator Account, provide a
username, and a password that meets the
defined complexity requirements

6. Under Inbound port rules, choose Allow


selected ports and then select ports from
the drop-down list

7. Leave the remaining defaults and then


select the Review + create button at the
bottom of the page

Copyright © edureka and/or its affiliates. All rights reserved.


Connect To A VM
8. Click the Connect button on the virtual machine properties page

Copyright © edureka and/or its affiliates. All rights reserved.


Connect To A VM (Contd…)
9. In the Connect to virtual machine page, keep the default options
to connect by DNS name over port 3389 > and click Download
RDP file

Copyright © edureka and/or its affiliates. All rights reserved.


Connect To A VM (Contd…)
10. Open the RDP file and click on Connect

11. Type the username and enter the password you created
for the VM > then click OK to create the connection

Copyright © edureka and/or its affiliates. All rights reserved.


Demo 2: Create An Azure Virtual
Machine Using PowerShell

Note: Refer to Module-3 Demo2 Document on LMS for all the steps in detail

Copyright © edureka and/or its affiliates. All rights reserved.


Azure Resource Manager VM

Copyright © edureka and/or its affiliates. All rights reserved.


ARM – Resource Tier For VM Creation
▪ You already know that the Azure Resource Manager
simplifies the deployment and management of Resource Microsoft .Compute
Provider
resources by providing APIs

Provisions
▪ The API passes requests to the Resource Manager
Resources Virtual Machine
service, which authenticates and authorizes the
requests
Contained In

▪ Resource Manager then routes the requests to the


appropriate resource providers

Resource Group

Copyright © edureka and/or its affiliates. All rights reserved.


Introduction To ARM Templates

Copyright © edureka and/or its affiliates. All rights reserved.


Azure Resource Manager (ARM) Template

What is ARM With Resource Manager, you can create a template (in JSON format) that defines the infrastructure and
template ? configuration of your Azure solution.

Why use ARM By using a template, you can repeatedly deploy your solution throughout its lifecycle and have confidence your
template ? resources are deployed in a consistent state.

When you create a solution from the portal, the solution automatically includes a deployment template. You do
How ARM will
not have to create your template from scratch because you can start with the template for your solution and
be created ?
customize it to meet your specific needs.

You can retrieve a template for an existing resource group by either exporting the current state of the resource
How to use
group, or viewing the template used for a particular deployment and viewing the exported template is a helpful
ARM template ?
way to learn about the template syntax.

Copyright © edureka and/or its affiliates. All rights reserved.


ARM Template Deployment
You can define templates and resource groups on the basis of how you want to manage your solution.
For example:
2. Or if you envision your tiers having separate lifecycles, you can
deploy your three tiers to separate resource groups

1. You can deploy your three tier application through a single


template to a single resource group

Copyright © edureka and/or its affiliates. All rights reserved.


ARM Template Format

Template format:

Copyright © edureka and/or its affiliates. All rights reserved.


Virtual Machines Via ARM Template
▪ Virtual Machines have dependencies such as network interfaces, public IP addresses, and virtual networks
that need to be defined in the ARM template
▪ There are many templates in the Azure gallery that include the VM resource:
https://azure.microsoft.com/en-us/resources/templates/?term=VM

Copyright © edureka and/or its affiliates. All rights reserved.


Demo 3: Create Two Azure Virtual
Machines Using ARM Template

Note: Refer to Module-3 Demo3 Document on LMS for all the steps in detail

Copyright © edureka and/or its affiliates. All rights reserved.


Create A Custom Image Of Azure VM

Copyright © edureka and/or its affiliates. All rights reserved.


Create A Custom Image Of Azure VM
Custom images are like marketplace images, but you create them yourself

They can be used for preloading applications, and bootstrapping other OS configurations

To create an image of a virtual machine, you need to perform the following steps:

Step 1 - Sysprep and generalize VMs


Step 2 - Create a custom image Note
• Generalize command enables you to reuse that image on different VMs as
Step 3 - Create a VM from a custom image
it removes unique info from your OS installations
Step 4 - List all the images in your subscription
• If you create an image from a VM that hasn't been generalized, any VM
Step 5 - Delete an image created from that image won't start

Copyright © edureka and/or its affiliates. All rights reserved.


Step 1 – Sysprep And Generalize VMs
➢ Prepare the VM by generalizing it

➢ Deallocate the VM

➢ Mark the source VM as generalized in Azure

01 Connect to the VM

02 Open the Command Prompt window as administrator and change the directory to %windir%\system32\sysprep

03 Run sysprep.exe

Copyright © edureka and/or its affiliates. All rights reserved.


Step 1 – Sysprep And Generalize VMs (Contd…)
➢ Prepare the VM by generalizing it

➢ Deallocate the VM

➢ Mark the source VM as generalized in Azure

04 In the System Preparation Tool dialog box, select Enter System Out-of-Box Experience (OOBE), and check Generalize

05 In Shutdown Options, select Shutdown and then click OK

06 When Sysprep completes, it shuts down the virtual machine. Do not restart the VM

Copyright © edureka and/or its affiliates. All rights reserved.


Step 1 – Sysprep And Generalize VMs (Contd…)
➢ Prepare the VM by generalising it

➢ Deallocate the VM

➢ Mark the source VM as generalized in Azure

Deallocated the VM using Stop-AzureRmVM

Stop-AzureRmVM -ResourceGroupName myResourceGroup -Name myVM -Force

Copyright © edureka and/or its affiliates. All rights reserved.


Step 1 – Sysprep And Generalize VMs (Contd…)
➢ Prepare the VM by generalising it

➢ Deallocate the VM

➢ Mark the source VM as generalized in Azure

Set the status of the virtual machine to -Generalized using Set-AzureRmVM

Set-AzureRmVM -ResourceGroupName myResourceGroup -Name myVM -Generalized

Copyright © edureka and/or its affiliates. All rights reserved.


Step 2 – Create A Custom Image

Get the Virtual Machine

$vm = Get-AzureRmVM -Name myVM -ResourceGroupName myResourceGroup

Create the image configuration

$image = New-AzureRmImageConfig -Location EastUS -SourceVirtualMachineId $vm.ID

Create the image

New-AzureRmImage -Image $image -ImageName myImage -ResourceGroupName myResourceGroup

Copyright © edureka and/or its affiliates. All rights reserved.


Step 3 – Create A VM from a Custom Image
▪ Creating a VM from a custom image is similar to creating a VM using a Marketplace image
▪ To create a VM from a custom image we use New-AzureRmVm cmdlet
▪ You need to provide the name of the custom image in the same resource group

Example
New-AzureRmVm `
-ResourceGroupName "myResourceGroup" `
-Name "myVMfromImage" `
-ImageName "myImage" `
-Location "East US" `
-VirtualNetworkName "myImageVnet" `
-SubnetName "myImageSubnet" `
-SecurityGroupName "myImageNSG" `
-PublicIpAddressName "myImagePIP" `
-OpenPorts 3389

Copyright © edureka and/or its affiliates. All rights reserved.


Step 4 And 5 – Image Management

List all images by name

$images = Get-AzureRMResource -ResourceType Microsoft.Compute/images


$images.name

Delete an image

Remove-AzureRmImage `
-ImageName myImage `
-ResourceGroupName myResourceGroup

Copyright © edureka and/or its affiliates. All rights reserved.


Create A Managed Image Of A
Generalized VM

Copyright © edureka and/or its affiliates. All rights reserved.


Create A Managed Image On Azure Portal
A managed image resource can be created from a generalized virtual VM that is stored as either a managed disk
or an unmanaged disk in a storage account

The image can then be used to create multiple VMs

In the Virtual machine page for


the VM, on the upper menu,
select Capture

Copyright © edureka and/or its affiliates. All rights reserved.


Create A Managed Image On Azure Portal (Contd…)
The Create Image page appears:

Enter a name that you would


like to use for the image

For Resource group, either


Create new and enter a name,
or select an existing one

If you want the ability to use the


image in any availability zone,
select On for Zone resiliency

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM From A Managed Image

In the Image page for the VM,


on the upper menu,
select Create VM

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM From A Managed Image (Contd…)

Fill in all the fields and then select


the Review + create button at the
bottom of the page to create the VM

Copyright © edureka and/or its affiliates. All rights reserved.


Create An Image From VM Snapshots

Copyright © edureka and/or its affiliates. All rights reserved.


What Are VM Snapshots?

A VM snapshot is a copy of the virtual machine's disk file at a given point in time

Snapshots are used to restore a VM to a particular point in time when a failure


or system error occurs

Any data that was writable on a VM becomes read-only when the snapshot is taken

The snapshot file cannot exceed the size of the original disk file, and it requires
some overhead disk space

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM Snapshot For Managed Disks
1. Go to the Disks section under the Settings blade in your Virtual Machine window

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM Snapshot For Managed Disks (Contd…)
2. Choose an OS disk or create a Data disk to choose

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM Snapshot For Managed Disks (Contd…)
3. Click on Create snapshot

Copyright © edureka and/or its affiliates. All rights reserved.


Create A VM Snapshot For Managed Disks (Contd…)
4. The Create snapshot page
appears:
Enter a name that you would
like to use for the snapshot

For Resource group, either


Create new and enter a name,
or select an existing one

Select an Account type

Click on Create

Copyright © edureka and/or its affiliates. All rights reserved.


Create An Image From A Snapshot Using PowerShell
1. Create some variables 2. Get the snapshot

$rgName = "myResourceGroup"
$snapshot = Get-AzureRmSnapshot `
$location = "EastUS"
–ResourceGroupName $rgName `
$snapshotName = "mySnapshot"
-SnapshotName $snapshotName
$imageName = "myImage"

3. Create the image configuration

$imageConfig = New-AzureRmImageConfig -Location $location


$imageConfig = Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows `
-SnapshotId $snapshot.Id

4. Create the image

New-AzureRmImage -ImageName $imageName -ResourceGroupName $rgName -Image $imageConfig

Copyright © edureka and/or its affiliates. All rights reserved.


Create An Image From A Snapshot Using PowerShell
1. Create some variables 2. Get the snapshot

$rgName = "myResourceGroup"
$snapshot = Get-AzureRmSnapshot `
$location = "EastUS"
–ResourceGroupName $rgName `
$snapshotName = "mySnapshot"
-SnapshotName $snapshotName
$imageName = "myImage"

3. Create the image configuration

$imageConfig = New-AzureRmImageConfig -Location $location


$imageConfig = Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows `
-SnapshotId $snapshot.Id

4. Create the image

New-AzureRmImage -ImageName $imageName -ResourceGroupName $rgName -Image $imageConfig

Copyright © edureka and/or its affiliates. All rights reserved.


Create An Image From A Snapshot Using PowerShell
1. Create some variables 2. Get the snapshot

$rgName = "myResourceGroup"
$snapshot = Get-AzureRmSnapshot `
$location = "EastUS"
–ResourceGroupName $rgName `
$snapshotName = "mySnapshot"
-SnapshotName $snapshotName
$imageName = "myImage"

3. Create the image configuration

$imageConfig = New-AzureRmImageConfig -Location $location


$imageConfig = Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows `
-SnapshotId $snapshot.Id

4. Create the image

New-AzureRmImage -ImageName $imageName -ResourceGroupName $rgName -Image $imageConfig

Copyright © edureka and/or its affiliates. All rights reserved.


Create An Image From A Snapshot Using PowerShell
1. Create some variables 2. Get the snapshot

$rgName = "myResourceGroup"
$snapshot = Get-AzureRmSnapshot `
$location = "EastUS"
–ResourceGroupName $rgName `
$snapshotName = "mySnapshot"
-SnapshotName $snapshotName
$imageName = "myImage"

3. Create the image configuration

$imageConfig = New-AzureRmImageConfig -Location $location


$imageConfig = Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows `
-SnapshotId $snapshot.Id

4. Create the image

New-AzureRmImage -ImageName $imageName -ResourceGroupName $rgName -Image $imageConfig

Copyright © edureka and/or its affiliates. All rights reserved.


Creating A Linux Virtual Machine

Copyright © edureka and/or its affiliates. All rights reserved.


Linux Virtual Machines
Azure Linux Virtual Machines provides on-demand, high-scale, secure, virtualized
infrastructure using Red Hat, Ubuntu, or the Linux distribution of your choice

Unlike Windows and Linux VM creation, for creating a Linux VM you need to specify
an SSH public key for authentication instead of regular Username and Password

When you use an SSH client to connect to your Linux VM, the remote VM tests the
client to make sure it has the private key, and then grants access to the VM

Copyright © edureka and/or its affiliates. All rights reserved.


SSH Key Pair
You need an SSH key pair to automate logins, single sign-on, and authenticate hosts.

The public key is placed on your Linux VM

The private key remains on your local


system and should be confidential

Copyright © edureka and/or its affiliates. All rights reserved.


Create An SSH Key Pair
If you have an existing SSH key pair, these steps can be skipped

From a Bash shell, run ssh-keygen -t rsa -b 2048


1 command and follow the on-screen directions

The command output includes the file name of


2 the public key file

Copy the contents of the public key file to the


3 clipboard

Copyright © edureka and/or its affiliates. All rights reserved.


Create An SSH Key Pair
▪ You can also use an SSH keygen, a tool for creating new
authentication key pairs for SSH
▪ PuTTYgen is an SSH keygen tool you can use on
Windows to generate key pairs, click on below links to
get it:

- For Windows: https://www.ssh.com/ssh/putty/windows/puttygen


- For Linux: https://www.ssh.com/ssh/putty/linux/puttygen

Copyright © edureka and/or its affiliates. All rights reserved.


Demo 4: Create A Linux VM
On Azure Portal Using PuTTyGen

Note: Refer to Module-3 Demo4 Document on LMS for all the steps in detail

Copyright © edureka and/or its affiliates. All rights reserved.


Demo 5: Create A Linux VM
Using PowerShell

Note: Refer to Module-3 Demo5 Document on LMS for all the steps in detail

Copyright © edureka and/or its affiliates. All rights reserved.


Virtual Machine Extensions

Copyright © edureka and/or its affiliates. All rights reserved.


What Are VM Extensions?
VM extensions are software components that extend VM functionality
and simplify various VM management operations

The Azure VM Agent and associated extensions are part of


Microsoft Azure infrastructure services

They give your VM additional capabilities through post deployment


configuration and automated tasks

To interact with the Azure VM extension, you must use either the
Azure portal or the Azure PowerShell SDK

Copyright © edureka and/or its affiliates. All rights reserved.


Why Are VM Extensions Required?
Following tasks can be accomplished using extensions:

Deploy and manage configurations

The PowerShell Desired State Configuration (DSC) Extension helps


you set up DSC on a VM to manage configurations and environments

Run custom scripts

The Custom Script Extension helps you configure workloads on the


VM by running your script when the VM is provisioned

Collect diagnostics data

The Azure Diagnostics Extension helps you configure the VM to


collect data to monitor the health of your application

Copyright © edureka and/or its affiliates. All rights reserved.


Configuration Management Using
PowerShell DSC

Copyright © edureka and/or its affiliates. All rights reserved.


What Is Configuration Management?
Configuration Management is an automated method for maintaining computer
systems and software in a known, consistent state

▪ Configuration Management (CM) processes system changes systematically to update the


system while maintaining its integrity

▪ Configuration can be performed using tools and extensions on cloud, such as:
– PowerShell DSC
– Custom Script Extension
– Azure Automation
– Puppet
– Chef, etc.

Copyright © edureka and/or its affiliates. All rights reserved.


What Is PowerShell DSC Extension?
DSC is a management platform in Windows PowerShell that enables deploying and managing
configuration data for software services

DSC provides a set of Windows PowerShell language extensions, cmdlets, and resources that
can be used to declaratively specify your software environment configuration

It also provides a means to maintain and manage existing configurations


(Configuration as a Service)

Copyright © edureka and/or its affiliates. All rights reserved.


Configuration Management Using PowerShell DSC
Write the Configuration
01

02 Publish the Configuration Script into User Storage

>_ 03 Set the VM to Run the DSC Configuration

04 Retrieve the Status of DSC Configuration

05
Check the Implementation

Copyright © edureka and/or its affiliates. All rights reserved.


Publish The Configuration Script To User Storage
Create some variables

$resourceGroup = 'Edu533rg'
$location = 'WestIndia'
$vmName = 'EdurekaDSCvm'
$storageName = 'edudscteststorage'

Publish the config script to user storage

Publish-AzureRmVMDscConfiguration -ConfigurationPath .\iisInstall.ps1 `


-ResourceGroupName $resourceGroup `
-StorageAccountName $storageName -force

Copyright © edureka and/or its affiliates. All rights reserved.


Publish The Configuration Script To User Storage
Example -

The .zip file created by this cmdlet has the .ps1 configuration script at the root of the
archive folder. Resources have the module folder placed in the archive folder

Copyright © edureka and/or its affiliates. All rights reserved.


Set The VM And Retrieve The Status

Set the VM to run the DSC configuration

Set-AzureRmVMDscExtension -Version '2.76' -ResourceGroupName $resourceGroup `


-VMName $vmName -ArchiveStorageAccountName $storageName `
-ArchiveBlobName 'iisInstall.ps1.zip' -AutoUpdate $true `
-ConfigurationName 'IISInstall'

Injects the settings needed by the PowerShell DSC


extension into a VM configuration object

Copyright © edureka and/or its affiliates. All rights reserved.


Set The VM And Retrieve The Status
Example -

Copyright © edureka and/or its affiliates. All rights reserved.


Retrieve The Status Of DSC Configuration
Retrieve the status of DSC configuration

Get-AzureRmVMDscExtensionStatus -ResourceGroupName $resourceGroup -VMName $vmName

Copyright © edureka and/or its affiliates. All rights reserved.


Check The Implementation
▪ Once the implementation is succeeded, you can check the same logging on to the DSC configured VM

Copyright © edureka and/or its affiliates. All rights reserved.


Check The Implementation
▪ In the DSC configured VM, open the browser and check the localhost if IIS has been installed

Copyright © edureka and/or its affiliates. All rights reserved.


Run Custom Scripts Using
Custom Script Extension

Copyright © edureka and/or its affiliates. All rights reserved.


Custom Script Extension For Windows

The Custom Script Extension downloads and executes scripts on Azure VMs

Useful for post deployment configuration, software installation, or any other configuration / management task

Scripts can be downloaded from Azure Storage or GitHub, or provided to the Azure portal at extension run time

Integrates with ARM templates, and can be run using the Azure CLI, PowerShell, Portal, or Azure VM REST API

Copyright © edureka and/or its affiliates. All rights reserved.


Difference Between DSC And Custom Script Extensions

PowerShell Desired State


Custom Script Extension:
Configuration (DSC):

Publish-AzureRmVMDscConfiguration –
Takes in a configuration file. Set-AzureRmVMCustomScriptExtension –
Scans it for dependent DSC resources. Creates an Extension which runs a Configuration
Creates a .zip file containing the configuration and Script present in a User Storage and Adds it directly to
DSC resources. a specified VM in the cmdlet.
Publishes it to an Azure Blob storage.

Set-AzureRmVMDscExtension –
Injects the settings needed by the PowerShell DSC
extension into a VM configuration object.

Copyright © edureka and/or its affiliates. All rights reserved.


Custom Script Extension For Windows – Prerequisites

The Custom Script Extension for Windows can be run against Windows 10 Client,
Operating System
Windows Server 2008 R2, 2012, 2012 R2, and 2016 releases

The script needs to be stored in Azure Blob storage, or any other location accessible
Script Location
through a valid URL

The Custom Script Extension for Windows requires that the target virtual machine is
Internet Connectivity
connected to the internet

Copyright © edureka and/or its affiliates. All rights reserved.


The Set-AzureRmVMCustomScriptExtension Command
The typical cmdlet used to set a Custom Script Extension to a VM is shown below:

Template format:

Copyright © edureka and/or its affiliates. All rights reserved.


Summary

Copyright © edureka and/or its affiliates. All rights reserved.


Copyright © edureka and/or its affiliates. All rights reserved.
Copyright © edureka and/or its affiliates. All rights reserved.
Copyright © edureka and/or its affiliates. All rights reserved.

You might also like