
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.ps1What 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

Jul 05, 2026 - 7 min read
How to migrate .NET versioning from x.x.x.x to SemVer
Many long-lived .NET repositories did not start with semantic versioning. They grew up with major.minor.build.revision, often set in …

Jul 03, 2026 - 7 min read
Modern versioning for ASP.NET Core and web apps and how to produce idempotent artifacts
ASP.NET Core applications are usually released often enough that versioning stops being a documentation concern and turns into delivery …

Jun 30, 2026 - 8 min read
Modern versioning for .NET desktop apps and how to produce idempotent artifacts
Desktop software makes versioning visible in a way that web systems often do not. A backend can hide a surprising amount of release …
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.
