Capture Bicep outputs in PowerShell

Outputs in Bicep are super handy.  They allow you to return values from your Bicep template or module.  We often use this for returning values that cannot be known upfront, such as an IP address, principal Id, domain name, url…

The challenge

As long as we consume these outputs within Bicep, it is quite easy to access them via the <module>.outputs.<output> syntax.  However, sometimes you need those outputs outside of your Bicep context, for example to be used in subsequent GitHub actions.  This blog describes  how you can do this within PowerShell.

The solution

When triggering you deployment from PowerShell by using the az deployment command, you can capture the deployment result.  When you convert this from JSON, you can access outputs via this syntax: $<output>.value.  Hereby you can find a simple example:

$result = az deployment sub create --template-file infra.bicep --parameters --location westeurope | ConvertFrom-Json
$apimStaticIpAddress = $


Once you figured out the syntax, it’s pretty simple to start using these outputs for deployment tasks that go beyond the scope of your Bicep deployment.




Your Azure Coach is specialized in organizing Azure trainings that are infused with real-life experience. All our coaches are active consultants, who are very passionate and who love to share their Azure expertise with you.