Create a Public IP Address With Bicep

This Azure Bicep blog post will show you how to create a Public IP using a Bicep template on the Microsoft Azure Cloud platform.

Bicep Template

The following Bicep template creates a public IP with the following options.

  • Static allocation method
  • Standard SKU
  • Global tier
param location string = resourceGroup().location
resource publicip 'Microsoft.Network/publicIPAddresses@2022-01-01' = {
  name:  'bicepBupIP'
  location: location
  properties: {
    publicIPAllocationMethod: 'Static'
  }

  sku: {
    name:  'Standard'
    tier:  'Global'
  }
 
} 

Output Public IP

Add the following line to your code to output the public IP address after the deployment and display it in the terminal (where you run Azure CLI).

output publicip  string =  publicip.properties.ipAddress

The Bicep API has many options, and the above code only creates a public IP. To link the IP address to a resource, please review the Bicep documentation.

About Bicep

Azure Bicep is a DSL (Domain specific language) programming language for deploying resources in Azure. It allows us to define the infrastructure as code and reuse it multiple times.

The main advantage of Bicep compared to other IAC languages is its immediate support of resources in Azure (including preview and GA). Bicep also provides a smooth authoring experience of template files using Intellisense when using VS code.

When authoring template files, there is no need to order the deployment code; Bicep is smart enough to orchestrate the deployment order correctly for you.

Processing…
Success! You're on the list.

Posted

in

,

by

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.