In my previous blog article, I introduced you to the process involved in registering an on-premises Windows server with Azure Arc so that it can be managed alongside native Azure Virtual Machine using a single control plane. In this blog article, we will focus on how we can deploy the PowerShell Desired State Configuration (DSC) extension to your on-premises Arc servers and have DSC configure settings on them. We will cover the process of adding the DSC extension to your Arc servers via the Azure portal, and how you can upload a DSC configuration from it so that it gets pushed down and applied onto your on-premises servers. To keep things interesting, we will be deploying a DSC configuration which will automatically configure the OS level features, install SQL Server, and install SharePoint 2019 automatically. All this without ever leaving the Azure portal.
Install the PowerShell Desired State – Azure Arc Extension
For the purpose of this demo, I’ve created a brand new Hyper-V Virtual Machine on my host, which is located in my office in Gatineau, Quebec. That VM is a plain-vanilla install of Windows Server 2019 on which I’ve installed the Azure Connected Machine Agent and which I on-boarded onto Azure Arc.
From the Azure Portal, click on the newly on-boarded server. This will open the management screen for that given server. In the left menu, click on Extensions.
On the Extensions screen, click on the Add button.
From the list of available extensions, click on PowerShell Desired State Configuration – Azure Arc.
On the next screen, simply click on the Create button at the bottom.
Deploy a DSC Configuration to your On-Premises Server
The next screen you will be presented with will allow you to select the PowerShell Desired State Configuration files to deploy to your on-premises server. The configuration file you upload here has to be a zip file. The zip file needs to have your DSC configuration .ps1 file at its root and have all the dependent DSC modules as folders directly at the root. In my case, the DSC configuration is contained in a file named Config.ps1 which is dependent on the SharePointDSC, SqlServerDSC, xActiveDirectory and xDownloadISO DSC modules.
You can download the ZIP file used for this demo here.
- In the Configuration Modules or Script control, browse to the Zip file which contains your configuration.
- In the Module-qualified Name of Configuration text box, enter the name of your configuration file (with the .ps1 extension) followed by ‘\’ and the name of the configuration inside of your configuration file. In my case, my configuration file is named Config.ps1 and the configuration inside of it is named SP19StandAlone. Therefore the value for this control will be Config.ps1\SP19StandAlone.
- For the Configuration Data PSD1 File control, upload the following file.
- Leave all the other controls’ values as default and click on the Review + create blue button at the bottom.
Once the validation of the DSC package passes, click on the Create button to initiate the configuration of your on-premises server.
This will automatically install the PowerShell DSC extension on your on-premises server, push down the DSC configuration and all the dependent DSC modules and execute the configuration of your server. By the end of it, you will have a fully functional SharePoint 2019 Standalone Server in your on-premises environment and you will be able to fully manage it via your Azure Portal from wherever you want.
How it Works Under the Cover
When you install the DSC extension on a VM, it gets installed under >strong>C:\Packages\Plugins\Microsoft.Powershell.DSC\<latest version>. Inside this folder, you will find the DSCWork folder, which in turn will contain a folder named with the name of the configuration Zip file we imported. In my case, this folder is located at C:\Packages\Plugins\Microsoft.Powershell.DSC\22.214.171.124\DSCWork\SPStandAlone.0. Inside of this folder will be the configuration .ps1 file, the ConfigurationData .psd1 files and a folder named after your configuration which will contain your compiled .mof file
All the dependent modules have been automatically copied under C:\Program Files\WindowsPowerShell\Modules and are ready to be used.
The DSC for Azure Arc, after being done copying all the files locally onto the on-premises server, will trigger the following PowerShell command in the background to initiate the DSCConfiguration:
Start-DSCConfiguration <name of your config></name>