<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://zerohoursleep.net/feed.xml" rel="self" type="application/atom+xml" /><link href="https://zerohoursleep.net/" rel="alternate" type="text/html" /><updated>2025-10-22T09:33:40+00:00</updated><id>https://zerohoursleep.net/feed.xml</id><title type="html">Zero Hour Sleep</title><subtitle>a blog dedicted for sharing my knowledge and experience on azure</subtitle><entry><title type="html">Manually Install Winget on Windows 10</title><link href="https://zerohoursleep.net/2022/01/05/Manually-Install-Winget-on-Windows-10.html" rel="alternate" type="text/html" title="Manually Install Winget on Windows 10" /><published>2022-01-05T00:00:00+00:00</published><updated>2022-01-05T00:00:00+00:00</updated><id>https://zerohoursleep.net/2022/01/05/Manually-Install-Winget-on-Windows-10</id><content type="html" xml:base="https://zerohoursleep.net/2022/01/05/Manually-Install-Winget-on-Windows-10.html"><![CDATA[<h1 id="manually-install-winget-on-windows-10">Manually install winget on windows 10</h1>
<h2 id="introduction">Introduction</h2>

<p>If you are curious like me and eager to get to use the new window package manager, you certainly needed to use winget command line tool</p>

<p>The winget client is the main utility to manage packages on a windows 10 / 11 machines.<br />It is mainly installed as part of the windows app installer which can be directly installed from the windows app store check the following article for details <a href="https://devblogs.microsoft.com/commandline/windows-package-manager-1-0/">https://devblogs.microsoft.com/commandline/windows-package-manager-1-0/</a> .<br /><br />However, in case you are running a device where installing apps from the windows app store is disabled for certain reasons and you still wish to use the winget command line tool, here are the steps that should be followed for you in order to get the winget command line tool installed.</p>

<div style="border: solid; border-color: #e0f2ff; background-color: #e0f2ff; border-radius: 10px; width: 90%; padding: 10px; margin: auto;">
<p style="color: #003a66;" align="center">at this time winget is supported with windows 10 versions (1809) or later</p>
</div>
<h3 id="1-download-the-windows-app-installer">1. Download the windows app installer</h3>
<p>Download the latest release of windows app installer msixbundle available at the following github repo https://github.com/microsoft/winget-cli/releases</p>
<figure class="wp-block-image size-large"><img src="https://i.ibb.co/mX8fMDz/image-1641203235853-0.png" alt="" /><figcaption> image-1641203235853-0.png </figcaption></figure>
<h3 id="2-download-the-latest-c-runtime-desktop-bridge-optional-but-recommended">2. Download the latest c++ runtime desktop bridge (optional but recommended)</h3>
<p>Download the latest c++ runtime desktop bridge package from the following location
https://docs.microsoft.com/en-us/troubleshoot/cpp/c-runtime-packages-desktop-bridge</p>
<div style="border: solid; border-color: #e0f2ff; background-color: #e0f2ff; border-radius: 10px; width: 90%; padding: 10px; margin: auto;">
<p style="color: #003a66;" align="center">make sure to select the package the corresponds to your device architecture</p>
</div>
<h3 id="3-open-powershell-7-and-run-the-following">3. Open powershell 7 and run the following</h3>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">Import-module</span><span class="w"> </span><span class="nx">appx</span><span class="w"> </span><span class="nt">-UseWindowsPowerShell</span><span class="w"> 
</span><span class="n">Add-appxpackage</span><span class="w"> </span><span class="s1">'&lt;pathtodowloadedc++packageName&gt;'</span><span class="w"> 
</span><span class="n">Add-appxpackage</span><span class="w"> </span><span class="s1">'&lt;pathtodownloadedmsixbundleName&gt;'</span></code></pre></figure>

<h3 id="4-verify-successful-installation">4. verify successful installation</h3>
<p>Once you have successfully ran the above mentioned commands you can run the winget command from powershell or cmd to check if it was successfully installed</p>
<figure class="wp-block-image size-large"><img src="https://i.ibb.co/dGkCcpw/image-1641205149293-0.png" alt="" /><figcaption> image-1641205149293-0.png </figcaption></figure>
<h2 id="conclusion">Conclusion</h2>
<p>in this post we saw how to install and use the winget client to install windows applications. By using the windows package manager approach you will be able to manage installations much faster and easier!</p>

<p>Hope you enjoy it :)</p>]]></content><author><name>Charbel Hanna</name></author><summary type="html"><![CDATA[Bypass installations restrictions...]]></summary></entry><entry><title type="html">Azure Bicep - New Generation ARM Templates</title><link href="https://zerohoursleep.net/azure/2021/05/26/Bicep-Deploy-using-modules.html" rel="alternate" type="text/html" title="Azure Bicep - New Generation ARM Templates" /><published>2021-05-26T00:00:00+00:00</published><updated>2021-05-26T00:00:00+00:00</updated><id>https://zerohoursleep.net/azure/2021/05/26/Bicep-Deploy-using-modules</id><content type="html" xml:base="https://zerohoursleep.net/azure/2021/05/26/Bicep-Deploy-using-modules.html"><![CDATA[<h1 id="part-3---azure-bicep---advanced-deployments-with-bicep-modules">Part 3 - Azure Bicep - Advanced Deployments with Bicep Modules</h1>
<p><a href="/azure/2021/04/02/Bicep-Introduction.html">Part 1 - Azure Bicep - Introduction</a><br />
<a href="/azure/2021/04/29/Bicep-Deploy-your-first-code.html">Part 2 - Azure Bicep - Deploy your Fist code</a></p>

<h2 id="introduction">Introduction</h2>

<p>In this part of the Bicep series we will discuss how to perform advanced deployments using Bicep as an Infrastructure As Code DSL language, while shedding the light on Bicep modules.</p>

<h2 id="prerequisites">Prerequisites</h2>

<ul>
  <li>We assume that your development environment is setup for bicep, (if you still did not setup your development environment please follow the instructions mentioned in <a href="/azure/2021/04/02/Bicep-Introduction.html">Part-one</a></li>
  <li>We assume that you have minimum knowledge on how to deploy azure resources using bicep, you can follow the instructions in <a href="/azure/2021/04/29/Bicep-Deploy-your-first-code.html">Part-two</a></li>
</ul>

<h2 id="the-regaton-app">The Regaton App</h2>

<p>Let's consider a scenario where want to programmatically deploy and maintain the below illustrated application  in your azure environment using bicep</p>

<figure class="wp-block-image size-large is-style-default"><img src="https://i.ibb.co/Ltkfhvt/image-1621248001664-0.png" alt="image-1621248001664-0" /></figure>

<h3 id="detailing-the-application-components">Detailing the application components</h3>

<p>As shown in the above diagram our application &quot;Regaton&quot; consists in the following main components:</p>

<ul><li>A Web Application</li><li>An SQL Database</li><li>A storage Account<br />Yes only three Azure services but why consider it as complex ?<br />Actually if we take a deep look we notice the following:</li><li>The resources are distributed between different resource groups, this actually means that our deployment include different targets.</li><li>Azure services like the <strong>Azure SQL Database</strong> and the <strong>Azure Web app</strong>, depends on other type of services such as "<strong>SQL Server</strong>", and "<strong>App service plan</strong>" to be available therefore should also be deployed.</li></ul>

<h2 id="authoring-concept">Authoring concept</h2>

<p>Let's see how we can achieve our required deployment while meeting all the requirements.<br /><br />If we were using ARM templates we would use either nested templates which are child templates that are written in the same template file or linked templates which are ARM templates stored in a remote location ( mainly a storage account) and referenced by their Template Uri in the parent template.<br /><br />When the above options represent a valid solution, however they do also represent many challenges which are not simple to overcome. Fortunately these challenges were eliminated with Bicep modules.</p>

<h3 id="modularization">Modularization</h3>

<p>Bicep allows splitting your deployment code into multiple local bicep files to be consumed as modules in your deployment. We refer to this concept by modularization.<br />Modularization offers many advantages among the below:</p>

<ul><li>The ability of using existing written modules in different deployments while applying minor or i many cases zero changes to the existing code.</li><li>Allows Masking the complex details from the parent bicep files as only parameters and outputs are required to be exposed.</li><li>Most importantly allows targeted deployments to specific scopes (subscription, resource groups)</li></ul>

<h2 id="deployment-code-structure">Deployment code structure</h2>
<p>Inspite of the above mentioned facts our Regaton application deployment code will consists of the following:</p>
<ul><li>A main bicep file that will contain the main code which is responsible of calling multiple modules each module with aim to deploy a set of resources in a target location.</li><li>While multiple parameters files can be used, deployment parameters will be stored in a single file and passed through the main bicep file to all modules.</li></ul>
<figure class="wp-block-image size-large is-style-default"><img src="https://i.ibb.co/FY7Fv5g/image-1621934471120-0.png" alt="image-1621934471120-0" /></figure>

<h2 id="bicep-modules-in-action">Bicep modules in action</h2>

<p>While the complete deployment code of the Regaton application is available for you in the following github repository <a rel="noreferrer noopener" href="https://github.com/CharbelHanna/Azure/tree/main/Bicep/Templates/Regaton" data-type="URL" data-id="https://github.com/CharbelHanna/Azure/tree/main/Bicep/Templates/Regaton" target="_blank">CharbelHanna/Azure/Bicep</a>.  let's start exploring the main bicep file &quot;regaton.bicep&quot; to discuss in details how the different modules are consumed.</p>
<p><a href="https://ibb.co/HtqtjmM"></a></p>
<figure class="wp-block-image size-large is-style-default"><img src="https://i.ibb.co/ZBxB0yw/image-1622021428194-0.png" alt="image-1622021428194-0" /></figure>

<p>Taking a closer look on the selected code, we will notice the following:</p>
<ul><li>To consume a module the following syntax is used</li></ul>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="kr">module</span><span class="w"> </span><span class="err">&lt;</span><span class="n">modulesymoblikname</span><span class="err">&gt;</span><span class="w"> </span><span class="s1">'Modulepath'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="n">name:</span><span class="w"> </span><span class="err">&lt;</span><span class="nx">ModuleName</span><span class="err">&gt;</span><span class="w"> </span><span class="nx">//</span><span class="w"> </span><span class="nx">the</span><span class="w"> </span><span class="nx">deployment</span><span class="w"> </span><span class="nx">name</span><span class="w"> </span><span class="nx">that</span><span class="w"> </span><span class="nx">will</span><span class="w"> </span><span class="nx">be</span><span class="w"> </span><span class="nx">logged</span><span class="w"> </span><span class="nx">in</span><span class="w"> </span><span class="nx">Azure</span><span class="w"> </span><span class="nx">activity</span><span class="w"> </span><span class="nx">logs</span><span class="w">
</span><span class="n">scope:</span><span class="w"> </span><span class="err">&lt;</span><span class="nx">Deploymentscope</span><span class="err">&gt;</span><span class="w"> </span><span class="nx">//</span><span class="w"> </span><span class="nx">specifying</span><span class="w"> </span><span class="nx">the</span><span class="w"> </span><span class="nx">scope</span><span class="w"> </span><span class="nx">where</span><span class="w"> </span><span class="nx">the</span><span class="w"> </span><span class="nx">deployment</span><span class="w"> </span><span class="nx">should</span><span class="w"> </span><span class="nx">take</span><span class="w"> </span><span class="nx">place</span><span class="w">
</span><span class="n">params:</span><span class="w"> </span><span class="p">{</span><span class="w">
  </span><span class="n">your</span><span class="w"> </span><span class="nx">parameters</span><span class="w"> </span><span class="nx">goes</span><span class="w"> </span><span class="nx">here</span><span class="w">
  </span><span class="p">}</span><span class="w"> 
</span><span class="p">}</span></code></pre></figure>

