Azure Resource deployment with Bicep

Azure Resource deployment with Bicep

Bicep

In order to deploy Azure resources among approaches as through the Azure portal and through ARM templates, Pulumi, and many other the approach through Bicep files can be considered as one of the convenient as well as efficient approach.

Bicep is the simplest approach when it comes to deploy multiple resources to multiple clients or onto multiple resource groups.

Bicep is a domain-specific language (DSL), which uses declarative syntax in order to deploy Azure resources.

Bicep syntax reduces the complexity unlike in the JSON format in the ARM templates. So in that way Bicep can be considered as the abstract version of the ARM templates with reduced complexity but not with reduced capabilities. Ultimately during the deployment, the Bicep file will be converted into an ARM template by the Bicep CLI, leaving less amount of work to the Developer.

  • As on-the-fly the Bicep file will be converted into its ARM file, the following can be used to transpile an ARM template into its Bicep in Azure CLI.

az bicep decompile -f test.json

The following bicep code provisions a new storage account.

No alt text provided for this image

The name of the new storage account (stgActName), location, sku (stgActSku) can be defined in the bicep file itself or a separate parameter file (JSON) can be used.

In the following parameters are defined in the bicep file itself.

No alt text provided for this image

In the following a separate parameter file is created and the parameters are declared.

No alt text provided for this image

Bicep Module usage

Modules can be used to organize the resource deployments. A module is simply another bicep file which refers other bicep files. With the use of modules, it enhances code reuse as the same resource deployment bicep file can be called by many other deployments via modules and also reduces the complexity as it encapsulates complex details.

The given below code deploys a storage account and a hosting plan by calling the StorageTemplate.bicep.

No alt text provided for this image

Deployment of Azure Bicep files

Bicep files can be deployed in multiple ways as either manually or automatedly.

Deploying a Bicep file using the Azure CLI command:

New-AzResourceGroupDeployment -Name NameOfTheAzureResource -TemplateFile C:bicepFilePath.bicep

  • Deploying with the yaml file using Azure CLI command:

New-AzResourceGroupDeployment -Name NameOfTheAzureResource -TemplateFile C:yamlFilePath.bicep

  • Deploy yaml file via CI/CD pipelines

?YAML file for Bicep deployment

(YAML is used for writing configuration files and it is a data serialization language)

The following is an example for yaml file.

No alt text provided for this image
No alt text provided for this image

The above yaml code validates and deploys the resource (storage account) defined in the bicep (StorageTemplate.bicep)

If the parameters are defined in a separate parameter.json file the file locations also should be provided after the bicep file location

Eg: --parameters @Infrastructure/Parameters/fappmain.parameters.json\

The *AzureSubscription and the Resource Group names can be passed as either a separate variable or as a variable group.

No alt text provided for this image

The AzureSubscription and the Resource Group names can be passed as a variable group.

Azure DevOps Variable Group

No alt text provided for this image

Azure Service Connection

*AzureSubscription in the yaml file is simply the Connection between Azure DevOps pipelines and the external remote azure services.

Inorder to create a new Service Connection:

1. Log into the Azure DevOps Project

2. Project settings -> Service Connections -> New Service Connection

3. Select Azure Resource Manager and Service Principal (automatic)

4. Provide the Subscription and Resource Group details.

?Afterwards the developed YAML files can be deployed with the use of scheduled pipelines.

Likewise at a time with a requirement to provision multiple resources to multiple environments, Bicep can be used to perform the tedious steps and to increase the efficiency with just a little number of codes.?


要查看或添加评论,请登录

Shamali Weerasinghe的更多文章

  • AI and ML Capabilities with Power BI

    AI and ML Capabilities with Power BI

    Interactive dashboards with rich visualizations, self-service capabilities, and continuous enrichments in a very…

    2 条评论
  • Slicers Vs Filters

    Slicers Vs Filters

    What are slicers ? What are filters? How are they different from each other? What and When should be used? Well lets…

  • Power BI Storage Modes

    Power BI Storage Modes

    Power BI provides different types of storage modes, which can be a great tool when it comes to performance improvement…

    2 条评论
  • Power BI Aggregation tables

    Power BI Aggregation tables

    An Aggregation table is simply a smaller imported version of the original large DirectQuery table, which also can be…

  • Power BI Composite model

    Power BI Composite model

    What is a composite model in Power BI? Composite model is a data model, which is built on a combination of imported…

  • Blog Post : SSIS Loggings

    Blog Post : SSIS Loggings

    https://shamalibi.home.

  • SSIS Loggings

    SSIS Loggings

    https://shamalibi.home.

社区洞察

其他会员也浏览了