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…
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.
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: $result.properties.outputs.<output>.value. Hereby you can find a simple example:
$result = az deployment sub create --template-file infra.bicep --parameters --location westeurope | ConvertFrom-Json $apimStaticIpAddress = $result.properties.outputs.apimStaticIpAddress.value
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.