<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ana Carolina Manzan</title>
    <description>The latest articles on DEV Community by Ana Carolina Manzan (@devsonclouds).</description>
    <link>https://dev.to/devsonclouds</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1413079%2Fc99778a9-de09-4c37-a1c1-1dcb30b2f6bf.jpeg</url>
      <title>DEV Community: Ana Carolina Manzan</title>
      <link>https://dev.to/devsonclouds</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devsonclouds"/>
    <language>en</language>
    <item>
      <title>Implementing blue-green deployment with Azure App Service deployment slots</title>
      <dc:creator>Ana Carolina Manzan</dc:creator>
      <pubDate>Fri, 17 Jan 2025 20:52:04 +0000</pubDate>
      <link>https://dev.to/devsonclouds/implementing-blue-green-deployment-with-azure-app-service-deployment-slots-2658</link>
      <guid>https://dev.to/devsonclouds/implementing-blue-green-deployment-with-azure-app-service-deployment-slots-2658</guid>
      <description>&lt;p&gt;Have you ever had to perform a deployment in your production environment after working hours, just to avoid having downtime? &lt;/p&gt;

&lt;p&gt;And maybe, even after your deployment was done, you realized your application version had issues that shouldn't be in the production environment and had to spend some time to perform a rollback?&lt;/p&gt;

&lt;p&gt;In this article, I want to provide you a simple solution to handle this problem using the Blue-green deployment strategy with Azure App Service deployment slots.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are deployment slots?
&lt;/h2&gt;

&lt;p&gt;First of all, we need to understand what "deployment slots" means and how this functionality can help us apply the Blue-green strategy in this scenario.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/azure/app-service/deploy-staging-slots?wt.mc_id=studentamb_234887" rel="noopener noreferrer"&gt;Deployment slots&lt;/a&gt; is a whole functionality of Azure App Services that allows us to create a replica, a duplicate environment as a single live app coupled with our original web app that will behave as a staging environment that can receive new versions of our application.&lt;/p&gt;

&lt;h3&gt;
  
  
  And how is this related to blue-green deployment strategy?
&lt;/h3&gt;

&lt;p&gt;Blue-green is a deployment strategy that claims we must have a replica of our productive environment in which we will deploy new versions of our application. After the deployment is done, we must shift the environments to grant that the newer version will be available for the users.&lt;/p&gt;

&lt;p&gt;I'm going to use an analogy to explain it better: imagine that you have 2 different kitchens in a restaurant, a blue one and a green one. The blue kitchen is functioning and serving the restaurant customers while you are having the green kitchen renewed. When the green kitchen renovation is done, you can then start using it to serve your customers, and if everything goes well, you will deactivate the blue kitchen. &lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get practical
&lt;/h2&gt;

&lt;p&gt;The first step we need to take in the direction of implementing it, is to  create the necessary resources in Azure. We need to create a Web App within a Standard App Service Plan tier at least, in which we'll have access to the deployment slots functionality.&lt;/p&gt;

&lt;p&gt;To facilitate the App Service creation process, we will use Azure CLI to create the resources.&lt;/p&gt;

&lt;p&gt;Here is a quick explanation about the code below: from line 1 until line 5, we are creating variables that will hold information about the resources, like the location where they will be created, the resource group, app service plan, web app and slot names. You can exchange the values of the variables according to your preferences.&lt;/p&gt;

&lt;p&gt;In lines 7 to 10, we will create the resource group, the App Service Plan, the Web App and the Deployment Slot within the Web App we created before.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The commands above can be executed either in your computer (after &lt;a href="https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?wt.mc_id=studentamb_234887" rel="noopener noreferrer"&gt;installing Azure CLI&lt;/a&gt;) or in Azure Portal using cloud shell.&lt;/p&gt;

&lt;p&gt;Here is a snapshot of how the resources should look like in Azure portal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2bewrxhsyz5rphfcaco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2bewrxhsyz5rphfcaco.png" alt="Image description" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right after its creation, the Web App (on the left) and its deployment slot (on the right) will be waiting to receive the application code, as we can see below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5ng2ckcpu5wrt7w4ydw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5ng2ckcpu5wrt7w4ydw.png" alt="Image description" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now with the infrastructure created, we need a pipeline that will deploy the application in the Web App and perform the swap operation between deployment slots.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In the code above, we have the tasks that will perform the deployment and swap operations. We are going to focus on this two tasks of our pipeline for now, but you can find the whole pipeline code &lt;a href="https://github.com/devsnasnuvens/blue-green-with-web-apps/blob/main/deployment/azure-pipelines.yml" rel="noopener noreferrer"&gt;here&lt;/a&gt; and the full project code &lt;a href="https://github.com/devsnasnuvens/blue-green-with-web-apps" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The first task is used to deploy our application into the WebApp. In this task, the application code will be sent to the Web App named &lt;strong&gt;bgapp&lt;/strong&gt; into its slot &lt;strong&gt;stage&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;In the second task we are performing the swap operation. For this task, the command will shift the &lt;strong&gt;stage&lt;/strong&gt; slot with the production Web App, which will then show the users the latest version of the application. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note that in this scenario, whenever we have a deployment, the swap will also happen right after it. If you wish or if it's applicable to your scenario, you can also perform the swap operation manually in Azure portal.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the pipeline
&lt;/h2&gt;

&lt;p&gt;Now with everything in place, set up and run the pipeline in Azure DevOps for the first time and check the final result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi182p3dvtmj4xeoan1sq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi182p3dvtmj4xeoan1sq.png" alt="Image description" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this first pipeline run, we deployed the first version of the application with the &lt;strong&gt;blue feature&lt;/strong&gt;, as we can see in the image above. &lt;/p&gt;

