Course contentsShow
← Cloud and Infrastructure
Lesson 932 of 2,98917. Azure ARM Templates and BicepFree lesson

Bicep Outputs and Cross-References

Defining outputs to expose resource properties and using them across module boundaries.

Bicep Outputs and Cross-References

What you'll learn: How to expose resource properties from Bicep files using outputs and reference them across module boundaries.

The Core Idea

In Bicep, outputs let you extract and expose specific properties from resources you've deployed — like a resource's ID, endpoint URL, or connection string — so they can be used by other modules or deployment pipelines. Think of outputs as the "return values" from your Bicep module, making important information available to whatever called that module.

Why Outputs Matter

When you deploy infrastructure as modules (which you learned in lesson 928), each module is self-contained. But often Module B needs information from Module A — like a storage account name or virtual network ID. Outputs solve this by publishing specific values that other modules can consume.

Defining an Output

Outputs follow a simple syntax:

output storageAccountName string = storageAccount.name
output storageEndpoint string = storageAccount.properties.primaryEndpoints.blob

You specify the output name, its type, and the value to expose.

Cross-Module References

When you call a Bicep module (as you learned earlier), you can capture its outputs:

module storage 'storage.bicep' = {
  name: 'storageDeployment'
  params: { ... }
}

// Reference the module's output
var storageName = storage.outputs.storageAccountName

This creates a clean contract between modules: the storage module publishes what it offers, and consuming modules grab only what they need.

Analogy

Think of outputs as a restaurant's takeout window. The kitchen (your module) prepares many things internally, but only selected items appear in the window for customers (other modules) to collect.

Key Takeaway:
Bicep outputs expose resource properties for reuse across modules, enabling clean separation and information sharing in your infrastructure code.