{"id":544,"date":"2021-10-15T00:39:00","date_gmt":"2021-10-15T00:39:00","guid":{"rendered":"https:\/\/thecloudmarathoner.com\/?p=544"},"modified":"2021-10-19T04:04:33","modified_gmt":"2021-10-19T04:04:33","slug":"four-parameterization-options-for-your-azure-bicep-deployments","status":"publish","type":"post","link":"https:\/\/thecloudmarathoner.com\/index.php\/2021\/10\/15\/four-parameterization-options-for-your-azure-bicep-deployments\/","title":{"rendered":"Four parameterization options for your Azure Bicep deployments"},"content":{"rendered":"\n<p>Hello Cloud Marathoners,<\/p>\n\n\n\n<p>In my last posts, I wrote about Azure CL and a Bicep language. The Azure Bicep language, helps to author and manage Azure resources&nbsp;more cleanly and easily on your Azure subscription.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" src=\"\/wp-content\/uploads\/2021\/10\/image-3-1024x573.png\" alt=\"\" class=\"wp-image-601\" srcset=\"\/wp-content\/uploads\/2021\/10\/image-3-1024x573.png 1024w, \/wp-content\/uploads\/2021\/10\/image-3-300x168.png 300w, \/wp-content\/uploads\/2021\/10\/image-3-768x430.png 768w, \/wp-content\/uploads\/2021\/10\/image-3-1200x672.png 1200w, \/wp-content\/uploads\/2021\/10\/image-3.png 1454w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><br>The parameterization of infrastructure deployment files is an important skill where true power of automation and code reuse comes forward.<br>Let&#8217;s learn about different parameterization options that you could use in your Azure Bicep deployments. As an example, we will examine the following parameterization options on an Azure Bicep web app deployment file.<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u2714\ufe0f  Using Bicep file as is<\/p><p>\u2714\ufe0f Using default parameters on your bicep file<\/p><p>\u2714\ufe0f Simply adding parameters into your command line<\/p><p>\u2714\ufe0f Using a separate file for parameters, per environment<\/p><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">Option 1: <span style=\"font-size: revert;\">Using Bicep file as is<\/span> <\/h3>\n\n\n\n<p>This first option is the most straightforward way to declare your parameters. However, you would have to enter each parameter name, every time you are deploying the Azure resources.<\/p>\n\n\n\n<p>Following screenshot is a default Bicep web app declaration with parameters. Check the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/ElYusubov\/Learn-Bicep\/tree\/main\/param-files\" target=\"_blank\">Learn Bicep repo here<\/a> \ud83d\udc4d<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"870\" src=\"\/wp-content\/uploads\/2021\/10\/image-1024x870.png\" alt=\"\" class=\"wp-image-580\" srcset=\"\/wp-content\/uploads\/2021\/10\/image-1024x870.png 1024w, \/wp-content\/uploads\/2021\/10\/image-300x255.png 300w, \/wp-content\/uploads\/2021\/10\/image-768x652.png 768w, \/wp-content\/uploads\/2021\/10\/image.png 1034w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><br>Now, let&#8217;s declare an Azure CLI command that will deploy our Azure Bicep file into a Resource group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Create a rg-test-deploy RG\naz group create -l eastus -g 'rg-test-deploy'\n\n# Option-1: Run deployment file as is\naz deployment group create -g 'rg-test-deploy' -f .\\param-files\\webapp-service-w-param.bicep\n\n# List all webapps in the subscription\naz webapp list --query &#91;].name -o table<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Option 2: <span style=\"font-size: revert;\">Using default parameters on your bicep files<\/span> <\/h3>\n\n\n\n<p>The second option will allow us to deploy our Bicep file without entering the default values each time. However, it would require an update on file each time you want to change parameter values \ud83d\ude22<\/p>\n\n\n\n<p>Now, we can take the previous webapp-service Bicep file, and add its default values. The updated Bicep file will look like the following screenshot:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"839\" src=\"\/wp-content\/uploads\/2021\/10\/image-1-1024x839.png\" alt=\"\" class=\"wp-image-582\" srcset=\"\/wp-content\/uploads\/2021\/10\/image-1-1024x839.png 1024w, \/wp-content\/uploads\/2021\/10\/image-1-300x246.png 300w, \/wp-content\/uploads\/2021\/10\/image-1-768x629.png 768w, \/wp-content\/uploads\/2021\/10\/image-1.png 1061w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><br>Our Azure CLI deployment script would just get a new file name<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Option-2: Run deployment with default values\naz deployment group create -g 'rg-test-deploy' -f .\\param-files\\webapp-service-default-param.bicep\n\n# You could also add preflight check with \"-c\" at the end of each deployment script<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Option 3: Simply adding parameters into your command line script<\/h3>\n\n\n\n<p>If you would prefer to type parameters and values on a terminal then third option can deliver it for you. That script will look like the following sample: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Option-3: Run deployment with inline parameters\naz deployment group create -g 'rg-test-deploy' -f .\\param-files\\webapp-service-w-param.bicep -p location='eastus' appServiceAppName='param-demoapp18' appServicePlanName='asp-param-demo'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Option 4: <span style=\"font-size: revert;\">Using a separate file for parameters<\/span>, per environment<\/h3>\n\n\n\n<p>The last option has multiple advantages over prior options. As you could create separate environment parameters in their own dedicated files and manage them accordingly. <br>For example: You can create a separate param file for <strong>&#8220;Dev&#8221; <\/strong>environment deployments; like in the following screenshot.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"433\" src=\"\/wp-content\/uploads\/2021\/10\/image-2-1024x433.png\" alt=\"\" class=\"wp-image-583\" srcset=\"\/wp-content\/uploads\/2021\/10\/image-2-1024x433.png 1024w, \/wp-content\/uploads\/2021\/10\/image-2-300x127.png 300w, \/wp-content\/uploads\/2021\/10\/image-2-768x325.png 768w, \/wp-content\/uploads\/2021\/10\/image-2-1200x507.png 1200w, \/wp-content\/uploads\/2021\/10\/image-2.png 1318w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><strong>Note:<\/strong> parameter files for Bicep language are using a JSON notation, similar to the way how ARM JSON declares parameter files with a following schema.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"https:\/\/schema.management.azure.com\/schemas\/2019-04-01\/deploymentParameters.json#\"<\/code><\/pre>\n\n\n\n<p>And our deployment script will look like the following sample:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Option-4: Run deployment with a separate parameter file\naz deployment group create -g 'rg-test-deploy' -f .\\param-files\\webapp-service-w-param.bicep -p .\\param-files\\webapp-service-parameters-dev.json\n\n# List all webapps in the subscription\naz webapp list --query &#91;].name -o table\n\n# Clean all resources from RG\naz group delete -n 'rg-test-deploy' --yes<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Summary<\/h3>\n\n\n\n<p>Thank you  \ud83d\ude4f  for reading this post and learning about four different options to deploy your Azure Bicep files using Azure CLI. <\/p>\n\n\n\n<p>Please check out the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/ElYusubov\/Learn-Bicep\" target=\"_blank\">Learn Bicep<\/a> GitHub repo, and follow it. <br>Thanks \ud83d\ude4f \ud83d\ude4c !<\/p>\n\n\n\n<p>Stay tuned for more Azure automation &amp; Azure Bicep posts.<\/p>\n\n\n\n<p>F\u1d0f\u029f\u029f\u1d0f\u1d21 \u1d0d\u1d07 \ud83c\udfaf \u1d00\u0274\u1d05 become \u1d00&nbsp;<a href=\"https:\/\/www.linkedin.com\/feed\/hashtag\/?keywords=cloudmarathoner&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A6831288713784410112\">#cloudmarathoner<\/a>&nbsp;\u26c5\ud83c\udfc3\u200d\u2642\ufe0f\ud83c\udfc3\u200d\u2640\ufe0f &#8211; \ud835\udc0b\ud835\udc04\ud835\udc13&#8217;\ud835\udc12 \ud835\udc02\ud835\udc0e\ud835\udc0d\ud835\udc0d\ud835\udc04\ud835\udc02\ud835\udc13 \ud83d\udc4d<\/p>\n<div class=\"pvc_clear\"><\/div><p id=\"pvc_stats_544\" class=\"pvc_stats all  \" data-element-id=\"544\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p><div class=\"pvc_clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Hello Cloud Marathoners, In my last posts, I wrote about Azure CL and a Bicep language. The Azure Bicep language, helps to author and manage Azure resources&nbsp;more cleanly and easily on your Azure subscription. The parameterization of infrastructure deployment files is an important skill where true power of automation and code reuse comes forward.Let&#8217;s learn &hellip; <a href=\"https:\/\/thecloudmarathoner.com\/index.php\/2021\/10\/15\/four-parameterization-options-for-your-azure-bicep-deployments\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Four parameterization options for your Azure Bicep deployments&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,4,2,18],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-azure-bicep","category-azure-devops","category-infrastructure-as-code-iac","category-azure"],"_links":{"self":[{"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":19,"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/posts\/544\/revisions"}],"predecessor-version":[{"id":605,"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/posts\/544\/revisions\/605"}],"wp:attachment":[{"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/media?parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/categories?post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecloudmarathoner.com\/index.php\/wp-json\/wp\/v2\/tags?post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}