<ul><li>The deployment scope is defined by referencing the symbolic name of the resource group that was created earlier, for example<strong> stgrg </strong>for the storage account resource group "regaRG3"</li></ul>

<figure class="wp-block-image size-large is-style-default"><img src="https://i.ibb.co/4m4kzRM/image-1622027693226-0.png" alt="image-1622027693226-0" /></figure>

<ul><li>Outputs from different modules are passed as parameters to other modules </li></ul>
<p>In order to configure the web app to use and connect to the storage account and SQL database that are being deployed, it is essential to get the outputs from the respective modules. This is done as following:</p>
<ul><li>Defining the output variables in the source module as below</li></ul>
<figure class="wp-block-image size-large is-style-default"><img src="https://i.ibb.co/bd8L6bp/image-1622033682892-0.png" alt="image-1622033682892-0.png" /></figure>

<blockquote class="wp-block-quote">Notice the cross reference that we are using to supply the value of the output variable storageEndpoint</blockquote>

<ul><li>Passing the output as parameters to the destination module as below</li></ul>

<figure class="wp-block-image size-large is-style-default"><img src="https://i.ibb.co/RY8wPBK/image-1622034830979-0.png" alt="" /></figure>
<!-- /wp:image -->
<!-- wp:quote {"canvasClassName":"cnvs-block-core-quote-1622035055888"} -->
<p>notice the parameters value reference &lt;Modulesymname&gt;.outputs.&lt;variablename&gt;</p>

<h2 id="conclusion">Conclusion</h2>

