Exercise – Set up a DSC and configure a desired state – Training | Microsoft Learn

What do we make:

1 Create a VM
PS C:\giti2022\azure-arm-104\3_compute\vm_simple_win> .\deploy_vm.ps1
Open your VM’s port 80 for web traffic:This site can’t be reached

2 Create an Azure Automation account
3 Portal, select the Automation Azure service published by Microsoft


4 Create a DSC configuration script

Run it from local and store it on automation account
PS C:\giti2022\amqp-automation> .\MyFirstPs1Deploy.ps1

# MyFirstDsc.ps1

Configuration MyFirstDsc {
    Node "localhost" {
      WindowsFeature MyFeatureInstance {
        Ensure = 'Present'
        Name = 'Web-Server'
      }
    }
  }

# MyFirstPs1Deploy.ps1
Import-AzAutomationDscConfiguration `
    -Published `
    -ResourceGroupName testit2-rg `
    -SourcePath "MyFirstDsc.ps1" `
    -Force `
    -AutomationAccountName testitautomationacc

# First Connect-AzAccount

PS C:\giti2022\amqp-automation> .\MyFirstPs1Deploy.ps1

# output

ResourceGroupName     : testit2-rg
AutomationAccountName : testitautomationacc
Location              : westeurope
State                 : Published
Name                  : MyFirstDsc
Tags                  : {}
CreationTime          : 15.11.2022 17:30:28 +01:00
LastModifiedTime      : 15.11.2022 17:30:28 +01:00
Description           :
Parameters            : {}
LogVerbose            : False

Compile the DSC script

In the command bar, select Compile.

In the Compile DSC Configuration dialog box, select Yes.

Check your notifications (notifications icon is in the global controls in the page header). Wait for the compilation job to show Status of Completed, which may take several minutes.

Here it is already compiled

Compiled

Register the VM with your Azure Automation account
On the State configuration (DSC) pane for [your-automation-account-name], select the Nodes tab. In the command bar, select Add. The Virtual Machines pane for your automation account appears.

Wait until the VM is connected. This process might take a few minutes. When your myVM has connected, in the breadcrumb path in the top left of the portal, select your account automation to close the Registration and Virtual Machines pane. The State configuration (DSC) pane for your automation account appears.

In the command bar, select Refresh.

Verify that the node myVM appears in the list and that its status is Compliant.

Verify that IIS is installed on the VM
In your web browser, go to http://[public-ip], where, [public-ip] is the public IP address that you recorded earlier in this exercise.

You should see the default IIS webpage.

add telnet

#MyFirstDcs

Configuration MyFirstDsc {
    Node "localhost" {
      WindowsFeature MyFeatureInstance {
        Ensure = 'Present'
        Name = 'Web-Server'
      }
      WindowsFeature Telnet-Client
        {
            Ensure = "Present"
            Name = "Telnet-Client"     
        }
    }
  }

Run it from local and compile it again and store it on automation account

and then we wait 15 min (this was what we used initial for the configuration)

Refresh Frequency30
Configuration Mode Frequency15
Configuration ModeApplyAndMonitor
Allow Module OverrideSelect checkbox
Reboot Node if NeededSelect checkbox
Action after RebootContinueConfiguration

and telnet is ready

And there is something new that contains this function

Azure Automanage | Microsoft Learn

Azure Automanage for Windows Server | Microsoft Learn

Azure Automanage for Windows Server | Microsoft Learn