{"id":13775287,"url":"https://github.com/johnlokerse/azure-bicep-cheat-sheet","last_synced_at":"2025-05-11T07:32:22.831Z","repository":{"id":215851038,"uuid":"705228806","full_name":"johnlokerse/azure-bicep-cheat-sheet","owner":"johnlokerse","description":"Quick-reference guide on Azure Bicep 💪🏻","archived":false,"fork":false,"pushed_at":"2024-05-29T06:38:22.000Z","size":55,"stargazers_count":98,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-08-03T17:11:21.144Z","etag":null,"topics":["azure","azure-resource-manager","bicep","cheat-sheet","cheat-sheets","cheatsheet","community","infrastructure-as-code","microsoft-azure"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnlokerse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-15T12:30:11.000Z","updated_at":"2024-07-09T16:00:43.000Z","dependencies_parsed_at":"2024-01-17T16:59:08.407Z","dependency_job_id":"07b134e6-15a7-4589-9613-cca0cf6ccbaa","html_url":"https://github.com/johnlokerse/azure-bicep-cheat-sheet","commit_stats":null,"previous_names":["johnlokerse/azure-bicep-cheat-sheet"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlokerse%2Fazure-bicep-cheat-sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlokerse%2Fazure-bicep-cheat-sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlokerse%2Fazure-bicep-cheat-sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlokerse%2Fazure-bicep-cheat-sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnlokerse","download_url":"https://codeload.github.com/johnlokerse/azure-bicep-cheat-sheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225027363,"owners_count":17409420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-resource-manager","bicep","cheat-sheet","cheat-sheets","cheatsheet","community","infrastructure-as-code","microsoft-azure"],"created_at":"2024-08-03T17:01:36.414Z","updated_at":"2025-05-11T07:32:22.813Z","avatar_url":"https://github.com/johnlokerse.png","language":null,"funding_links":[],"categories":["Community"],"sub_categories":["Community Repositories"],"readme":"# Azure Bicep Cheat Sheet\n\nAzure Bicep has become my preferred tool for writing infrastructure-as-code for Azure, thanks to its modularity and effortless adaptability. This repository serves as a handy cheat sheet, offering code snippets and references for Azure Bicep.\n\n\u003e [!NOTE]\n\u003e Community contributions are welcome :-)! If you have content that you want to add, please add it to the cheat sheet using a pull request.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/AzureBicepCheatSheetHeader.png\"\u003e\n\u003c/p\u003e\n\n## What is a cheat sheet?\n\nA cheat sheet is a concise set of notes or a reference guide used for quick retrieval of essential information. It's often a single page that contains summaries, commands, formulas, or procedures that someone might need to reference frequently, especially when learning a new topic or skill.\n\n## What is Azure Bicep?\n\nAzure Bicep is a domain-specific language (also known as DSL) designed by Microsoft for defining and deploying Azure resources in a declarative manner. It's the next generation of Azure Resource Manager (ARM) templates, offering a cleaner syntax, improved type safety, and better support for modularization. While ARM templates use JSON syntax, Bicep uses a more concise syntax that aims to make it easier for developers to author and maintain Azure deployments.\n\n## Topics\n\n\u003e [!NOTE]\n\u003e Click the arrow next to a topic to expand its content.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eBasics\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eDeclarations of new and existing resources, variables, parameters and outputs, etcetera.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n### Create a resource\n\n[GitHub Copilot Prompt - Learn more on resource creation](https://github.com/copilot?prompt=how%20to%20define%20a%20resource%20in%20azure%20bicep)\n\nhow to define a resource in azure bicep\n\n```bicep\nresource resourceName 'ResourceType@version' = {\n  name: 'exampleResourceName'\n  properties: {\n    // resource properties here\n  }\n}\n```\n\n### Create a child resource\n\n[GitHub Copilot Prompt - Learn more about creating child resources](https://github.com/copilot?prompt=Can%20you%20explain%20the%20differences%20between%20creating%20child%20resources%20in%20Azure%20Bicep%20using%20a%20name%20property,%20using%20a%20parent%20property,%20and%20nesting%20them%20within%20a%20parent%20resource%20block?%20Please%20include%20examples%20and%20clarify%20when%20to%20use%20each%20approach.)\n\n#### Via name\n\n```bicep\nresource resVnet 'Microsoft.Network/virtualNetworks@2022-01-01' = {\n  name: 'my-vnet'\n}\n\nresource resChildSubnet 'Microsoft.Network/virtualNetworks/subnets@2022-01-01' = {\n  name: '${resVnet}/my-subnet'\n}\n```\n\n#### Via parent property\n\n```bicep\nresource resVnet 'Microsoft.Network/virtualNetworks@2022-01-01' = {\n  name: 'my-vnet'\n}\n\nresource resChildSubnet 'Microsoft.Network/virtualNetworks/subnets@2022-01-01' = {\n  name: 'my-subnet'\n  parent: resVnet\n}\n```\n\n#### Via parent resource\n\n```bicep\nresource resVnet 'Microsoft.Network/virtualNetworks@2022-01-01' = {\n  name: 'my-vnet'\n\n  resource resChildSubnet 'subnets' = {\n    name: 'my-subnet'\n  }\n}\n```\n\n### Reference to an existing resource\n\n```bicep\nresource resKeyVaultRef 'Microsoft.KeyVault/vaults@2019-09-01' = existing {\n  name: 'myExistingKeyVaultName'\n}\n```\n\n### Access a nested resource (::)\n\n```bicep\nresource resVnet 'Microsoft.Network/virtualNetworks@2022-01-01' existing = {\n  name: 'my-vnet'\n  resource resChildSubnet 'subnets' existing = {\n    name: 'my-subnet'\n  }\n}\n\n// access child resource\noutput outChildSubnetId string = resVnet::resChildSubnet.id\n```\n\n### Declare a variable\n\n```bicep\nvar varEnvironment = 'dev'\n```\n\nThere is no need to declare a datatype for a variable, because the type is inferred from the value.\n\n### Declare a parameter\n\n```bicep\nparam parStorageAccountName string\nparam parLocation string = resourceGroup().location\n```\n\nAvailable datatypes are: `string`, `bool`, `int`, `object`, `array` and `custom (user defined type)`.\n\n### Declare a secure parameter\n\n```bicep\n@secure()\nparam parSecureParameter string\n```\n\n### Declare an output\n\n```bicep\nresource resPublicIp 'Microsoft.Network/publicIPAddresses@2023-02-01' ={\n  name: parPublicIpName\n  tags: parTags\n  location: parLocation\n  zones: parAvailabilityZones\n  sku: parPublicIpSku\n  properties: parPublicIpProperties\n}\n\noutput outPublicIpId string = resPublicIp.id\noutput outMyString string = 'Hello!'\n```\n\nAvailable datatypes are: `string`, `bool`, `int`, `object`, `array` and `custom (user defined type)`.\n\n### String interpolation\n\n```bicep\nvar varGreeting = 'Hello'\noutput outResult string = '${varGreeting} World'\n```\n\n### Multi-line strings\n\n```bicep\nvar varMultiLineString = '''\n  This is a\n  Muli-line string\n  variable.\n'''\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eModules\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eSplit your deployment into smaller, reusable components.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n### Create a module\n\n[GitHub Copilot Prompt](https://github.com/copilot?prompt=Can%20you%20explain%20what%20Azure%20Bicep%20modules%20are%20and%20how%20they%20work?%20Also,%20how%20can%20you%20reference%20a%20module%20stored%20in%20an%20external%20Azure%20Container%20Registry%20(ACR)?)\n\n```bicep\nmodule modVirtualNetwork './network.bicep' = {\n  name: 'networkModule'\n  params: {\n    parLocation: 'westeurope'\n    parVnetName: 'my-vnet-name'\n  }\n}\n```\n\n### Reference to a module using a bicep registry\n\n```bicep\nmodule modBicepRegistryReference 'br/\u003cbicep registry name\u003e:\u003cfile path\u003e:\u003ctag\u003e' = {\n  name: 'deployment-name'\n  params: {}\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eConditions\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eResource definitions based on conditions.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about conditions](https://github.com/copilot?prompt=How%20do%20conditions%20work%20in%20Azure%20Bicep?%20Can%20you%20explain%20it%20in%20detail%20and%20provide%20examples%20of%20how%20to%20use%20conditions%20to%20control%20resource%20deployment%20or%20property%20values?)\n\n### If condition\n\n```bicep\nparam parDeployResource bool\n\nresource resDnsZone 'Microsoft.Network/dnszones@2018-05-01' = if (parDeployResource) {\n  name: 'myZone'\n  location: 'global'\n}\n```\n\n### Ternary if/else condition\n\n```bicep\nparam parEnvironment string\n\nvar varSku = parEnvironment == 'prod' ? 'premium' : 'standard'\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eLoops\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eLoop constructions.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about loops](https://github.com/copilot?prompt=How%20do%20you%20create%20loops%20in%20Azure%20Bicep?%20Can%20you%20show%20examples%20using%20the%20for%20keyword%20to%20deploy%20multiple%20resources%20or%20set%20values%20in%20an%20array?)\n\n### foreach using an array\n\n```bicep\nparam parStorageAccountNames array = [\n  'storageaccount1'\n  'storageaccount2'\n  'storageaccount3'\n]\n\nresource resStorageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = [for name in parStorageAccountNames: {\n  name: name\n  location: 'westeurope'\n  kind: 'StorageV2'\n  sku: {\n    name: 'Standard_LRS'\n  }\n}]\n```\n\n### foreach using an array of objects\n\n``` bicep\nparam parStorageAccountNames array = [\n  {\n    name: 'storageaccount1'\n    kind: 'StorageV2'\n    sku: {\n      name: 'Standard_LRS'\n    }\n  }\n  {\n    name: 'storageaccount2'\n    kind: 'StorageV2'\n    sku: {\n      name: 'Standard_LRS'\n    }\n  }\n]\n\nresource resStorageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = [for storageAccount in parStorageAccountNames: {\n  name: storageAccount.name\n  location: 'westeurope'\n  kind: storageAccount.kind\n  sku: {\n    name: storageAccount.sku\n  }\n}]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eData manipulation\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eFunctions used to manipulate data.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about lambda functions](https://github.com/copilot?prompt=In%20Azure%20Bicep,%20how%20do%20the%20filter(),%20map(),%20and%20sort()%20functions%20work?%20Can%20you%20explain%20each%20function%20in%20detail%20and%20show%20how%20they%E2%80%99re%20used%20in%20practice?%20For%20example:%20%E2%80%A2output%20outProducts%20array%20=%20filter(varGroceryStore,%20item%20=%3E%20item.productPrice%20%3E=%204)%20%E2%80%A2output%20outDiscount%20array%20=%20map(range(0,%20length(varGroceryStore)),%20item%20=%3E%20{%20productNumber:%20item,%20productName:%20varGroceryStore[item].productName,%20discountedPrice:%20%27The%20item%20${varGroceryStore[item].productName}%20is%20on%20sale.%20Sale%20price:%20${(varGroceryStore[item].productPrice%20/%202)}%27%20})%20%E2%80%A2output%20outUsingSort%20array%20=%20sort(varGroceryStore,%20(a,%20b)%20=%3E%20a.productPrice%20%3C=%20b.productPrice)%20Please%20walk%20through%20what%20each%20of%20these%20functions%20does%20and%20when%20to%20use%20them)\n\n### Example data\n\n```bicep\nvar varGroceryStore = [\n  {\n    productName: 'Icecream'\n    productPrice: 2\n    productCharacteristics: [\n      'Vegan'\n      'Seasonal'\n    ]\n  }\n  {\n    productName: 'Banana'\n    productPrice: 4\n    productCharacteristics: [\n      'Bio'\n    ]\n  }\n]\n```\n\n### filter() function\n\n```bicep\n  output outProducts array = filter(varGroceryStore, item =\u003e item.productPrice \u003e= 4)\n```\n\n#### returns\n\n```json\n[\n  {\n    \"productName\": \"Banana\",\n    \"productPrice\": 4,\n    \"productCharacteristics\": [\n      \"Bio\"\n    ]\n  }\n]\n```\n\n### map() function\n\n```bicep\noutput outDiscount array = map(range(0, length(varGroceryStore)), item =\u003e {\n  productNumber: item\n  productName: varGroceryStore[item].productName\n  discountedPrice: 'The item ${varGroceryStore[item].productName} is on sale. Sale price: ${(varGroceryStore[item].productPrice / 2)}'\n})\n```\n\n#### returns\n\n```json\n[\n  {\n    \"productNumber\": 0,\n    \"productName\": \"Icecream\",\n    \"discountedPrice\": \"The item Icecream is on sale. Sale price: 1\"\n  },\n  {\n    \"productNumber\": 1,\n    \"productName\": \"Banana\",\n    \"discountedPrice\": \"The item Banana is on sale. Sale price: 2\"\n  }\n]\n```\n\n### sort() function\n\n```bicep\noutput outUsingSort array = sort(varGroceryStore, (a, b) =\u003e a.productPrice \u003c= b.productPrice)\n```\n\n#### returns\n\n```json\n[\n  {\n    \"productName\": \"Icecream\",\n    \"productPrice\": 2,\n    \"productCharacteristics\": [\n      \"Vegan\"\n      \"Seasonal\"\n    ]\n  },\n  {\n    \"productName\": \"Banana\",\n    \"productPrice\": 4,\n    \"productCharacteristics\": [\n      \"Bio\"\n    ]\n  }\n]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eUser Defined Types\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eDefine custom complex data structures.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more on User Defined Types](https://github.com/copilot?prompt=Can%20you%20explain%20in%20detail%20how%20User%20Defined%20Types%20work%20in%20Azure%20Bicep?%20Please%20include%20examples%20of%20defining%20custom%20object%20types,%20including%20how%20to%20structure%20them%20and%20how%20to%20define%20optional%20properties.%20Optional%20properties%20should%20be%20defined%20using%20a%20?%20at%20the%20type%20level%20(e.g.,%20type%20Bla%20=%20{%20name:%20string?%20}).%20Also%20include%20examples%20of%20arrays%20of%20objects%20with%20optional%20properties,%20such%20as:type%20arrayWithObjectsType%20=%20{%20name:%20string%20age:%20int%20hasChildren:%20bool?%20hasPets:%20bool?%20}[])\n\n### Primitive types\n\n```bicep\n// a string type with two allowed strings ('Standard_LRS' or 'Standard_GRS')\ntype skuType = 'Standard_LRS' | 'Standard_GRS'\n\n// an integer type with one allowed value (1337)\ntype integerType = 1337\n\n// an boolean type with one allowed value (true)\ntype booleanType = true\n\n// Reference the type\nparam parMyStringType skuType\nparam parMyIntType integerType\nparam parMyBoolType booleanType\n```\n\n### A custom type that enforced an array with a specific object structure\n\n```bicep\ntype arrayWithObjectsType = {\n  name: string\n  age: int\n}[]\n\nparam parCustomArray arrayWithObjectsType = [\n  {\n    name: 'John'\n    age: 30\n  }\n]\n```\n\n### Optional properties in objects (using ?)\n\n```bicep\ntype arrayWithObjectsType = {\n  name: string\n  age: int\n  hasChildren: bool?\n  hasPets: bool?\n}[]\n\nparam parCustomArray arrayWithObjectsType = [\n  {\n    name: 'John'\n    age: 30\n  }\n  {\n    name: 'Jane'\n    age: 31\n    hasPets: true\n  }\n  {\n    name: 'Jack'\n    age: 45\n    hasChildren: true\n    hasPets: true\n  }\n]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eUser Defined Functions\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eDefine custom complex expressions.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about User Defined Functions](https://github.com/copilot?prompt=Can%20you%20explain%20in%20detail%20how%20User%20Defined%20Functions%20work%20in%20Azure%20Bicep?%20Please%20include%20examples%20that%20show%20how%20to%20define%20and%20use%20custom%20functions,%20including%20parameter%20definitions,%20return%20types,%20and%20function%20logic.%20Also%20include%20a%20simple%20example%20such%20as:func%20funcSayHelloTo()%20string%20=%3E%20%27Hello%20and%20welcome,%20John%20Doe%27%20output%20outName%20string%20=%20funcSayHelloTo()%20/*%20Outputs:%20%27Hello%20and%20welcome,%20John%20Doe%27%20*/)\n\n### User-defined function syntax\n\n```func \u003cfunction-name\u003e (\u003cparameter-name\u003e \u003cdata-type\u003e) \u003creturn-type\u003e =\u003e \u003cexpression\u003e```\n\n### Basic user-defined function\n\n```bicep\nfunc funcSayHelloTo() string =\u003e 'Hello and welcome, John Doe'\n```\n\n### User-defined function with parameters\n\n```bicep\nfunc funcSayHelloTo(name string) string =\u003e 'Hello and welcome, ${name}'\n```\n\nWith multiple parameters:\n\n```bicep\nfunc funcPersonNameAndAge(name string, age int) string =\u003e 'My name is ${name} and my age is ${age}'\n```\n\n### User-defined function return types\n\n```bicep\nfunc funcReturnTypeArray() array =\u003e [1, 2, 3, 4, 5]\nfunc funcReturnTypeObject() object =\u003e {name: 'John Doe', age: 31}\nfunc funcReturnTypeInt() int =\u003e 1337\nfunc funcReturnTypeBool(key string) bool =\u003e contains({}, key)\nfunc funcReturnTypeUserDefinedType() customTypeUsedAsReturnType =\u003e {\n  hello: 'world'\n}\n\ntype customTypeUsedAsReturnType = {\n  hello: string\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eCompile-time imports\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eImport and export() enable reuse of user-defined types variables, functions.\u003cbr\u003eSupported in Bicep and Bicepparam files.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - learn more about compile-time imports](https://github.com/copilot?prompt=Show%20me%20how%20to%20use%20export%20and%20import%20in%20Azure%20Bicep%20to%20reuse%20a%20storage%20account%20resource%20across%20multiple%20Bicep%20files.)\n\n### export() decorator (shared.bicep)\n\n```bicep\n@export()\nvar region = 'we'\n\n@export()\ntype tagsType = {\n  Environment: 'Prod' | 'Dev' | 'QA' | 'Stage' | 'Test'\n  CostCenter: string\n  Owner: string\n  BusinessUnit: string\n  *: string\n}\n```\n\n### import statement\n\n```bicep\nimport { region, tagsType } from 'shared.bicep'\n\noutput outRegion string = region\noutput outTags tagsType = {\n  Environment: 'Dev'\n  CostCenter: '12345'\n  BusinessUnit: 'IT'\n  Owner: 'John Lokerse'\n}\n```\n\n### import statement with alias\n\n```bicep\nusing 'keyVault.bicep'\nimport { region as importRegion } from 'shared.bicep'\n\nparam parKeyVaultName = 'kv-${importRegion}-${uniqueString(importRegion)}'\n```\n\n### import statement using a wildcard\n\n```bicep\nimport * as shared from 'shared.bicep'\n\noutput outRegion string = shared.region\noutput outTags shared.tagsType = {\n  Environment: 'Dev'\n  CostCenter: '12345'\n  BusinessUnit: 'IT'\n  Owner: 'John Lokerse'\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eNetworking\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eCIDR functions to make subnetting easier.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - learn more about the networking functions](https://github.com/copilot?prompt=Can%20you%20explain%20how%20to%20use%20CIDR%20functions%20in%20Azure%20Bicep%20to%20make%20subnetting%20easier?%20Show%20how%20functions%20like%20cidrSubnet(),%20cidrHost()%20and%20others%20help%20to%20calculate%20subnet%20ranges,%20addresses,%20or%20specific%20IPs%20based%20on%20a%20base%20CIDR%20block.%20Include%20practical%20examples%20such%20as%20splitting%20a%20/16%20address%20space%20into%20multiple%20/24%20subnets.)\n\n### parseCidr() function\n\n```bicep\noutput outParseCidrInformation object = parseCidr('192.168.1.0/24')\n```\n\n#### returns\n\n```json\n\"outParseCidrInformation\": {\n  \"type\": \"Object\",\n  \"value\": {\n    \"broadcast\": \"192.168.1.255\",\n    \"cidr\": 24,\n    \"firstUsable\": \"192.168.1.1\",\n    \"lastUsable\": \"192.168.1.254\",\n    \"netmask\": \"255.255.255.0\",\n    \"network\": \"192.168.1.0\"\n  }\n}\n```\n\n### cidrSubnet() function\n\n```bicep\noutput outCidrSubnet string = cidrSubnet('192.168.1.0/24', 25, 0)\n```\n\n#### returns\n\n```json\n\"outCidrSubnet\": {\n  \"type\": \"String\",\n  \"value\": \"192.168.1.0/25\"\n}\n```\n\n### cidrHost() function\n\n```bicep\noutput outCidrHost array = [for i in range(0, 10): cidrHost('192.168.1.0/24', i)]\n```\n\n#### returns\n\n```json\n\"outCidrHost\": {\n  \"type\": \"Array\",\n  \"value\": [\n    \"192.168.1.1\",\n    \"192.168.1.2\",\n    \"192.168.1.3\",\n    \"192.168.1.4\",\n    \"192.168.1.5\",\n    \"192.168.1.6\",\n    \"192.168.1.7\",\n    \"192.168.1.8\",\n    \"192.168.1.9\",\n    \"192.168.1.10\"\n  ]\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eBicepconfig\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eCustomize your Bicep development experience.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about bicepconfig.json](https://github.com/copilot?prompt=Tell%20me%20more%20about%20the%20bicepconfig.json%20in%20Azure%20Bicep.%20What%20does%20it%20do%20and%20why%20do%20I%20need%20it?)\n\n### Azure Container Registry configuration\n\n```json\n{\n  \"moduleAliases\": {\n    \"br\": {\n      \"\u003cbicep registry name\u003e\": {\n        \"registry\": \"\u003curl to registry\u003e\",\n        \"modulePath\": \"\u003cmodule path of the alias\u003e\"\n      }\n    }\n  }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eDependencies\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eImplicit and explicit dependencies.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - learn more about dependencies](https://github.com/copilot?prompt=How%20do%20dependencies%20work%20in%20Azure%20Bicep?%20Explain%20it%20to%20me%20in%20detail%20and%20add%20examples.)\n\n### Implicit dependency using symbolic name\n\n```bicep\nresource resNetworkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2019-11-01' = {\n  name: 'my-networkSecurityGroup'\n  location: resourceGroup().location\n}\n\nresource nsgRule 'Microsoft.Network/networkSecurityGroups/securityRules@2019-11-01' = {\n  name: '${resNetworkSecurityGroup}/AllowAllRule'\n  properties: {\n    // resource properties here\n  }\n}\n```\n\n### Explicit dependency using dependsOn\n\n```bicep\nresource resDnsZone 'Microsoft.Network/dnsZones@2018-05-01' = {\n  name: 'contoso.com'\n  location: 'global'\n}\n\nmodule modVirtualNetwork './network.bicep' = {\n  name: 'networkModule'\n  params: {\n    parLocation: 'westeurope'\n    parVnetName: 'my-vnet-name'\n  }\n  dependsOn: [\n    resDnsZone\n  ]\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eDeployment\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eOrchestration commands to deploy Azure Bicep to your Azure Environment.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n### Azure CLI\n\n| Scope           | Command                                                                                                                             |\n| --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| resourceGroup   | `az deployment group create --resource-group ResourceGroupName --template-file template.bicep --parameters parameters.bicepparam`   |\n| subscription    | `az deployment sub create --location location --template-file template.bicep --parameters parameters.bicepparam`                    |\n| managementGroup | `az deployment mg create --management-group-id ManagementGroupId --template-file template.bicep --parameters parameters.bicepparam` |\n| tenant          | `az deployment tenant create --location location --template-file template.bicep --parameters parameters.bicepparam`                 |\n\n### Azure PowerShell\n\n| Scope           | Command                                                                                                                                                                     |\n| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| resourceGroup   | `New-AzResourceGroupDeployment -ResourceGroupName \"ResourceGroupName\" -TemplateFile \"template.bicep\" -TemplateParameterFile \"parameters.bicepparam`                         |\n| subscription    | `New-AzDeployment -Location \"Location\" -TemplateFile \"template.bicep\" -TemplateParameterFile \"parameters.bicepparam\"`                                                       |\n| managementGroup | `New-AzManagementGroupDeployment -ManagementGroupId \"ManagementGroupId\" -Location \"location\" -TemplateFile \"template.bicep\" -TemplateParameterFile \"parameters.bicepparam\"` |\n| tenant          | `New-AzTenantDeployment -Location \"Location\" -TemplateFile \"template.bicep\" -TemplateParameterFile \"parameters.bicepparam\"`                                                 |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eTarget Scopes\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eDeployment scope definitions.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about target scopes](https://github.com/copilot?prompt=What%20are%20target%20scopes%20in%20Azure%20Bicep%20when%20deploying%20to%20Azure?)\n\n### Target scopes\n\nThe `targetScope` directive in Azure Bicep determines the level at which the Bicep template will be deployed within Azure. The default is `targetScope = 'resourceGroup'`.\n\nAzure Bicep supports multiple levels of `targetScope`:\n\n| Scope           | Description                                                                                                              |\n| --------------- | ------------------------------------------------------------------------------------------------------------------------ |\n| resourceGroup   | The Bicep file is intended to be deployed at the Resource Group level.                                                   |\n| subscription    | The Bicep file targets a Subscription, allowing you to manage resources or configurations across an entire subscription. |\n| managementGroup | For managing resources or configurations across multiple subscriptions under a specific Management Group.                |\n| tenant          | The highest scope, targeting the entire Azure tenant. This is useful for certain global resources or policies.           |\n\n```bicep\ntargetScope = 'resourceGroup'\n\nresource resKeyVault 'Microsoft.KeyVault/vaults@2019-09-01' = {\n  // key vault properties here\n}\n```\n\nUse the scope property on modules to deploy on a different scope than the target scope:\n\n```bicep\n// Uses the targetScope\nmodule modStorageModule1 'storage.bicep' = {\n  name: 'storageModule1'\n}\n\n// Uses the scope of the module\nmodule modStorageModule2 'storage.bicep' = {\n  name: 'storageModule2'\n  scope: resourceGroup('other-subscription-id', 'other-resource-group-name')\n  // module properties here\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cspan\u003e\u003cb\u003eAzure Verified Modules\u003c/b\u003e\u003c/span\u003e\n    \u003cp\u003e\u003ci\u003eMicrosoft building blocks for Azure Bicep right at your fingertips.\u003c/i\u003e\u003c/p\u003e\n  \u003c/summary\u003e\n\n[GitHub Copilot - Learn more about Azure Verified Modules](https://github.com/copilot?prompt=What%20are%20Azure%20Verified%20Modules%20(https://aka.ms/avm),%20and%20how%20can%20I%20use%20them%20in%20my%20Azure%20Bicep%20files?%20Please%20explain%20their%20purpose,%20benefits,%20and%20show%20an%20example%20of%20how%20to%20reference%20and%20deploy%20a%20verified%20module%20in%20a%20Bicep%20template.)\n\n### Azure Verified Modules reference\n\nWhen you're writing Bicep, you can reference Azure Verified Modules (AVM) directly in your Bicep files. To get access to the IntelliSense prompt, you need the Azure Bicep VSCode extension installed. Additionally, to restore the Bicep modules successfully, make sure you have access to the Microsoft Container Registry at mcr.microsoft.com.\n\nAs an example, here is how to reference to an Azure Key Vault from the Microsoft Container Registry:\n![AVM](images/AVM-KV.gif)\n\nMore information on Azure Verified Modules can be found [here](https://aka.ms/avm).\n\n\u003c/details\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnlokerse%2Fazure-bicep-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnlokerse%2Fazure-bicep-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnlokerse%2Fazure-bicep-cheat-sheet/lists"}