<p>In this series I tried to shed the light on Azure Bicep as a new DSL language and how it can be used for Azure deployments and the main Bicep features. <br />
More details on how to move from  ARM templates can be found <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/compare-template-syntax">here</a> .<br />Tt is important to note that Azure Bicep is 100% supported by Microsoft and it provides Day 0 resource provider support. Any Azure resource - whether in private or public preview or GA - can be provisioned using Bicep.</p>]]></content><author><name>Charbel Hanna</name></author><category term="Azure" /><summary type="html"><![CDATA[Part 3 - Advanced Deployments with Bicep Modules]]></summary></entry><entry><title type="html">Azure Bicep - New Generation ARM Templates</title><link href="https://zerohoursleep.net/azure/2021/04/29/Bicep-Deploy-your-first-code.html" rel="alternate" type="text/html" title="Azure Bicep - New Generation ARM Templates" /><published>2021-04-29T00:00:00+00:00</published><updated>2021-04-29T00:00:00+00:00</updated><id>https://zerohoursleep.net/azure/2021/04/29/Bicep-Deploy-your-first-code</id><content type="html" xml:base="https://zerohoursleep.net/azure/2021/04/29/Bicep-Deploy-your-first-code.html"><![CDATA[<h1 id="part-2---azure-bicep---deploy-your-first-code">Part 2 - Azure Bicep - Deploy Your First Code<br /></h1>
<p><a href="/azure/2021/04/02/Bicep-Introduction.html">Part 1 - Azure Bicep - Introduction</a><br />
<a href="/azure/2021/05/26/Bicep-Deploy-using-modules.html">Part 3 - Azure Bicep - Advanced Deployments with Bicep modules</a></p>

<h2 id="introduction">Introduction</h2>

<p>In [part-one](/azure/2021/04/02/Bicep-Introduction.html) of this series we have introduced Bicep and explained how it works. <br />so now it is time to get our hands dirty by starting deploying our first bicep code.</p>

<p>In this part I will walk you through how to deploy your Azure resources by using Bicep with emphasis on the syntax requirements and differences between Bicep and standard ARM Templates.</p>

<h2 id="prerequisites">Prerequisites</h2>

<p>We assume that your development environment is setup for bicep, (if you still did not setup your development environment please follow the instructions mentioned in  <a href="/azure/2021/04/02/Bicep-Introduction.html">part-one</a></p>

<h2 id="create-your-bicep-file">Create your Bicep file</h2>

<p>Open vscode and create your bicep file, you can give the file any name that you want as long as you save it under the “.bicep” extension. For the purpose of this tutorial I will create a bicep file and call it main.bicep.
I like to create and save the file as an empty file first so vscode recognize it as a .bicep file and load the bicep tools extension directly as soon as I start authoring.</p>

<p><img src="https://i.ibb.co/DQJWR33/image-1619113760243-0.png" alt="image-1619113760243-0" height="100%" width="100%" /></p>

<h2 id="bicep-file-structure">Bicep file structure</h2>

<p>Unlike standard JSON ARM templates, bicep does not require a predefined schema to exist in the beginning of the file so the file be properly treated as a deployment template.
Which means in a bicep file you start authoring directly without adding any specific elements related to the file itself to make it readable.</p>

<p>The picture below shows an empty ARM template.</p>

<p><img src="https://i.ibb.co/xhb4p2k/image-1619418259449-0.png" alt="image-1619418259449-0" height="100%" width="100%" />
<br /></p>
<div style="border: solid; border-color: #e0f2ff; background-color: #e0f2ff; border-radius: 10px; width: 90%; padding: 10px; margin: auto;">
<p style="color: #003a66;" align="center">Note the first lines and the of code in the top of the file</p>
</div>
<p><br /></p>
<p><strong>If we take a look on a bicep file, we will directly notice the difference and how simple it is</strong></p>

<p><img src="https://i.ibb.co/KLZ9WG0/image-1619441036863-0.png" alt="image-1619441036863-0" height="100%" width="100%" /></p>

<p>For example the above code permit the deployment of a public IP address resource just by specifying the resource type and related properties. cool isn’t ?</p>

<h2 id="defining-azure-resources-in-bicep">Defining Azure Resources in Bicep</h2>

<p>Azure resources are the building bloc of a bicep file, since at the end the target is to deploy or update an azure resource, therefore, the minimum required block in a bicep file is a resource bloc.
The resource bloc define the type of the resource that you want to interact with.
Each resource bloc includes the following:</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">resource</span><span class="w"> </span><span class="err">&lt;</span><span class="nx">resouceSymbolicName</span><span class="err">&gt;</span><span class="w"> </span><span class="s1">'ResourceType@&lt;Apiversion&gt;'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="n">property1:</span><span class="err">&lt;</span><span class="nx">somevalue</span><span class="err">&gt;</span><span class="w">
</span><span class="n">property2:</span><span class="err">&lt;</span><span class="nx">somevalue</span><span class="err">&gt;</span><span class="w">
</span><span class="o">....</span><span class="w"> </span><span class="p">}</span></code></pre></figure>

<p><strong>There are couple of things to note here</strong></p>

<p>1) Each resource is represented by a symbolic name to be used as a reference for the resource throughout the file. 
2) The API version is appended directly to the ‘ResourceType’  which allows you to directly choose the API version to be used during the deployment.</p>

