Azure Bicep Refreshed

Published Apr 25 2021 05:00 PM 3,804 Views
Microsoft

In the previous post, I introduced the very early stage of Project Bicep. At that time, it was the version of 0.1.x, but now it's updated to 0.3.x. You can use it for production, and many features keep being introduced. Throughout this post, I'm going to discuss new features added since the last post.

 

 

Azure CLI Integration

 

While Bicep CLI works as a stand-alone tool, it's been integrated with Azure CLI from v2.20.0 and later. Therefore, you can run bicep in either way.

 

    # Bicep CLI
    bicep build azuredeploy.bicep
    
    # Azure CLI
    az bicep build --file azuredeploy.bicep

 

NOTE: Although Bicep CLI could build multiple files by v0.2.x, it's now only able to build one file at a time from v0.3.x. Therefore, if you want to build multiple files, you should do it differently. Here's a sample PowerShell script, for example.

 

    Get-ChildItem -Path **/*.bicep -Recurse | ForEach-Object {
        az bicep build --file $_.FullName
    }

 

Because of the Azure CLI integration, you can also provision resources through the bicep file like below:

 

    # ARM template file
    az deployment group create \
        --name  \
        --resource-group  \
        --template-file azuredeploy.json \
        --parameters @azuredeploy.parameters.json
    
    # Bicep file
    az deployment group create \
        --name  \
        --resource-group  \
        --template-file azuredeploy.bicep \
        --parameters @azuredeploy.parameters.json

 

Bicep Decompiling

 

From v0.2.59, Bicep CLI can convert ARM templates to bicep files. It's particularly important because still many ARM templates out there have been running and need maintenance. Run the following command for decompiling.

 

    # Bicep CLI
    bicep decompile azuredeploy.json
    
    # Azure CLI
    az bicep decompile --file azuredeploy.json

 

NOTE: If your ARM template contains a copy attribute, bicep can't decompile it as of this writing. In the later version, it should be possible.

 

Decorators on Parameters

 

Writing parameters has become more articulate than v0.1.x, using the decorators. For example, there are only several possible SKU values of a Storage Account available, so using the @allowed decorator like below makes the code better readability.

 

    // Without decorators
    param storageAccountSku string {
      allowd: [
        'Standard_GRS'
        'Standard_LRS'
      ]
      default: 'Standard_LRS'
    }
    
    // With decorators
    @allowed([
      'Standard_GRS'
      'Standard_LRS'
    ])
    param storageAccountSku string = 'Standard_LRS'

 

Conditional Resources

 

You can use ternary operations for attributes. What if you can conditionally declare a resource itself using conditions? Let's have a look. The following code says if the location is only Korea Central, the Azure App Service resource can be provisioned.

 

    param location = resourceGroup().location

    resource webapp 'Microsoft.Web/sites@2020-12-01' = if (location == 'koreacentral') {
      ...
    }

 

Loops

 

While ARM templates use both copy attribute and copyIndex() function for iterations, bicep uses the for...in loop. Have a look at the code below. You can declare Azure App Service instances using the array parameter through the for...in loop.

 

    param webapps array = [
      'dev'
      'test'
      'prod'
    ]
  
    // Use array only
    resource webapp 'Microsoft.Web/sites@2020-12-01' = [for name in webapps: {
      name: 'my-webapp-${name}'
      ...
    }]

 

You can also use both array and index at the same time.

 

    // Use both array and index
    resource webapp 'Microsoft.Web/sites@2020-12-01' = [for (name, index) in webapps: {
      name: 'my-webapp-${name}-${index + 1}'
      ...
    }]

 

Instead of the array, you can use the range() function in the loop.

 

    // Use range
    resource webapp 'Microsoft.Web/sites@2020-12-01' = [for i in range(0, 10): {
      name: 'my-webapp-${index + 1}'
      ...
    }]

 

Please note that you MUST use the array expression ([...]) outside the for...in loop because it declares the array of the resources. Bicep will do the rest.

 

Modules

 

Personally, I love this part. While ARM templates use the linked template, bicep uses the module keyword for modularisation. Here's the example for Azure Function app provisioning. For this, you need at least Storage Account, Consumption Plan and Azure Functions resources. Each resource can be individually declared as a module, and the orchestration bicep file calls each module. Each module should work independently, of course.

 

Storage Account

 

    // storageAccount.bicep
    param resourceName string
    param location string = resourceGroup().location
    
    resource st 'Microsoft.Storage/storageAccounts@2021-02-01' = {
      name: resourceName
      location: location
      ...
    }
    
    output id string = st.id
    output name string = st.name

 

Consumption Plan

 

    // consumptionPlan.bicep
    param resourceName string
    param location string = resourceGroup().location
    
    resource csplan 'Microsoft.Web/serverfarms@2020-12-01' = {
      name: resourceName
      location: location
      ...
    }
    
    output id string = csplan.id
    output name string = csplan.name

 

Azure Functions

 

    // functionApp.bicep
    param resourceName string
    param location string = resourceGroup().location
    param storageAccountId string
    param storageAccountName string
    param consumptionPlanId string
    
    resource fncapp 'Microsoft.Web/sites@2020-12-01' = {
      name: resourceName
      location: location
      ...
      properties: {
        serverFarmId: consumptionPlanId
        ...
        siteConfig: {
          appSettings: [
            {
              name: 'AzureWebJobsStorage'
              value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(storageAccountId, '2021-02-01').keys[0].value}'
            }
            ...
          ]
        }
      }
    }
    
    output id string = fncapp.id
    output name string = fncapp.name

 

Modules Orchestration

 

Here's the orchestration bicep file to combine modules. All you need to do is to declare a module, refer to the module location and pass parameters. Based on the references between modules, dependencies are automatically calculated.

 

    // azuredeploy.bicep
    param resourceName string
    param location string = resourceGroup().location
    
    module st './storage-account.bicep' = {
      name: 'StorageAccountProvisioning'
      params: {
        name: resourceName
        location: location
      }
    }
    
    module csplan './consumption-plan.bicep' = {
      name: 'ConsumptionPlanProvisioning'
      params: {
        name: resourceName
        location: location
      }
    }
    
    module fncapp './function-app.bicep' = {
      name: 'FunctionAppProvisioning'
      params: {
        name: resourceName
        location: location
        storageAccountId: st.outputs.id
        storageAccountName: st.outputs.name
        consumptionPlanId: csplan.outputs.id
      }
    }

 

NOTE: Unfortunately, as of this writing, referencing to external URL is not supported yet, unlike linked ARM templates.

 


 

So far, we've briefly looked at the new features of Project Bicep. As Bicep is one of the most rapidly growing toolsets in Azure, keep using it for your resource management.

 

This article was originally published on Dev Kimchi.

%3CLINGO-SUB%20id%3D%22lingo-sub-2282165%22%20slang%3D%22en-US%22%3EAzure%20Bicep%20Refreshed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2282165%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fapps-on-azure%2Fwhat-is-bicep-the-arm-template-dsl%2Fba-p%2F1634067%3FWT.mc_id%3Ddevops-25381-juyoo%22%20target%3D%22_blank%22%3Eprevious%20post%3C%2FA%3E%2C%20I%20introduced%20the%20very%20early%20stage%20of%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fbicep%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EProject%20Bicep%3C%2FA%3E.%20At%20that%20time%2C%20it%20was%20the%20version%20of%3CCODE%3E0.1.x%3C%2FCODE%3E%2C%20but%20now%20it's%20updated%20to%3CCODE%3E0.3.x%3C%2FCODE%3E.%20You%20can%20use%20it%20for%20production%2C%20and%20many%20features%20keep%20being%20introduced.%20Throughout%20this%20post%2C%20I'm%20going%20to%20discuss%20new%20features%20added%20since%20the%20last%20post.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fapps-on-azure%2Fwhat-is-bicep-the-arm-template-dsl%2Fba-p%2F1634067%3FWT.mc_id%3Ddevops-25381-juyoo%22%20target%3D%22_blank%22%3EWhat%20is%20Bicep%3F%20The%20ARM%20Template%20DSL%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fapps-on-azure%2Flinting-bicep-codes-in-devops-pipeline-arm-ttk%2Fba-p%2F1718204%3FWT.mc_id%3Ddevops-25381-juyoo%22%20target%3D%22_blank%22%3ELinting%20Bicep%20Codes%20in%20DevOps%20Pipeline%20%E2%80%93%20ARM%20TTK%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CSTRONG%3EAzure%20Bicep%20Refreshed%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--492675056%22%20id%3D%22toc-hId--492675056%22%3EAzure%20CLI%20Integration%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20Bicep%20CLI%20works%20as%20a%20stand-alone%20tool%2C%20it's%20been%20integrated%20with%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fwhat-is-azure-cli%3FWT.mc_id%3Ddevops-25381-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Frelease-notes-azure-cli%3FWT.mc_id%3Ddevops-25381-juyoo%23march-02-2021%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ev2.20.0%3C%2FA%3E%20and%20later.%20Therefore%2C%20you%20can%20run%20bicep%20in%20either%20way.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%23%20Bicep%20CLI%0A%20%20%20%20bicep%20build%20azuredeploy.bicep%0A%20%20%20%20%0A%20%20%20%20%23%20Azure%20CLI%0A%20%20%20%20az%20bicep%20build%20--file%20azuredeploy.bicep%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20Although%20Bicep%20CLI%20could%20build%20multiple%20files%20by%3CCODE%3Ev0.2.x%3C%2FCODE%3E%2C%20it's%20now%20only%20able%20to%20build%20one%20file%20at%20a%20time%20from%3CCODE%3Ev0.3.x%3C%2FCODE%3E.%20Therefore%2C%20if%20you%20want%20to%20build%20multiple%20files%2C%20you%20should%20do%20it%20differently.%20Here's%20a%20sample%20PowerShell%20script%2C%20for%20example.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20Get-ChildItem%20-Path%20**%2F*.bicep%20-Recurse%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20az%20bicep%20build%20--file%20%24_.FullName%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBecause%20of%20the%20Azure%20CLI%20integration%2C%20you%20can%20also%20provision%20resources%20through%20the%20bicep%20file%20like%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%23%20ARM%20template%20file%0A%20%20%20%20az%20deployment%20group%20create%20%5C%0A%20%20%20%20%20%20%20%20--name%20%20%5C%0A%20%20%20%20%20%20%20%20--resource-group%20%20%5C%0A%20%20%20%20%20%20%20%20--template-file%20azuredeploy.json%20%5C%0A%20%20%20%20%20%20%20%20--parameters%20%40azuredeploy.parameters.json%0A%20%20%20%20%0A%20%20%20%20%23%20Bicep%20file%0A%20%20%20%20az%20deployment%20group%20create%20%5C%0A%20%20%20%20%20%20%20%20--name%20%20%5C%0A%20%20%20%20%20%20%20%20--resource-group%20%20%5C%0A%20%20%20%20%20%20%20%20--template-file%20azuredeploy.bicep%20%5C%0A%20%20%20%20%20%20%20%20--parameters%20%40azuredeploy.parameters.json%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1994837777%22%20id%3D%22toc-hId-1994837777%22%3EBicep%20Decompiling%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fbicep%2Freleases%2Ftag%2Fv0.2.59%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CCODE%3Ev0.2.59%3C%2FCODE%3E%3C%2FA%3E%2C%20Bicep%20CLI%20can%20convert%20ARM%20templates%20to%20bicep%20files.%20It's%20particularly%20important%20because%20still%20many%20ARM%20templates%20out%20there%20have%20been%20running%20and%20need%20maintenance.%20Run%20the%20following%20command%20for%20decompiling.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%23%20Bicep%20CLI%0A%20%20%20%20bicep%20decompile%20azuredeploy.json%0A%20%20%20%20%0A%20%20%20%20%23%20Azure%20CLI%0A%20%20%20%20az%20bicep%20decompile%20--file%20azuredeploy.json%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20If%20your%20ARM%20template%20contains%20a%3CCODE%3Ecopy%3C%2FCODE%3Eattribute%2C%20bicep%20can't%20decompile%20it%20as%20of%20this%20writing.%20In%20the%20later%20version%2C%20it%20should%20be%20possible.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-187383314%22%20id%3D%22toc-hId-187383314%22%3EDecorators%20on%20Parameters%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWriting%20parameters%20has%20become%20more%20articulate%20than%3CCODE%3Ev0.1.x%3C%2FCODE%3E%2C%20using%20the%20decorators.%20For%20example%2C%20there%20are%20only%20several%20possible%20SKU%20values%20of%20a%20Storage%20Account%20available%2C%20so%20using%20the%3CCODE%3E%40allowed%3C%2FCODE%3Edecorator%20like%20below%20makes%20the%20code%20better%20readability.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20Without%20decorators%0A%20%20%20%20param%20storageAccountSku%20string%20%7B%0A%20%20%20%20%20%20allowd%3A%20%5B%0A%20%20%20%20%20%20%20%20'Standard_GRS'%0A%20%20%20%20%20%20%20%20'Standard_LRS'%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20default%3A%20'Standard_LRS'%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20With%20decorators%0A%20%20%20%20%40allowed(%5B%0A%20%20%20%20%20%20'Standard_GRS'%0A%20%20%20%20%20%20'Standard_LRS'%0A%20%20%20%20%5D)%0A%20%20%20%20param%20storageAccountSku%20string%20%3D%20'Standard_LRS'%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1620071149%22%20id%3D%22toc-hId--1620071149%22%3EConditional%20Resources%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20ternary%20operations%20for%20attributes.%20What%20if%20you%20can%20conditionally%20declare%20a%20resource%20itself%20using%20conditions%3F%20Let's%20have%20a%20look.%20The%20following%20code%20says%20if%20the%20location%20is%20only%20%3CSTRONG%3EKorea%20Central%3C%2FSTRONG%3E%2C%20the%20Azure%20App%20Service%20resource%20can%20be%20provisioned.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20param%20location%20%3D%20resourceGroup().location%0A%0A%20%20%20%20resource%20webapp%20'Microsoft.Web%2Fsites%402020-12-01'%20%3D%20if%20(location%20%3D%3D%20'koreacentral')%20%7B%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-867441684%22%20id%3D%22toc-hId-867441684%22%3ELoops%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20ARM%20templates%20use%20both%3CCODE%3Ecopy%3C%2FCODE%3Eattribute%20and%3CCODE%3EcopyIndex()%3C%2FCODE%3Efunction%20for%20iterations%2C%20bicep%20uses%20the%3CCODE%3Efor...in%3C%2FCODE%3Eloop.%20Have%20a%20look%20at%20the%20code%20below.%20You%20can%20declare%20Azure%20App%20Service%20instances%20using%20the%20array%20parameter%20through%20the%3CCODE%3Efor...in%3C%2FCODE%3Eloop.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20param%20webapps%20array%20%3D%20%5B%0A%20%20%20%20%20%20'dev'%0A%20%20%20%20%20%20'test'%0A%20%20%20%20%20%20'prod'%0A%20%20%20%20%5D%0A%20%20%0A%20%20%20%20%2F%2F%20Use%20array%20only%0A%20%20%20%20resource%20webapp%20'Microsoft.Web%2Fsites%402020-12-01'%20%3D%20%5Bfor%20name%20in%20webapps%3A%20%7B%0A%20%20%20%20%20%20name%3A%20'my-webapp-%24%7Bname%7D'%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%5D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20use%20both%20array%20and%20index%20at%20the%20same%20time.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20Use%20both%20array%20and%20index%0A%20%20%20%20resource%20webapp%20'Microsoft.Web%2Fsites%402020-12-01'%20%3D%20%5Bfor%20(name%2C%20index)%20in%20webapps%3A%20%7B%0A%20%20%20%20%20%20name%3A%20'my-webapp-%24%7Bname%7D-%24%7Bindex%20%2B%201%7D'%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%5D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInstead%20of%20the%20array%2C%20you%20can%20use%20the%3CCODE%3Erange()%3C%2FCODE%3Efunction%20in%20the%20loop.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20Use%20range%0A%20%20%20%20resource%20webapp%20'Microsoft.Web%2Fsites%402020-12-01'%20%3D%20%5Bfor%20i%20in%20range(0%2C%2010)%3A%20%7B%0A%20%20%20%20%20%20name%3A%20'my-webapp-%24%7Bindex%20%2B%201%7D'%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%5D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20note%20that%20you%20MUST%20use%20the%20array%20expression%20(%3CCODE%3E%5B...%5D%3C%2FCODE%3E)%20outside%20the%3CCODE%3Efor...in%3C%2FCODE%3Eloop%20because%20it%20declares%20the%20array%20of%20the%20resources.%20Bicep%20will%20do%20the%20rest.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--940012779%22%20id%3D%22toc-hId--940012779%22%3EModules%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPersonally%2C%20I%20love%20this%20part.%20While%20ARM%20templates%20use%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-resource-manager%2Ftemplates%2Flinked-templates%3FWT.mc_id%3Ddevops-25381-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elinked%20template%3C%2FA%3E%2C%20bicep%20uses%20the%3CCODE%3Emodule%3C%2FCODE%3Ekeyword%20for%20modularisation.%20Here's%20the%20example%20for%20Azure%20Function%20app%20provisioning.%20For%20this%2C%20you%20need%20at%20least%20Storage%20Account%2C%20Consumption%20Plan%20and%20Azure%20Functions%20resources.%20Each%20resource%20can%20be%20individually%20declared%20as%20a%20module%2C%20and%20the%20orchestration%20bicep%20file%20calls%20each%20module.%20Each%20module%20should%20work%20independently%2C%20of%20course.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--249451305%22%20id%3D%22toc-hId--249451305%22%3EStorage%20Account%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20storageAccount.bicep%0A%20%20%20%20param%20resourceName%20string%0A%20%20%20%20param%20location%20string%20%3D%20resourceGroup().location%0A%20%20%20%20%0A%20%20%20%20resource%20st%20'Microsoft.Storage%2FstorageAccounts%402021-02-01'%20%3D%20%7B%0A%20%20%20%20%20%20name%3A%20resourceName%0A%20%20%20%20%20%20location%3A%20location%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20output%20id%20string%20%3D%20st.id%0A%20%20%20%20output%20name%20string%20%3D%20st.name%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--2056905768%22%20id%3D%22toc-hId--2056905768%22%3EConsumption%20Plan%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20consumptionPlan.bicep%0A%20%20%20%20param%20resourceName%20string%0A%20%20%20%20param%20location%20string%20%3D%20resourceGroup().location%0A%20%20%20%20%0A%20%20%20%20resource%20csplan%20'Microsoft.Web%2Fserverfarms%402020-12-01'%20%3D%20%7B%0A%20%20%20%20%20%20name%3A%20resourceName%0A%20%20%20%20%20%20location%3A%20location%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20output%20id%20string%20%3D%20csplan.id%0A%20%20%20%20output%20name%20string%20%3D%20csplan.name%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-430607065%22%20id%3D%22toc-hId-430607065%22%3EAzure%20Functions%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20functionApp.bicep%0A%20%20%20%20param%20resourceName%20string%0A%20%20%20%20param%20location%20string%20%3D%20resourceGroup().location%0A%20%20%20%20param%20storageAccountId%20string%0A%20%20%20%20param%20storageAccountName%20string%0A%20%20%20%20param%20consumptionPlanId%20string%0A%20%20%20%20%0A%20%20%20%20resource%20fncapp%20'Microsoft.Web%2Fsites%402020-12-01'%20%3D%20%7B%0A%20%20%20%20%20%20name%3A%20resourceName%0A%20%20%20%20%20%20location%3A%20location%0A%20%20%20%20%20%20...%0A%20%20%20%20%20%20properties%3A%20%7B%0A%20%20%20%20%20%20%20%20serverFarmId%3A%20consumptionPlanId%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%20%20%20%20siteConfig%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20appSettings%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20'AzureWebJobsStorage'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20value%3A%20'DefaultEndpointsProtocol%3Dhttps%3BAccountName%3D%24%7BstorageAccountName%7D%3BEndpointSuffix%3D%24%7Benvironment().suffixes.storage%7D%3BAccountKey%3D%24%7BlistKeys(storageAccountId%2C%20'2021-02-01').keys%5B0%5D.value%7D'%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20...%0A%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20output%20id%20string%20%3D%20fncapp.id%0A%20%20%20%20output%20name%20string%20%3D%20fncapp.name%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1376847398%22%20id%3D%22toc-hId--1376847398%22%3EModules%20Orchestration%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere's%20the%20orchestration%20bicep%20file%20to%20combine%20modules.%20All%20you%20need%20to%20do%20is%20to%20declare%20a%20module%2C%20refer%20to%20the%20module%20location%20and%20pass%20parameters.%20Based%20on%20the%20references%20between%20modules%2C%20dependencies%20are%20automatically%20calculated.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20azuredeploy.bicep%0A%20%20%20%20param%20resourceName%20string%0A%20%20%20%20param%20location%20string%20%3D%20resourceGroup().location%0A%20%20%20%20%0A%20%20%20%20module%20st%20'.%2Fstorage-account.bicep'%20%3D%20%7B%0A%20%20%20%20%20%20name%3A%20'StorageAccountProvisioning'%0A%20%20%20%20%20%20params%3A%20%7B%0A%20%20%20%20%20%20%20%20name%3A%20resourceName%0A%20%20%20%20%20%20%20%20location%3A%20location%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20module%20csplan%20'.%2Fconsumption-plan.bicep'%20%3D%20%7B%0A%20%20%20%20%20%20name%3A%20'ConsumptionPlanProvisioning'%0A%20%20%20%20%20%20params%3A%20%7B%0A%20%20%20%20%20%20%20%20name%3A%20resourceName%0A%20%20%20%20%20%20%20%20location%3A%20location%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20module%20fncapp%20'.%2Ffunction-app.bicep'%20%3D%20%7B%0A%20%20%20%20%20%20name%3A%20'FunctionAppProvisioning'%0A%20%20%20%20%20%20params%3A%20%7B%0A%20%20%20%20%20%20%20%20name%3A%20resourceName%0A%20%20%20%20%20%20%20%20location%3A%20location%0A%20%20%20%20%20%20%20%20storageAccountId%3A%20st.outputs.id%0A%20%20%20%20%20%20%20%20storageAccountName%3A%20st.outputs.name%0A%20%20%20%20%20%20%20%20consumptionPlanId%3A%20csplan.outputs.id%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20Unfortunately%2C%20as%20of%20this%20writing%2C%20referencing%20to%20external%20URL%20is%20not%20supported%20yet%2C%20unlike%20linked%20ARM%20templates.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20far%2C%20we've%20briefly%20looked%20at%20the%20new%20features%20of%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fbicep%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EProject%20Bicep%3C%2FA%3E.%20As%20Bicep%20is%20one%20of%20the%20most%20rapidly%20growing%20toolsets%20in%20Azure%2C%20keep%20using%20it%20for%20your%20resource%20management.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3EThis%20article%20was%20originally%20published%20on%20%3CA%20href%3D%22https%3A%2F%2Fdevkimchi.com%2F2021%2F04%2F21%2Fbicep-refreshed%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EDev%20Kimchi%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2282165%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22bicep-sneak-peek-00.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F216461i451A636931BC473E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22bicep-sneak-peek-00.png%22%20alt%3D%22bicep-sneak-peek-00.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20post%20refreshes%20the%20new%20features%20of%20Azure%20Bicep%20since%20the%20last%20update.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2282165%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Resource%20Manager%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDevOps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 22 2021 10:24 PM
Updated by: