Azure

Exploring Azure Bicep Outputs: Retrieving Useful resource Properties

Introduction

Good day everybody! We’ve been on an thrilling journey exploring Azure Bicep. We’ve seen what it’s, and the way it compares to ARM templates, arrange our surroundings, dived into its syntax, and explored parameters, assets, and variables. In the present day, we’re going to take one other step ahead. We’ll discover one of many key elements of Azure Bicep – Outputs. So, let’s get began!

Logging in to Azure

Earlier than we begin, let’s guarantee we’re logged into Azure. Right here’s how you are able to do it.

  1. Open your terminal or command immediate: You should utilize any terminal or command immediate that you just’re comfy with.
  2. Log in to Azure: Use the az login command to log in to Azure.
    # Log in to Azure
    az login
    
  3. Set your subscription: Use the az account set command to set your subscription.
    # Set your subscription
    az account set --subscription "YourSubscriptionName"
    

Azure Bicep Outputs

Outputs in Azure Bicep are the outcomes which are returned after deployment. They let you retrieve the worth of a property from a deployed useful resource. This makes your Bicep recordsdata extra versatile and reusable.

You may outline an output utilizing the output key phrase. Right here’s an instance.

output storageAccountId string = storageAccount.id

On this instance, storageAccountId is an output of a kind string. The worth of this output is the id property of the storageAccount useful resource.

Right here’s an instance of a Bicep file that makes use of an output.

param storageAccountName string = 'mystorageaccount'
var location = 'westus'
useful resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
  identify: storageAccountName
  location: location
  sku: {
    identify: 'Standard_LRS'
  }
  sort: 'StorageV2'
}
output storageAccountId string = storageAccount.id

On this instance, the storageAccountId output returns the id of the storageAccount useful resource after deployment.

Conclusion

Effectively achieved! You’ve simply realized the right way to use outputs in Azure Bicep. Outputs are a strong characteristic that permits you to retrieve the worth of a property from a deployed useful resource. In our subsequent session, we’ll discover modules in Azure Bicep. So, keep tuned and continue to learn.

Know extra about our firm at Skrots. Know extra about our providers at Skrots Companies, Additionally checkout all different blogs at Weblog at Skrots

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button