Azure

Kickstarting Azure Infrastructure: Azure Bicep

Introduction

In our earlier articles, we launched Azure Bicep and in contrast it with ARM templates. Now that we’ve got a superb understanding of what Azure Bicep is and why it’s a compelling different to ARM templates, it’s time to get our palms soiled. On this article, we are going to arrange the environment for Azure Bicep and create our first Azure Bicep file.

Establishing the Setting

Earlier than we begin writing Azure Bicep information, we have to arrange the environment. Listed here are the steps.

  1. Set up Azure CLI: Azure CLI is a command-line device that you need to use to handle Azure sources. You’ll be able to obtain it from the official Azure web site right here.
    # Verify your put in model
    
    az --version
    
  2. Set up Bicep CLI: Bicep CLI is a command-line device that you need to use to work with Bicep information. You’ll be able to set up it utilizing Azure CLI.
    # Set up Bicep CLI
    az bicep set up
    
    # Verify your put in model
    az bicep model
    
  3. Set up Visual Studio Code and Bicep extension: Visual Studio Code is a well-liked code editor, and the Bicep extension gives options like autocompletion, code navigation, and reside linting.

You’ll be able to set up VS Code from right here.

After getting put in VS Code, use the under command to put in the Bicep Extension.

# Open Visual Studio Code and set up Bicep extension

code --install-extension ms-azuretools.vscode-bicep

Logging in to Azure and Setting the Subscription

Earlier than deploying the Bicep file, we have to log in to Azure and set the subscription. Listed here are the steps.

  1. Log in to Azure: Use the az login command to log in to Azure.
    # Log in to Azure
    az login
    
  2. Set the subscription: Use the az account set command to set the subscription.
    # Set the subscription
    
    az account set --subscription "mySubscription"
    

Creating your first Azure bicep file

Now that the environment is about up, let’s create our first Azure Bicep file. We’ll create a easy Bicep file that deploys a storage account.

  1. Create a brand new Bicep file: In Visual Studio Code, create a brand new file with a .bicep extension.
  2. Outline a storage account useful resource: Within the Bicep file, outline a storage account useful resource as follows.
    useful resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
      title: 'mystorageaccount'
      location: resourceGroup().location
      sku: {
        title: 'Standard_LRS'
      }
      variety: 'StorageV2'
    }
    
  3. Deploy the Bicep file: You’ll be able to deploy the Bicep file utilizing Azure CLI.
    # Deploy the Bicep file
    
    az deployment group create --resource-group myResourceGroup --template-file ./foremost.bicep
    

Conclusion

Congratulations! You might have arrange your surroundings for Azure Bicep and created your first Azure Bicep file. Within the subsequent article, we are going to dive deeper into the syntax of Azure Bicep. Keep tuned

Know extra about our firm at Skrots. Know extra about our companies 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