adaptive.run TECH BLOG

Cloud can be tricky sometimes. Find out what scenarios we've ran into that are worth being mentioned and explained.

GitHub Actions to deploy Azure Bicep

Level: 200
Publishing date: 01-Oct-2021
Author: Catalin Popa

The purpose of today’s blog post is to show you how you can use GitHub Actions to deploy a Bicep configuration to Azure.

Let’s start with the basics and establish what is Azure Bicep!

Azure Bicep represents the Next Generation of ARM templates, being an extension of them. Bicep is a Domain Specific Language (DSL) for ARM templates.

Azure Bicep’s scope is defined in the documentation (https://github.com/Azure/bicep) as aiming to simplify as much as possible the authoring experience by presenting a cleaner syntax and better support for modularity and re-use of code. As such, Bicep represents a transparent abstraction over ARM and ARM templates, meaning that everything that can be done in ARM Template, can also be done in Bicep.

If you are interested to see some examples of Azure Bicep configurations, you can check this link: https://github.com/Azure/bicep/tree/main/docs/examples

Now let’s define the scope of GitHub Actions!

GitHub Actions enable you to create workflows by using the GitHub repository. This manner is similar to Azure DevOps Pipelines, as they allow you to create an automated workflow. GitHub Actions can really help you with you work!

If you are interested to find out more about them, you can check this links: What is GitHub Actions for Azure and Azure/actions GitHub Repository

Let me show you a Bicep sample configuration

Before starting this, I also recommend the Bicep extension for VSCode, which contains a built-in Intellisense (https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep)

My goal is to deploy an Azure Virtual Network by using the Bicep file.

GitHub Repository Secrets

In the GitHub repository where you want to run the Bicep configuration, select Settings -> Secrets.

Next, add 2 secrets, as seen below:

- AZURE_SUBSCRIPTION_ID – Subscription ID of the Azure Subscription

- AZURE_CREDENTIALS – in json format as below, this is the Service Principal that will be used for az login and to deploy your Bicep configuration

Use of GitHub Action to deploy Azure Bicep

In the GitHub repository that you use, select Actions -> Workflows -> New Workflow to add this GitHub Action. Quick tip – if you are merging into main branch with the folder structure presented below, the GitHub Action will be created automatically.

GitHub Action

 

adaptive.run

Transform your business.
Run adaptive.

Contact

Phone: +40 72 444 3842
Email: hello@adaptive.run

© Copyright  2019-2024 adaptive.run- All Rights Reserved