
Azure Pipelines inherently provides the ability for PowerShell scripts to be defined and executed inline.
1- task: AzureCLI@2
2 displayName: Bicep apply
3 inputs:
4 azureSubscription: MyAzureDevOpsConnectionName
5 scriptType: pscore
6 scriptLocation: inlineScript
7 inlineScript: az deployment group create --resource-group $(AZ_PLATFORM_RESOURCE_GROUP_NAME) --name $(AZ_DEPLOYMENT_NAME)-$(AZ_ENV_NAME)
Unfortunately, this can become very confusing in many situations and also repetitive, since, for example, an Azure Bicep deployment task is required in several stages, so that the task is repeated accordingly.
It can help that the PowerShell script is no longer declared inline, but via a scriptPath.
1- task: AzureCLI@2
2 displayName: Bicep apply
3 inputs:
4 azureSubscription: MyAzureDevOpsConnectionName
5 scriptType: pscore
6 scriptLocation: scriptPath
7 inlineScript: $(Pipeline.Workspace)/bicep/run.ps1
What the script is missing now are the variables, whereby one must note that by default variables are available only within the file. This means that the variable $(AZ_PLATFORM_RESOURCE_GROUP_NAME).
To make variables available from outside in a PowerShell script file you need the $ENV: prefix.
1# run.ps1
2az deployment group create `
3 --resource-group $($ENV:AZ_PLATFORM_RESOURCE_GROUP_NAME) `
4 --name "$($ENV:AZ_DEPLOYMENT_NAME)-$($ENV:AZ_ENV_NAME)"
Now you can clean up your pipeline YAML file and reuse PowerShell commands very easily.
Related articles

Nov 10, 2018 · 1 min read
Hide organizations in Azure DevOps aka VSTS
Azure DevOps aka Visual Studio Team Services aka VSTS got a pretty nice new interface and design the last month - but has one huge …

Jan 05, 2026 · 2 min read
Serve SPAs correctly on Cloudflare Workers
Single Page Applications like React expect the server to always return index.html and let the client-side router take over. On Cloudflare …

Jan 04, 2026 · 2 min read
Automate Pull Request Comments with GitHub Actions
When working with Pull Requests (PRs) in GitHub, it is often helpful to provide immediate feedback or relevant information directly in the …
Let's Work Together
Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

Comments