&lt;p&gt;Now, let's implement the &lt;strong&gt;green feature&lt;/strong&gt; and deploy it. I will make some changes in the application code, commit and push it to Azure DevOps and the pipeline will be triggered from the changes in the main branch.&lt;/p&gt;

&lt;p&gt;The code was initially implemented in the stage deployment slot:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasdnxxpphkme3ewxllb6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasdnxxpphkme3ewxllb6.png" alt="Image description" width="800" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And after the swap operation is done, we have the result of the new implementation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq9oaj3cj5p7xgmae07d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq9oaj3cj5p7xgmae07d.png" alt="Image description" width="800" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the &lt;strong&gt;left side&lt;/strong&gt; of the image, we have our Web App with the new version of the application with the &lt;strong&gt;green feature&lt;/strong&gt; implemented. On the &lt;strong&gt;right side&lt;/strong&gt;, we have the stage slot with the old version holding the &lt;strong&gt;blue feature&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I hope this content can contribute to your journey, and if you enjoyed it please leave a comment or contact me in &lt;a href="https://linkedin.com/in/anamanzandev" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;See ya'll! 👋&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Boost your IaC development with terraform console</title>
      <dc:creator>Ana Carolina Manzan</dc:creator>
      <pubDate>Wed, 14 Aug 2024 01:23:59 +0000</pubDate>
      <link>https://dev.to/devsonclouds/boost-your-iac-development-with-terraform-console-332f</link>
      <guid>https://dev.to/devsonclouds/boost-your-iac-development-with-terraform-console-332f</guid>
      <description>&lt;p&gt;Hi devs!&lt;/p&gt;

&lt;p&gt;If you are a terraform user, you've likely already used some of the built-in functions of it, like &lt;strong&gt;&lt;em&gt;concat&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;map&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;format&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Whilst using some of these functions, &lt;strong&gt;have you ever asked yourself which would be the output of the function or even thought about testing it before incorporating it to your codebase&lt;/strong&gt;? Well, I did it, and in this post I'll show you how you can test these functions in a practical way using terraform CLI itself!&lt;/p&gt;

&lt;h2&gt;
  
  
  The terraform console command
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;terraform console&lt;/code&gt; command offers us an interactive console to which we can use to test built-in functions.&lt;/p&gt;

&lt;p&gt;To begin with the testing, start your terminal type &lt;code&gt;terraform console&lt;/code&gt;and press enter. After executing the command, the console prompt will be loaded right away. We will start by testing the function &lt;strong&gt;&lt;code&gt;max(8,5,42,12)&lt;/code&gt;&lt;/strong&gt; with a list of values like we can see in the example below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52lbbsaaoq9ncorvmw5h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52lbbsaaoq9ncorvmw5h.png" alt="Image description" width="646" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this simple test, we could validate that using &lt;strong&gt;&lt;em&gt;max&lt;/em&gt;&lt;/strong&gt; function with 8, 5, 42 and 12 as inputs, we will get the number 42 as the ouput considering it is the highest number in the list.&lt;/p&gt;

&lt;p&gt;I'll bring another test scenario here using &lt;strong&gt;&lt;code&gt;split(“,”, “Testing,terraform,functions”)&lt;/code&gt;&lt;/strong&gt;. This function is responsible for splitting our text at each comma found and transforming it in a word list, as we can check in the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88h6ofea5d47d9hmdtx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88h6ofea5d47d9hmdtx8.png" alt="Image description" width="742" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In short: in addition to the output, &lt;code&gt;terraform console&lt;/code&gt; also bring information about the output format as we may check above with the list represented by &lt;em&gt;tolist([...])&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interacting with files
&lt;/h2&gt;

&lt;p&gt;More than just testing functions, we can also use &lt;code&gt;terraform console&lt;/code&gt; to interact with Terraform files.&lt;/p&gt;

&lt;p&gt;To illustrate it, I created a file called &lt;em&gt;variables.tf&lt;/em&gt; right in the directory in which I'm performing my tests and included a variable called &lt;strong&gt;&lt;em&gt;cidr&lt;/em&gt;&lt;/strong&gt; in it. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2imvgxy3vjc0k5jqnoo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2imvgxy3vjc0k5jqnoo.png" alt="Image description" width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I set a default value of 10.1.0.0/16 for this variable, because I want to use it to calculate subnet addresses; To calculate the addresses I will use the &lt;strong&gt;&lt;em&gt;cidrsubnet&lt;/em&gt;&lt;/strong&gt; function.&lt;/p&gt;

&lt;p&gt;I would like to provide an example of a different usage of terraform console command. To do this, I will use it by adding a pipe after calling the desired function:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;echo '[for i in range(1, 5) : cidrsubnet(var.cidr, 8, i)]' | terraform console&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After running this code, we will obtain the results:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia1cnakv7xs1t9bo667n.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia1cnakv7xs1t9bo667n.jpeg" alt="Image description" width="800" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Terraform console can become a valuable tool in our daily basis as our infrastructure code base grows. It can be a powerful ally whenever we need to ensure that the code we are developing will produce the results we expect.&lt;/p&gt;

&lt;p&gt;I hope this content can contribute to your journey, and if you enjoyed it please leave a comment or contact me through LinkedIn.&lt;/p&gt;

&lt;p&gt;See ya'll! 👋&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>infrastructureascode</category>
      <category>devops</category>
      <category>devsonclouds</category>
    </item>
  </channel>
</rss>