<p>Ok so now we know that we need to specify the resource type but the first question that pops up is from where we can get the resource type ?
Actually the answer is very simple, thanks for the Bicep vscode extension that will automatically display the resource Type along its API version just as soon as you start typing the name of the and for finding the allowed properties, you can use the “Ctrl+Space” key combination to open the properties selector as shown below.</p>

<!-- Courtesy of embedresponsively.com //-->

<div class="responsive-video-container">
    <iframe src="https://www.youtube-nocookie.com/embed/dPTMrCHuyS4" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
  </div>

<h2 id="author-the-first-code">Author the first code</h2>

<p>let’s assume we want to create a storage account with the following information:</p>
<ul>
  <li>Storage account name: komobicepstg01</li>
  <li>Storage account type: general purpose V2</li>
  <li>Replication policy: local redundant</li>
  <li>performance tier: standard</li>
</ul>

<p>based on what we have seen so far our bicep file should should contains the following code.</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">resource</span><span class="w"> </span><span class="nx">stg</span><span class="w"> </span><span class="s1">'Microsoft.Storage/storageAccounts@2021-02-01'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w">
  </span><span class="n">name:</span><span class="w"> </span><span class="s1">'komobicepstg01'</span><span class="w">
  </span><span class="n">location:</span><span class="w"> </span><span class="s1">'westeurope'</span><span class="w">
  </span><span class="n">kind:</span><span class="w"> </span><span class="s1">'StorageV2'</span><span class="w">
  </span><span class="n">sku:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="n">name:</span><span class="w"> </span><span class="s1">'Standard_LRS'</span><span class="w">
    </span><span class="n">tier:</span><span class="w"> </span><span class="s1">'Standard'</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span></code></pre></figure>

<h2 id="deploying-the-bicep-code">Deploying the bicep code</h2>
<p>Now we have our code complete, we are ready to deploy it to Azure in an existing resource group, to achieve this I have I can either use powershell or Az cli, I will deploy it using powershell by running the following command.</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">New-AzResourceGroupDeployment</span><span class="w"> </span><span class="nt">-templateFile</span><span class="w"> </span><span class="s2">"C:\Coding\Repos\Komo\bicep-tuto\App01\main.bicep"</span><span class="w"> </span><span class="se">`
</span><span class="nt">-ResourceGroupName</span><span class="w"> </span><span class="nx">bicep-tuto-rg</span><span class="w"> </span><span class="nt">-Verbose</span></code></pre></figure>

<p><br /></p>
<div style="border: solid; border-color: #e0f2ff; background-color: #e0f2ff; border-radius: 10px; width: 90%; padding: 10px; margin: auto;">
<p style="color: #003a66;" align="justify">To note that here the bicep deployment shown below will be performed on a resource group scope rather than on the subscription scope since the targetscope is not explicitly defined in t</p>
</div>
<p><br /></p>

<!-- Courtesy of embedresponsively.com //-->

<div class="responsive-video-container">
    <iframe src="https://www.youtube-nocookie.com/embed/X0YjSATbuyo" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
  </div>

<h2 id="working-with-parameters">Working With Parameters</h2>

<p>Despite that the bicep file we have created earlier works properly to deploy the intended resource, however it is would be difficult to use it for multiple deployments since all properties values are included directly within the resource bloc of the file itself.<br /><br />
To overcome this problem we should use parameters to dynamically inject values for specific properties without the need of each time through the code.<br /><br />
Fortunately defining and using parameters in a bicep file is easy and straight forward.<br />
In this section we will see how parameters can be defined and used with bicep.</p>

<blockquote class="wp-block-quote"><span style="color:#1380ae" class="has-inline-color">To note that same as in ARM templates bicep supports defining parameters and setting parameters values either within the bicep file itself or in a separate file.</span></blockquote>

<h2 id="defining-parameters-variables-and-setting-values">Defining parameters, variables and setting values</h2>
<p>A parameter or a variable can be defined using the following form of code
<br /></p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="kr">param</span><span class="w"> </span><span class="n">StorageAccountName</span><span class="w"> </span><span class="nx">string</span><span class="w">
</span><span class="kr">var</span><span class="w"> </span><span class="n">location</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">resroucegroup</span><span class="p">()</span><span class="o">.</span><span class="nf">location</span></code></pre></figure>

<p><br />
A parameter value can be set using the following form of code
<br /></p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="kr">param</span><span class="w"> </span><span class="n">StorageAccountName</span><span class="w"> </span><span class="nx">string</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'komobicepstg01'</span></code></pre></figure>

<p><br /></p>

<p>In this example we defined the storageAccountName as a string type parameter with a value
of “komobicepstg01”, and a variable name location to the value of the resource group location where the deployment will be performed.</p>

<h2 id="calling-parameters-and-variables">Calling Parameters And Variables</h2>
<p>A parameter or a variable can be called by simply typing the parameter name like below</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">name:StorageAccountName</span><span class="w">
</span><span class="nx">location:location</span></code></pre></figure>

<blockquote class="wp-block-quote"><span style="color:#1380ae" class="has-inline-color">Notice that the parameter and variable names are used directly without quotes or brackets or even mentioning if we are calling a variable or a parameter unlike the way it is required in a JSON ARM template which dramatically simplify the authoring experience.</span></blockquote>

<h2 id="putting-it-all-together">Putting it all together</h2>
<p>Our bicep file should be like this</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">//---parameters-----------</span><span class="w">
</span><span class="nx">param</span><span class="w"> </span><span class="nx">StorageAccountName</span><span class="w"> </span><span class="nx">string</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'komobicepstg01'</span><span class="w">
</span><span class="kr">param</span><span class="w"> </span><span class="n">StorageAccountType</span><span class="w"> </span><span class="nx">string</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'StorageV2'</span><span class="w">
</span><span class="kr">param</span><span class="w"> </span><span class="n">StorageAccountSku</span><span class="w"> </span><span class="nx">object</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w">
  </span><span class="n">name:</span><span class="w"> </span><span class="s1">'Standard_LRS'</span><span class="w">
  </span><span class="n">tier:</span><span class="w"> </span><span class="s1">'Standard'</span><span class="w">
</span><span class="p">}</span><span class="w">

</span><span class="n">//---variables-----------</span><span class="w">
</span><span class="nx">var</span><span class="w"> </span><span class="nx">location</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">resourceGroup</span><span class="p">()</span><span class="o">.</span><span class="nf">location</span><span class="w">

</span><span class="n">//---resources-----------</span><span class="w">
</span><span class="nx">resource</span><span class="w"> </span><span class="nx">stg</span><span class="w"> </span><span class="s1">'Microsoft.Storage/storageAccounts@2021-02-01'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w">
  </span><span class="n">name:StorageAccountName</span><span class="w">
  </span><span class="nx">location:location</span><span class="w">
  </span><span class="n">kind:StorageAccountType</span><span class="w">
  </span><span class="nx">sku:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="n">name:StorageAccountSku.name</span><span class="w">
    </span><span class="nx">tier:StorageAccountSku.tier</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span></code></pre></figure>

<h2 id="using-a-separate-template-file-with-bicep">Using a separate template file with bicep</h2>

<p>As mentioned earlier we can use separate parameter file with bicep, this will give us more flexibility in editing and supplying parameters values without touching the bicep code.
At the time of writing this article “.json” parameters files are the only supported. That means yes the same parameters file used with ARM template can be used with a bicep file.
so our parameters file for the storage account creation should look like this</p>

<figure class="highlight"><pre><code class="language-json" data-lang="json"><span class="p">{</span><span class="w">
    </span><span class="nl">"$schema"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"contentVersion"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.0.0.0"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"parameters"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
        </span><span class="nl">"StorageAccountName"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
            </span><span class="nl">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"komobicepstg01"</span><span class="w">
        </span><span class="p">},</span><span class="w">
        </span><span class="nl">"StorageAccountType"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
            </span><span class="nl">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"StorageV2"</span><span class="w">
        </span><span class="p">},</span><span class="w">
        </span><span class="nl">"StorageAccountSku"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
            </span><span class="nl">"value"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
                </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Standard_LRS"</span><span class="p">,</span><span class="w">
                </span><span class="nl">"tier"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Standard"</span><span class="w">
            </span><span class="p">}</span><span class="w">
        </span><span class="p">}</span><span class="w">
    </span><span class="p">}</span><span class="w">
</span><span class="p">}</span></code></pre></figure>

<p><br /></p>
<blockquote class="wp-block-quote"><span style="color:#1380ae" class="has-inline-color">Note that the values set in the main.bicep file itself earlier represents the parameters default values, therefore, these values are overwritten by the values are set in the parameters file that we have just created.<br />If you prefer to not use default values like myself you can remove the parameters values from the main.bicep file.</span>
</blockquote>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">//---parameters-----------</span><span class="w">
</span><span class="nx">param</span><span class="w"> </span><span class="nx">StorageAccountName</span><span class="w"> </span><span class="nx">string</span><span class="w">
</span><span class="kr">param</span><span class="w"> </span><span class="n">StorageAccountType</span><span class="w"> </span><span class="nx">string</span><span class="w">
</span><span class="kr">param</span><span class="w"> </span><span class="n">StorageAccountSku</span><span class="w"> </span><span class="nx">object</span><span class="w">

