A sample pipeline for managing PowerShell assets in an Azure Automation account.
Before starting to work with this sample project, I suggest reading the information in the following blog post:
Also, you might refer to the following posts regarding the building, publishing and accessing PowerShell modules during deployment:
- A sample CI/CD pipeline for PowerShell module
- How to access private PowerShell repository from Azure pipeline
This repository contains the source code for a sample Azure DevOps pipeline that deploys PowerShell assets such as runbooks, modules, and DSC configurations into an Azure Automation account.
Clone the repository to your local machine and look for project artifacts in the following locations:
- dsc-configurations - source code for a sample PowerShell DSC configuration
- runbooks - source code for a sample PowerShell runbook
- *.depend.psd1 files in corresponding folders - managing dependencies with PSDepend
- *.build.ps1 - build configuration for InvokeBuild
- *.deploy.ps1 - deployment configuration for PSDeploy
This project uses InvokeBuild module to automate build tasks such as running test, performing static code analysis, building the deployment artifact, etc.
- To build the project, run: Invoke-Build
- To see other build options: Invoke-Build ?
For deployment, the project uses PSDeploy module to simplify the deployment process and handle the dependency between the deployment artifacts. To get more information on how it works, please refer to PSDeploy docs.
To deploy from a local source:
- Create a target Azure Automation account
- Update the account name and its resource group name in azure.automation-account-pipeline.deploy.ps1
- In a PowerShell session, connect to your Azure environment (Connect-AzAccount)
- Run 'Invoke-Build Deploy'
- Editing - Visual Studio Code
- Runtime - PowerShell Core
- Build tool - InvokeBuild
- Dependency management - PSDepend
- Testing - Pester
- Code coverage - Pester
- Static code analysis - PSScriptAnalyzer
- Deployment tool - PSDeploy