Test your PowerShell DSC configuration on Azure VM

Troubleshooting and debugging PowerShell DSC configurations could be sometimes very painful. If you are preparing your DSC configuration to use in Azure or even on-premises, you would like to test it in the real environment.

One of the simplest method is to create empty Azure VM and push your configuration via PowerShell Desire State Configuration extension.  For example, if we want to create IIS Web Server joined to Active Directory domain we will need following configuration:

If you need more complex environment then just a one server you can develop an ARM Template to simplify redeployment.

Now you should organize your folders, I will use following structure:


After it is time to zip dsc folder, upload it to Azure Blob storage and deploy Azure PowerShell DSC Extension to created Virtual Machine. Please, follow comments inside code to understand better each part:



The configuration data with PSDscAllowDomainUser and PSDscAllowPlainTextPassword can be useful during DSC debugging but in the real projects we should encrypt credentials with our own certificate.

The last thing is to launch the script Test-Configuration.ps1 for each modification of DSC configuration file until Success status.

You can check the detailed status with execution log and errors on Azure Portal:

Virtual Machines -> [your vm] -> Extensions -> Microsoft.PowerShell.DSC -> View detailed status

or to examine full logs inside your Virtual Machine:


the detailed status that you see on Azure Portal is inside following folder: