<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sahil V on Medium]]></title>
        <description><![CDATA[Stories by Sahil V on Medium]]></description>
        <link>https://medium.com/@smartcloudtutorials?source=rss-31a4a0eb1136------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mZz7l4P96e2uJK0w</url>
            <title>Stories by Sahil V on Medium</title>
            <link>https://medium.com/@smartcloudtutorials?source=rss-31a4a0eb1136------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:35:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@smartcloudtutorials/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A simple Azure DevOps Pipeline to deploy resources using Bicep template.]]></title>
            <link>https://medium.com/@smartcloudtutorials/a-simple-azure-devops-pipeline-to-deploy-resources-using-bicep-template-c39597144ec7?source=rss-31a4a0eb1136------2</link>
            <guid isPermaLink="false">https://medium.com/p/c39597144ec7</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Sahil V]]></dc:creator>
            <pubDate>Sun, 30 Apr 2023 12:45:07 GMT</pubDate>
            <atom:updated>2023-04-30T12:45:07.102Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In this article we will create a simple pipeline that will deploy azure resources using Microsoft’s Bicep IaC language but before deploying, the pipeline we also preview what it is going to deploy, pause for user confirmation and then deploy the resources.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*APfEcFq4VwC2MCp8Hz988Q.png" /><figcaption>DevOps Organization</figcaption></figure><blockquote>Gentle Reminder: This article is tailored to cater to the needs of beginner-level readers and learners, providing an accessible and engaging foundation for those just starting their journey into the realm of Azure Bicep.</blockquote><p>Azure Bicep is a domain-specific language (DSL) specifically crafted for describing and deploying Azure resources. As a modern, elegant, and more readable successor to Azure Resource Manager (ARM) templates, Bicep provides developers with an intuitive and efficient way to build, manage, and maintain their Azure infrastructure.</p><p>In this article, we will first build a simple Bicep template to deploy a resource group, followed by a simple Azure DevOps Pipeline to deploy the resource group.</p><p>We shall use below Bicep template to deploy a resource group, lets create a template file named as <strong>resourceGroup.bicep</strong> —</p><pre>targetScope = &#39;subscription&#39;<br><br>@sys.description(&#39;Azure Region where Resource Group will be created.&#39;)<br>param Location string<br><br>@sys.description(&#39;Name of Resource Group to be created.&#39;)<br>param ResourceGroupName string<br><br>@sys.description(&#39;Tags you would like to be applied to all resources in this module.&#39;)<br>param Tags object = {}<br><br>resource resResourceGroup &#39;Microsoft.Resources/resourceGroups@2022-09-01&#39; = {<br>  location: Location<br>  name: ResourceGroupName<br>  tags: Tags<br>}<br><br>output outResourceGroupName string = resResourceGroup.name<br>output outResourceGroupId string = resResourceGroup.id</pre><p>Above Bicep code defines a template that creates a new Azure Resource Group with the specified parameters, and then outputs the name and ID of the created resource group.</p><p>1. `targetScope` = ‘subscription’`: The target scope of the template is set to ‘subscription’. This means that the deployment will be executed at the subscription level, rather than at the resource group level.</p><p>2. Parameters: The template takes three input parameters:<br> — `Location`: The Azure region where the resource group will be created.<br> — `ResourceGroupName`: The name of the resource group to be created.<br> — `Tags`: An optional object parameter containing tags to be applied to all resources in this module. The default value is an empty object.</p><p>3. Resource declaration: A single resource is declared of type `Microsoft.Resources/resourceGroups@2022–09–01`, which represents an Azure Resource Group. The properties for this resource are set as follows:<br> — `location`: Set to the value of the `Location` parameter.<br> — `name`: Set to the value of the `ResourceGroupName` parameter.<br> — `tags`: Set to the value of the `Tags` parameter.</p><p>4. Outputs: Two output values are defined:<br> — `outResourceGroupName`: The name of the created resource group, which is derived from the `resResourceGroup.name` property.<br> — `outResourceGroupId`: The ID of the created resource group, which is derived from the `resResourceGroup.id` property.</p><p>You have multiple options for passing parameter values to the template: either provide the values directly within the bicep template or provide the values directly within the pipeline as variables, or utilize a separate parameters file to supply them.</p><p>In this scenario, we will use a separate parameters file to pass the parameters values as seen below , create a file named as <strong>resourceGroup.parameters.json</strong> —</p><pre>{<br>    &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#&quot;,<br>    &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,<br>    &quot;parameters&quot;: {<br>        &quot;Location&quot;: {<br>            &quot;value&quot;: &quot;eastus&quot;<br>        },<br>        &quot;ResourceGroupName&quot;: {<br>            &quot;value&quot;: &quot;medium-rg&quot;<br>        },<br>        &quot;Tags&quot;: {<br>            &quot;value&quot;: {<br>                &quot;Environment&quot;: &quot;Dev&quot;,<br>                &quot;Description&quot;: &quot;Pipeline Demo&quot;<br>            }<br>        }<br>    }<br>}</pre><blockquote><em>Tip— Passing the parameters value via a parameters file makes a bicep template/module reusable and flexible.</em></blockquote><h4>Prerequisites for Integrating Azure with Your DevOps Workflow</h4><p>Before diving into the process of integrating Azure with your DevOps workflow, it’s essential to ensure you have the necessary setup in place. This article assumes you’ve already taken the following preliminary steps:</p><ol><li><a href="https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/create-organization?view=azure-devops"><strong>Established a DevOps Organization</strong></a></li><li><a href="https://learn.microsoft.com/en-us/azure/devops/organizations/projects/create-project?view=azure-devops&amp;tabs=browser"><strong>Created a DevOps Project</strong></a></li><li><a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?toc=%2Fazure%2Fdevops%2Forganizations%2Ftoc.json&amp;view=azure-devops&amp;tabs=yaml"><strong>Configured a Service Connection to Azure Subscription</strong></a></li></ol><blockquote><em>This article also assumes that you have basic understanding of Azure DevOps and running a pipeline.</em></blockquote><p>Now, lets create a YAML file for our pipeline. Lets name it — <strong>bicepDeploy.yml</strong></p><pre>trigger: none<br><br>pool:<br>  vmImage: ubuntu-latest<br><br>variables:<br>  ServiceConnectionName: &quot;AzDevOpsConnection&quot;<br>  Location: &quot;eastus&quot;<br>  AzSubscriptionid: &quot;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&quot;<br>  RunNumber: $(Build.BuildNumber)<br><br>jobs:<br>  - job:<br>    steps:<br>      - task: AzureCLI@2<br>        displayName: &quot;Deploy Resource Group&quot;<br>        name: deploy_rg<br>        inputs:<br>          azureSubscription: $(ServiceConnectionName)<br>          scriptType: &quot;bash&quot;<br>          scriptLocation: &quot;inlineScript&quot;<br>          inlineScript: |<br>            az account set --subscription $(AzSubscriptionid)<br>            az deployment sub create \<br>            --template-file bicep/modules/resourceGroup/resourceGroup.bicep \<br>            --parameters bicep/modules/resourceGroup/resourceGroup.parameters.json \<br>            --location $(Location) \<br>            --name deploy_rg-$(RunNumber)</pre><ol><li>trigger: none: This line specifies that the pipeline will not be triggered automatically by any changes to the source code repository.</li><li>pool: This block defines the agent pool that the pipeline will use. The vmImage: ubuntu-latest line specifies that the pipeline will use the latest Ubuntu-based virtual machine image.</li><li>variables: This block defines several variables that will be used throughout the pipeline. These variables include ServiceConnectionName, Location, AzSubscriptionid, and RunNumber.</li><li>jobs: This block contains the definition of the jobs that the pipeline will execute.</li></ol><ul><li>job: This is the only job defined in the pipeline. It consists of a single task.</li><li>steps: This block contains the steps that the job will execute.</li><li>task: AzureCLI@2: This task uses the Azure CLI task version 2 to execute an Azure CLI command.</li></ul><p>For more information on the task Azure CLI task version 2 visit <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-cli-v2?view=azure-pipelines">here</a>.</p><p>Next step is to <a href="https://learn.microsoft.com/en-us/azure/devops/repos/git/create-new-repo?toc=%2Fazure%2Fdevops%2Forganizations%2Ftoc.json&amp;view=azure-devops">create a repository</a> in your project and place above 3 files we created, in there respective folders of your choice.</p><p>Within the YAML file — inside the task, update the path accordingly for below —</p><p>--template-file and --parameters</p><p>Next, we shall create a new pipeline , you may follow the steps as described in <a href="https://xeladu.medium.com/how-to-create-a-pipeline-from-an-existing-yaml-file-in-azure-devops-4c41e74fde2b#:~:text=Go%20to%20Pipelines%20and%20click,file%20in%20the%20dropdown%20menu.">this </a>article, as it explains how we can create a pipeline using an existing YAML file.</p><p>The new pipeline you created should appear under —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*u4vq_5t3KcDYSl_cMZxAxA.png" /></figure><p>Run the pipeline and as it has only single job it should take only few mins to complete. Upon successful completion head to the Azure Portal and confirm the resource group deployment.</p><h4>Some Improvements —</h4><p>The pipeline we created is very basic, we can make it a little more intuitive and interactive by adding more jobs. For example — using what-if functionality within AzCLI command.</p><p>Using this flag, you can preview the changes that will happen. Azure Resource Manager offers the what-if operation, allowing you to view the potential modifications to resources if you deploy the Bicep file. The what-if operation does not alter existing resources; rather, it predicts the changes that would result from deploying the specified Bicep file.</p><p>For more information regarding what-if flag visit <a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/deploy-what-if?tabs=azure-powershell%2CCLI">here</a>.</p><p>One additional improvement that we could also do here is to add a manual validation job using an inbuilt <a href="http://Manual validation v0 task"><strong>Manual validation v0 task</strong></a><strong> </strong>in Azure DevOps. Essentially, adding this job will pause the pipeline for user input and once user approves, the pipeline will move forward with the deployment.</p><p>It will look something like this —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*N8M7CIoT3LHDHwpCSHvcfA.png" /><figcaption>Manual Validation Job</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*XSOXgE_hPi3jIEwpQYmWvQ.png" /><figcaption>User Input required here.</figcaption></figure><p>Following, manual validation job, we will add another job to “Deploy Resource Group” Job. This job will perform the actual deployment of the resource, basically, this job is nothing but the only job in the previous pipeline.</p><p>Finally, the improved pipeline will look like below —</p><pre>trigger: none<br><br>pool:<br>  vmImage: ubuntu-latest<br><br>variables:<br>  ServiceConnectionName: &quot;AzDevOpsConnection&quot;<br>  Location: &quot;eastus&quot;<br>  AzSubscriptionid: &quot;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&quot;<br>  RunNumber: $(Build.BuildNumber)<br><br>jobs:<br>  - job: Preview<br>    displayName: &quot;Preview Deployment&quot;<br>    steps:<br>      - task: AzureCLI@2<br>        name: deploy_rg<br>        inputs:<br>          azureSubscription: $(ServiceConnectionName)<br>          scriptType: &quot;bash&quot;<br>          scriptLocation: &quot;inlineScript&quot;<br>          inlineScript: |<br>            az account set --subscription $(AzSubscriptionid)<br>            az deployment sub create \<br>            --what-if \<br>            --template-file bicep/modules/resourceGroup/resourceGroup.bicep \<br>            --parameters bicep/modules/resourceGroup/resourceGroup.parameters.json \<br>            --location $(Location) \<br>            --name preview_rg-$(RunNumber)<br>  - job: ManualValidation<br>    displayName: &quot;Manual Validation&quot;<br>    dependsOn: Preview<br>    pool: server<br>    steps:<br>      - task: ManualValidation@0<br>        timeoutInMinutes: 30<br>        inputs:<br>          instructions: &quot;Please validate the build configuration and resume&quot;<br>          onTimeout: &quot;reject&quot;<br>  - job: Deployment<br>    displayName: &quot;Deploy Resource Group&quot;<br>    dependsOn: ManualValidation<br>    steps:<br>      - task: AzureCLI@2<br>        name: deploy_rg<br>        inputs:<br>          azureSubscription: $(ServiceConnectionName)<br>          scriptType: &quot;bash&quot;<br>          scriptLocation: &quot;inlineScript&quot;<br>          inlineScript: |<br>            az account set --subscription $(AzSubscriptionid)<br>            az deployment sub create \<br>            --template-file bicep/modules/resourceGroup/resourceGroup.bicep \<br>            --parameters bicep/modules/resourceGroup/resourceGroup.parameters.json \<br>            --location $(Location) \<br>            --name deploy_rg-$(RunNumber)</pre><h4>Summary</h4><p>Azure DevOps is a great tool to run Infrastructure as Code, Bicep being a relatively new language, my aim in this article is to offer readers a simple and foundational concept around using Azure DevOps Pipeline with a Bicep Template.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c39597144ec7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>