</span><span class="n">//---variables-----------</span><span class="w">
</span><span class="nx">var</span><span class="w"> </span><span class="nx">location</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">resourceGroup</span><span class="p">()</span><span class="o">.</span><span class="nf">location</span><span class="w">

</span><span class="n">//---resources-----------</span><span class="w">
</span><span class="nx">resource</span><span class="w"> </span><span class="nx">stg</span><span class="w"> </span><span class="s1">'Microsoft.Storage/storageAccounts@2021-02-01'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w">
  </span><span class="n">name:StorageAccountName</span><span class="w">
  </span><span class="nx">location:location</span><span class="w">
  </span><span class="n">kind:StorageAccountType</span><span class="w">
  </span><span class="nx">sku:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="n">name:StorageAccountSku.name</span><span class="w">
    </span><span class="nx">tier:StorageAccountSku.tier</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span></code></pre></figure>

<p><br />
The previous deployment can be performed using a separate file as follows</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">New-AzResourceGroupDeployment</span><span class="w"> </span><span class="nt">-templateFile</span><span class="w"> </span><span class="s2">"C:\Coding\Repos\Komo\bicep-tuto\App01\main.bicep"</span><span class="w"> </span><span class="se">`
</span><span class="nt">-TemplateparameterFile</span><span class="w"> </span><span class="s2">"C:\Coding\Repos\Komo\bicep-tuto\App01\parameters.json"</span><span class="w"> </span><span class="se">`
</span><span class="nt">-ResourceGroupName</span><span class="w"> </span><span class="nx">bicep-tuto-rg</span><span class="w"> </span><span class="nt">-Verbose</span></code></pre></figure>

<h2 id="conclusion">Conclusion</h2>

<p>We can clearly conclude that using bicep simplifies the deployment of azure resources while preserving the same deployment experience by using the same deployment commands used with ARM template deployment.
Also bicep capabilities provide a much simpler experience against the standard JSON ARM templates.
<br />
<br />
 hope you find this article in this series useful and helps you get starting using bicep. 
your feedback is appreciated.</p>]]></content><author><name>Charbel Hanna</name></author><category term="Azure" /><summary type="html"><![CDATA[Part 2 - Deploy Your First Code]]></summary></entry><entry><title type="html">Azure Bicep - New Generation ARM Templates</title><link href="https://zerohoursleep.net/azure/2021/04/02/Bicep-Introduction.html" rel="alternate" type="text/html" title="Azure Bicep - New Generation ARM Templates" /><published>2021-04-02T00:00:00+00:00</published><updated>2021-04-02T00:00:00+00:00</updated><id>https://zerohoursleep.net/azure/2021/04/02/Bicep-Introduction</id><content type="html" xml:base="https://zerohoursleep.net/azure/2021/04/02/Bicep-Introduction.html"><![CDATA[<h1 id="background">Background</h1>

<p>As a cloud architect working on cloud environments on daily basis trying to reply to various technical and organizational demands while coping with technology changes and updates , Infrastructure as Code has become vital to perform almost all kind of operations. <br /><br />Despite the fact that there are many languages / utilities offered by third party vendors that already exists in the market (which are by the way very good and powerful), you might be in a position like I am where you have to use only native languages provided by your public cloud provider "Microsoft Azure" in this context. <br />JSON ARM templates where the only available native solution from Microsoft to be used for Azure which I was using until recently a new promising language "<strong>Bicep</strong>" has been released, which for my opinion represents the future of ARM templates.</p>

<p>That being said, I felt that it worth shedding light on Bicep and share my experience on using this new language for IaC deployments through a series of articles which I hope that you find interesting and useful.</p>

<h1 id="part-1---azure-bicep---introduction">Part 1 - Azure Bicep - Introduction</h1>
<p><a href="/azure/2021/04/29/Bicep-Deploy-your-first-code.html">Part 2 - Azure Bicep - Deploy your Fist code</a> <br />
<a href="/azure/2021/05/26/Bicep-Deploy-using-modules.html">Part 3 - Azure Bicep - Advanced Deployments with Bicep modules</a></p>

<h2 id="first-things-first-what-is-azure-bicep">First things first, what is Azure Bicep</h2>
<p>As per the official documentation, “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”.</p>

<p>So in other terms Azure Bicep is a new authoring language that if once used it eliminates the need of developing standard ARM JSON templates, which I personally think is a turning point since this will drastically simplify template development hence considerably reduce authoring and deployment time.</p>

<h2 id="so-how-bicep-actually-works">So how Bicep actually works?</h2>

<p>What Bicep does under the hood actually is compiling the bicep code to ARM templates which they are in turn deployed on Azure by Azure Resource Manager, cool isn’t ?</p>

<figure class="wp-block-image size-full is-style-default"><img src="https://zerohoursleep.net/wp-content/uploads/2021/04/image-2.png" alt="" class="wp-image-2418" /><figcaption>how it actually works</figcaption></figure>

<p><strong>Wait a minute, so is this means that at the end we are always be using Azure ARM! </strong><br />Actually Yes! This means we can still benefit from all existing and NEW features and capabilities of ARM templates. Which also means that <strong>Azure Bicep is NOT a replacement of Azure ARM</strong></p>

<p><strong>So why bothering using a new language?</strong>
<br />The main reason is to simplify the authoring experience. Whether you are used to or new to ARM templates we all agree on the complexity of the syntax that they hold, which makes it hard to manage and maintain as they written in JSON format which is not considered as a user friendly language. Bicep does not only provide a simpler syntax but it also provide additional enhancements like automatic dependencies generation and much more. <br />at the time of writing this post Bicep is in version 0.13 which supports all existing ARM template features.</p>

<h2 id="bicep-deployment-process">Bicep deployment process</h2>

<p>The deployment process using bicep is easy and straight forward all you have to do is :
1) create your bicep code and save it as .bicep files
2) Deploy bicep code to azure using either Az CLI or Az powershell</p>

<figure class="wp-block-image size-full is-resized is-style-default"><img src="https://zerohoursleep.net/wp-content/uploads/2021/04/image-8.png" alt="" class="wp-image-2427" width="721" height="349" /><figcaption>Bicep deployment process</figcaption></figure>
<p><br />it is to note that the deployment of bicep files can still be done using existing commands such as<br />in Az powershell</p>

<figure class="highlight"><pre><code class="language-powershell" data-lang="powershell"><span class="n">New-AzResourceGroupDeployment</span><span class="w"> </span></code></pre></figure>

<p>or Az cli</p>

<figure class="highlight"><pre><code class="language-cli" data-lang="cli">Az deployment group</code></pre></figure>

<p>So now we have an idea about what is Azure Bicep and how it works, let’s jump over and start deploying our first bicep code.</p>

<h2 id="first-lets-setup-together-the-development-environment">First let’s setup together the development environment</h2>

<p>Bicep requires the Bicep cli to be able to compile bicep code to ARM templates which can be provided by the following:</p>

<ul><li><a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli" target="_blank" rel="noreferrer noopener">Azure cli</a> (<strong>required version v2.20.0 or later</strong>) can automatically install Bicep cli when deploying the bicep code, there's no need for any manual installation, however you can still manually install the bicep cli by running the below command</li></ul>

<figure class="highlight"><pre><code class="language-cli" data-lang="cli">az bicep install</code></pre></figure>

<figure class="wp-block-image size-large is-style-default"><img src="https://zerohoursleep.net/wp-content/uploads/2021/04/pages_Azure-Bicep-New-generation-ARM-Templates_1617049424645_0.png" alt="" class="wp-image-2429" /></figure>

<ul><li><a href="https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.7.0">Azure </a><a href="https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.7.0" target="_blank" rel="noreferrer noopener">Powershell</a><a href="https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.7.0"> module</a> (<strong>required version v5.6 or later</strong>) does not have the ability to install the Bicep cli directly therefore, it expect that the bicep cli is already installed. You can manually install the bicep cli by following on the installation methods mentioned in the <a href="https://github.com/Azure/bicep/blob/main/docs/installing.md#manually-install" target="_blank" rel="noreferrer noopener">reference link</a></li></ul>

<p>You can check the version of the installed bicep cli by running</p>

<figure class="highlight"><pre><code class="language-cli" data-lang="cli">bicep --version</code></pre></figure>

<figure class="wp-block-image size-large is-resized is-style-default"><img src="https://zerohoursleep.net/wp-content/uploads/2021/04/pages_Azure-Bicep-New-generation-ARM-Templates_1617050660001_0.png" alt="" class="wp-image-2430" width="680" height="238" /></figure>

<p>For the best authoring experience, Bicep language service can be used which is part of the Bicep visual studio extension, this is a great extension that supports validation, intellisense code completion and many more important features that can be used to give an easy and simple authoring experience</p>

<figure class="wp-block-image size-large is-style-default"><img src="https://zerohoursleep.net/wp-content/uploads/2021/04/pages_Azure-Bicep-New-generation-ARM-Templates_1617050798507_0.png" alt="" class="wp-image-2431" /></figure>

<h2 id="conclusion">Conclusion</h2>

<p>That was the first part of the Bicep series in which we introduced Bicep, how it works and what is required to start using it in your Azure deployments.
Stay tuned for Part two where we are going to get your hands dirty deploying Bicep</p>]]></content><author><name>Charbel Hanna</name></author><category term="Azure" /><summary type="html"><![CDATA[Part 1 - Introduction]]></summary></entry></feed>