The Azure team updates the Azure DSC module gallery regularly and there is also mechanism provided in the Azure Automation account to update the modules when new version are available. But how do you use a different or an older version of these modules? Recently I came across a scenario where I needed to use an older version of DSC module for SharePoint farm build as all the testing had been done against a specific version. The modules available in the gallery had already advanced to the latest SharePointDSC module. Following is a guide on how to use specific version of DSC modules. These steps also apply if you built your own module, and wanted to import it into your Automation account.
Deploy directly from the PowerShell Gallery
- Go to https://www.powershellgallery.com/ and search for the module you are require - in my case it was SharePointDSC.
- Navigate to the bottom of the page where it shows all the previous releases
- Click "Deploy to Azure Automation". This will redirect you to the Azure portal, and once you successfully login, it will navigate you to Import Module Blade.
- Here you can either select an existing automation account to import the module to, or create a new one.
To manually import the module
- Save the module to a local directory by running save Save-Module Commandlet
Save-Module -Name SharePointDSC -Path [Path] -RequiredVersion 188.8.131.52
- Navigate it to the path where you saved the module, and open the <moduleName>\<Version> folder. The <version> folder contains the ps1 file with module definition.
- Zip all the contents of this folder and name the zip file same as the name of the ps1 file. So in my case, the file is called SharePointDSC.zip
Here is some guidance on naming module files. This also applies if you were building a custom module https://azure.microsoft.com/en-us/blog/authoring-integration-modules-for-azure-automation/
- Once you have a zip file, Login into the azure portal and navigate to the Automation account, and then to the DSC modules blade
- Click "Add a Module" and upload the zip file. Once the importing of the module is finished, the module is ready for use.