AzureStack-QuickStart-Templ.../Bicep
Rakesh Kumar 9bf38a8181 clean ARM templates from Bicep samples 2022-01-10 15:05:19 -08:00
..
101-availabilityset-multiplevm-linux clean ARM templates from Bicep samples 2022-01-10 15:05:19 -08:00
101-simple-linux-vm-custom-managed-disk clean ARM templates from Bicep samples 2022-01-10 15:05:19 -08:00
101-vmss-windows-vm clean ARM templates from Bicep samples 2022-01-10 15:05:19 -08:00
201-vmss-linux-extension clean ARM templates from Bicep samples 2022-01-10 15:05:19 -08:00
201-vmss-windows-extension clean ARM templates from Bicep samples 2022-01-10 15:05:19 -08:00
README.md update readme 2021-11-11 11:44:29 -08:00

README.md

page_type languages products description urlFragment
sample
bicep
templates
Sample Bicep templates to deploy resources on AzureStackHub AzureStack-QuickStart-Templates

This directory contains Bicep samples for AzureStackHub

Project Bicep - an ARM DSL

Please visit the Project Bicep main page for full information and links.

What is Bicep?

Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. It aims to drastically simplify the authoring experience with a cleaner syntax, improved type safety, and better support for modularity and code re-use. Bicep is a transparent abstraction over ARM and ARM templates, which means anything that can be done in an ARM Template can be done in Bicep (outside of temporary known limitations). All resource types, apiVersions, and properties that are valid in an ARM template are equally valid in Bicep on day one (Note: even if Bicep warns that type information is not available for a resource, it can still be deployed).

Bicep code is transpiled to standard ARM Template JSON files, which effectively treats the ARM Template as an Intermediate Language (IL).

Video overview of Bicep

Bicep and Azure Stack Hub

Azure Stack Hub uses ARM (check this article for more information and considerations) and enables an easy conversion of the AzStackHub QuickStart Templates.

To convert any AzureStack ARM template to Bicep, you'll need to add the api version within each resource declaration. API profile is not yet supported in Bicep. Here is the tracking feature request.

Getting started

  1. Ensure the “https://github.com/Azure/bicep/blob/main/README.md#get-started-with-bicep” are completed
  2. Set the Azure Stack Hub environment – make sure the correct API Profile is used for Azure Stack Hub:
az cloud register `
    -n <environmentname> `
    --endpoint-resource-manager https://management.<region>.<fqdn> `
    --suffix-storage-endpoint "<fqdn>" `
    --suffix-keyvault-dns ".vault.<fqdn>" `
    --profile 2020-09-01-hybrid

az cloud set -n <environmentname>
az login --tenant contoso.onmicrosoft.com 

Az CLI Bicep commands

# Convert ARM template to Bicep template
az bicep decompile --file .\azuredeploy.json 
# Generate ARM template from Bicep template 
az bicep build --file .\azuredeploy.bicep --outfile bicepgenerated.json
# Deploy ARM/Bicep template
az deployment group create --resource-group testrg --template-file <ARM/Bicep template> --parameters .\azuredeploy.parameters.json

Known issues

Main categories of error during conversion:

  1. Error BCP079: This expression is referencing its own declaration, which is not allowed.
  2. Error BCP034: The enclosing array expected an item of type "module[] | (resource | module) | resource[]", but the provided item was of type "string".
    • This is when bicep decompile is not able to recognize the dependent resource and tries to convert the “dependsOn” defined in ARM template. The workaround is to modify the generated bicep template to either create implicit dependency or add the resource (not the resource id as used in ARM template) in dependsOn parameter. Doc link