<?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: DongAn</title>
    <description>The latest articles on DEV Community by DongAn (@lim_cym_2fa1d7812a11592a7).</description>
    <link>https://dev.to/lim_cym_2fa1d7812a11592a7</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%2F3459377%2Fca95332b-c0da-4013-8d14-c439a9344fea.png</url>
      <title>DEV Community: DongAn</title>
      <link>https://dev.to/lim_cym_2fa1d7812a11592a7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lim_cym_2fa1d7812a11592a7"/>
    <language>en</language>
    <item>
      <title>Mastering Azure Availability Sets: Fault Domains, Update Domains, and Best Practices</title>
      <dc:creator>DongAn</dc:creator>
      <pubDate>Thu, 27 Nov 2025 04:26:42 +0000</pubDate>
      <link>https://dev.to/lim_cym_2fa1d7812a11592a7/mastering-azure-availability-sets-fault-domains-update-domains-and-best-practices-2281</link>
      <guid>https://dev.to/lim_cym_2fa1d7812a11592a7/mastering-azure-availability-sets-fault-domains-update-domains-and-best-practices-2281</guid>
      <description>&lt;p&gt;When building infrastructure in Azure, high availability is non-negotiable. One of the fundamental tools for achieving this within a single datacenter is the Availability Set.&lt;/p&gt;

&lt;p&gt;In this post, we’ll break down how Availability Sets work, the math behind Fault and Update domains, and the critical constraints you need to know.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is an Availability Set?&lt;/strong&gt;&lt;br&gt;
An Availability Set is a logical grouping capability that ensures the Virtual Machines (VMs) you place within it are distributed across multiple isolated hardware nodes in a datacenter.&lt;/p&gt;

&lt;p&gt;This distribution is crucial because it protects your applications from two specific types of disruptions:&lt;/p&gt;

&lt;p&gt;Planned Maintenance Events: Handled by Update Domains.&lt;/p&gt;

&lt;p&gt;Unplanned Hardware Failures: Handled by Fault Domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Core Components: Fault vs. Update Domains&lt;/strong&gt;&lt;br&gt;
To understand how Azure protects your VMs, you need to understand the two dimensions of an Availability Set.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fault Domains (FD)
What they are: A Fault Domain represents a group of VMs that share common physical hardware, specifically a power source and a network switch (think of it as a physical server rack).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Goal: To prevent simultaneous downtime caused by physical hardware failures (e.g., a power outage or a rack switch failure).&lt;/p&gt;

&lt;p&gt;Configuration: By default, Azure assigns 3 Fault Domains per Availability Set (in most regions).&lt;/p&gt;

&lt;p&gt;Distribution: Azure spreads your VMs across these domains. If you have 3 VMs and 3 FDs, each VM sits on a different rack.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update Domains (UD)
What they are: A logical group of hardware that can be rebooted at the same time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Goal: To protect against downtime during planned maintenance. When Azure needs to patch the underlying host OS, it will never restart more than one Update Domain at a time.&lt;/p&gt;

&lt;p&gt;Configuration: The default is 5 Update Domains, but you can increase this up to 20.&lt;/p&gt;

&lt;p&gt;Distribution: When maintenance occurs, UD1 reboots, then UD2, and so on, ensuring the other domains remain online to handle traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Logic: How VMs are Distributed&lt;/strong&gt;&lt;br&gt;
It helps to visualize how Azure places your VMs into these buckets.&lt;/p&gt;

&lt;p&gt;Example Scenario: Imagine you have an Availability Set configured with 2 Update Domains and 3 Fault Domains. You deploy 3 VMs.&lt;/p&gt;

&lt;p&gt;Update Domains: VM 1 and VM 2 might reboot first (UD0), followed by VM 3 (UD1).&lt;/p&gt;

&lt;p&gt;Fault Domains: Each of the 3 VMs is placed on separate physical hardware (Rack 1, Rack 2, Rack 3) to maximize survival during a power outage.&lt;/p&gt;

&lt;p&gt;The "Bucket" Calculation&lt;br&gt;
What happens if you have more VMs than domains? They wrap around.&lt;/p&gt;

&lt;p&gt;Let's say you have 14 VMs and you configured 10 Update Domains.&lt;/p&gt;

&lt;p&gt;The Math:&lt;/p&gt;

&lt;p&gt;The first 10 VMs fill UD0 through UD9.&lt;/p&gt;

&lt;p&gt;The remaining 4 VMs wrap around and are placed in UD0 through UD3.&lt;/p&gt;

&lt;p&gt;The Result:&lt;/p&gt;

&lt;p&gt;4 Domains (UD0–UD3) contain 2 VMs each.&lt;/p&gt;

&lt;p&gt;6 Domains (UD4–UD9) contain 1 VM each.&lt;/p&gt;

&lt;p&gt;Risk Assessment: During a patch cycle for UD0, only 2 VMs will go offline simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Constraints &amp;amp; "Gotchas"&lt;/strong&gt;&lt;br&gt;
Availability Sets are powerful, but they come with strict rules.&lt;/p&gt;

&lt;p&gt;Creation Only: You cannot add an existing, running VM to an Availability Set. You must define the Availability Set at the time of VM creation. If you need to add a VM later, you will have to recreate it.&lt;/p&gt;

&lt;p&gt;Fixed Counts: Once the Availability Set is created, you cannot modify the number of Fault Domains or Update Domains. Plan ahead!&lt;/p&gt;

&lt;p&gt;Managed Disks: Always use Managed Disks with your Availability Sets. This ensures that the disks are also placed in different storage clusters aligned with the Fault Domains, preventing a single storage failure from taking down the whole set.&lt;/p&gt;

&lt;p&gt;The Resizing Rule&lt;br&gt;
This is a common headache for administrators. If you need to resize a VM within an Availability Set (specifically to a size that requires different physical hardware), you often cannot just resize that one VM.&lt;/p&gt;

&lt;p&gt;The Rule: You must stop (deallocate) ALL VMs in the Availability Set first.&lt;/p&gt;

&lt;p&gt;The Reason: All running VMs in an Availability Set must reside on the same physical hardware cluster type. To move to a new size that the current cluster doesn't support, the entire set must be moved to a new cluster that supports the new size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
Fault Domains = Protection against Hardware/Power failures (Racks).&lt;/p&gt;

&lt;p&gt;Update Domains = Protection against Microsoft Patching/Reboots.&lt;/p&gt;

&lt;p&gt;Strategy: Combine Availability Sets with a Load Balancer to ensure your application remains accessible even when specific domains are down.&lt;/p&gt;

</description>
      <category>availability</category>
      <category>updatedomains</category>
      <category>faultdomains</category>
      <category>azure</category>
    </item>
    <item>
      <title>Resolve errors in "Build flexible Bicep files by using conditions and loops - Unit 5_Exercise."</title>
      <dc:creator>DongAn</dc:creator>
      <pubDate>Wed, 24 Sep 2025 15:45:51 +0000</pubDate>
      <link>https://dev.to/lim_cym_2fa1d7812a11592a7/resolve-errors-in-build-flexible-bicep-files-by-using-conditions-and-loops-unit-5exercise-4fgc</link>
      <guid>https://dev.to/lim_cym_2fa1d7812a11592a7/resolve-errors-in-build-flexible-bicep-files-by-using-conditions-and-loops-unit-5exercise-4fgc</guid>
      <description>&lt;p&gt;Several issues lead to errors in Unit 5, "Exercise - Deploy multiple resources by using loops," within the "Build flexible Bicep files by using conditions and loops" module on Microsoft Learn. Primarily, the main.bicep file lacks an environmentName parameter. This omission prevents control over the deployment environment, limiting the exercise to the creation of only the SQL server and SQL database, even when following the provided steps.&lt;/p&gt;

&lt;p&gt;You can add the following snippet to your main.bicep file to solve the problem.&lt;br&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%2F9hfhtlachzs2ewp0l5y5.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%2F9hfhtlachzs2ewp0l5y5.png" alt=" " width="800" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another issue that can cause deployment failure is related to the Microsoft Learn sandbox. Due to unknown issues, attempting to deploy resources via Bicep code in the sandbox repeatedly led to my temporary account being deactivated. Even with remaining usage attempts, and after waiting for four hours to create a new account, the problem persisted. Therefore, for this exercise, it may be necessary to use an Azure pay-as-you-go account to complete the task.&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%2Fhsyi3xn5furtstdwkk3q.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%2Fhsyi3xn5furtstdwkk3q.png" alt=" " width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Managing the environment with Azure CLI:&lt;br&gt;
az deployment group create --resource-group Your-RG-Name --name main --template-file main.bicep --parameters environmentName=Production&lt;/p&gt;

&lt;p&gt;After a successful deployment, your resource group should include the following resources:&lt;br&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%2Fru4uyitalevfu9gyuw3o.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%2Fru4uyitalevfu9gyuw3o.png" alt=" " width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>microsoft</category>
      <category>azure</category>
      <category>devops</category>
    </item>
    <item>
      <title>The Concepts of building Reusable and Secure Azure Infrastructure with Bicep</title>
      <dc:creator>DongAn</dc:creator>
      <pubDate>Tue, 23 Sep 2025 14:32:36 +0000</pubDate>
      <link>https://dev.to/lim_cym_2fa1d7812a11592a7/building-reusable-and-secure-azure-infrastructure-with-bicep-41kb</link>
      <guid>https://dev.to/lim_cym_2fa1d7812a11592a7/building-reusable-and-secure-azure-infrastructure-with-bicep-41kb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
In modern cloud adoption, the ability to deploy infrastructure reliably and consistently across multiple environments is not just a convenience—it's a necessity. This post details a project focused on a common and critical business scenario: migrating an on-premises web application and its database to Microsoft Azure.&lt;/p&gt;

&lt;p&gt;The primary goal was to leverage Infrastructure as Code (IaC) to prepare the cloud infrastructure for three distinct environments: development, testing, and production. By using Bicep, we created a single, reusable template to ensure that each environment is a perfect replica of the others, eliminating configuration drift and streamlining the deployment process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Core Concepts&lt;/strong&gt;&lt;br&gt;
This project was built on three foundational pillars of modern cloud architecture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Infrastructure as Code (IaC) with Bicep&lt;br&gt;
Instead of manually creating resources through the Azure portal, we defined the entire infrastructure—an Azure App Service, its underlying plan, a SQL Server, and a SQL Database—in a declarative Bicep file. This approach treats infrastructure like application code: it's versioned, repeatable, and automated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusability Through Parameterization&lt;br&gt;
A single template was used for all environments. This was achieved by externalizing all environment-specific configurations (like resource names, pricing tiers, and instance counts) into parameters. We then used separate parameter files for each environment, making it easy to deploy a cost-effective "Free" tier for development and a resilient "Premium" tier for production without changing a single line of the core Bicep code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security-First with Azure Key Vault&lt;br&gt;
Handling secrets like database credentials is the most critical aspect of automating infrastructure. This project integrated directly with Azure Key Vault. Instead of storing sensitive values in our code or parameter files, we stored them securely in a vault. The parameter file contains only a reference to the secret, not the secret itself. During deployment, the Azure Resource Manager engine uses this reference to fetch the secret securely, ensuring credentials are never exposed in our codebase.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Fi5qukgg2fjdt5semmmhb.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%2Fi5qukgg2fjdt5semmmhb.png" alt=" " width="800" height="802"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Workflow&lt;/strong&gt;&lt;br&gt;
The end-to-end process was designed for security and automation:&lt;/p&gt;

&lt;p&gt;Setup the Vault: First, we created an Azure Key Vault and securely stored the SQL administrator login and password as secrets.&lt;/p&gt;

&lt;p&gt;Define the Infrastructure (main.bicep): We authored a comprehensive Bicep template that defined all resources and used parameters for dynamic values. We used decorators like @allowed and &lt;a class="mentioned-user" href="https://dev.to/secure"&gt;@secure&lt;/a&gt; to enforce governance and security rules directly in the code.&lt;/p&gt;

&lt;p&gt;Configure the Environment (parameters.dev.json): For each environment, we created a corresponding parameter file. This file specified the SKU for the App Service, the SKU for the database, and, most importantly, the references to the secrets in Azure Key Vault.&lt;/p&gt;

&lt;p&gt;Deploy with Azure CLI: The final step was a single Azure CLI command that combined the Bicep template with an environment-specific parameter file to deploy the resources. The process is idempotent, meaning we can run it repeatedly to enforce our desired configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways and Conclusion&lt;/strong&gt;&lt;br&gt;
This project successfully demonstrates a best-practice approach to cloud infrastructure management. The key takeaways are:&lt;/p&gt;

&lt;p&gt;Parameter Hierarchy is Crucial: Understanding that command-line parameters override parameter files, which in turn override defaults in Bicep, is key to building flexible templates.&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%2Fsk2obyp7xswkfanseirn.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%2Fsk2obyp7xswkfanseirn.png" alt=" " width="737" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Decorators Enforce Governance: Using decorators like @allowed and &lt;a class="mentioned-user" href="https://dev.to/secure"&gt;@secure&lt;/a&gt; shifts governance left, preventing non-compliant deployments before they even start.&lt;/p&gt;

&lt;p&gt;Key Vault is Non-Negotiable for Secrets: The reference mechanism in parameter files is a simple yet powerful feature that enables a secure, auditable, and automated deployment pipeline.&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%2Fvzjwrojluxpzslnqe3h8.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%2Fvzjwrojluxpzslnqe3h8.png" alt=" " width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By embracing these principles, any organization can build a robust, secure, and efficient process for managing its cloud infrastructure.&lt;/p&gt;

</description>
      <category>iac</category>
      <category>bicep</category>
      <category>azure</category>
      <category>devops</category>
    </item>
    <item>
      <title>Auto-Adding Tags with Azure Policy</title>
      <dc:creator>DongAn</dc:creator>
      <pubDate>Thu, 11 Sep 2025 16:42:53 +0000</pubDate>
      <link>https://dev.to/lim_cym_2fa1d7812a11592a7/auto-adding-tags-with-azure-policy-5doc</link>
      <guid>https://dev.to/lim_cym_2fa1d7812a11592a7/auto-adding-tags-with-azure-policy-5doc</guid>
      <description>&lt;p&gt;Managing resources in Azure can quickly become complex, especially when it comes to cost management, governance, and organization. Tags are your best friend here, allowing you to categorize resources, but manually applying them is tedious and error-prone. This post will guide you on how to use Azure Policy to &lt;strong&gt;automatically add a tag and its value to newly created resources&lt;/strong&gt;, explain a common mistake (like the one I faced!), and show you how to apply tags to existing resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Goal: Auto-Apply a "Cost Center" Tag
&lt;/h2&gt;

&lt;p&gt;Imagine you want every new resource created within a specific Resource Group to automatically get a &lt;code&gt;Cost Center&lt;/code&gt; tag with a value of &lt;code&gt;000&lt;/code&gt;. This helps track expenses and assign accountability.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Previous Policy: A Common Pitfall (and why it didn't work)
&lt;/h2&gt;

&lt;p&gt;I initially tried to achieve this by assigning a policy, thinking it would simply add the tag. However, I kept running into a &lt;strong&gt;"Validation failed: Required information is missing or not valid"&lt;/strong&gt; error when deploying new resources.&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%2Fcb6jww71rd4qr8qxzkx6.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%2Fcb6jww71rd4qr8qxzkx6.png" alt=" " width="800" height="201"&gt;&lt;/a&gt;&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%2Fop4fpyl91dcd32g73yrw.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%2Fop4fpyl91dcd32g73yrw.png" alt=" " width="800" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's why my previous approach likely failed:&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem: Using a "Deny" Policy for Tagging
&lt;/h3&gt;

&lt;p&gt;My policy assignment, while appearing to enforce a tag, actually had a &lt;strong&gt;"Deny" effect&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What a "Deny" Policy Does:&lt;/strong&gt; A "Deny" policy acts as a gatekeeper. It checks if the conditions (e.g., "does this resource have the 'Cost Center' tag?") are met &lt;em&gt;before&lt;/em&gt; the resource is allowed to be created or updated. If the condition isn't met (i.e., the tag is missing), the deployment is &lt;strong&gt;blocked&lt;/strong&gt;, and you receive a validation error. It doesn't modify anything; it just says "No."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why it didn't work for auto-tagging:&lt;/strong&gt; I wanted the tag to be &lt;em&gt;added automatically&lt;/em&gt;, not for the deployment to fail if it was missing. A "Deny" policy is excellent for ensuring compliance (e.g., "NEVER deploy a VM without a 'Owner' tag"), but not for automatic remediation or addition.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Solution: The "Modify" Policy Effect
&lt;/h2&gt;

&lt;p&gt;To automatically add or update tags, you need to use a policy definition with the &lt;strong&gt;&lt;code&gt;Modify&lt;/code&gt; effect&lt;/strong&gt;. This effect actively intervenes during resource creation/update to ensure compliance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to Auto-Add a Tag Using Azure Policy (Modify Effect)
&lt;/h3&gt;

&lt;p&gt;I will use the built-in policy definition: &lt;strong&gt;"Inherit a tag from the resource group if it is missing."&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Navigate to Azure Policy:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Azure portal, search for and select &lt;strong&gt;"Policy."&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Delete Conflicting Policies (if any):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you have a previous "Deny" policy assignment related to the tag you're trying to auto-add, you &lt;em&gt;must&lt;/em&gt; remove it first.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Assignments&lt;/strong&gt; on the left menu.&lt;/li&gt;
&lt;li&gt;Find your old policy assignment (e.g., "Inherit the Cost Center tag...") and click the &lt;code&gt;...&lt;/code&gt; (ellipses) next to it.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Delete assignment&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Assign the "Inherit a tag from the resource group if it is missing" Policy:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Back in the &lt;strong&gt;Policy&lt;/strong&gt; service, go to &lt;strong&gt;Assignments&lt;/strong&gt; and click &lt;strong&gt;Assign policy&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scope:&lt;/strong&gt; Choose the Management Group, Subscription, or &lt;strong&gt;Resource Group&lt;/strong&gt; where new resources will be created. This is crucial for defining &lt;em&gt;where&lt;/em&gt; the policy applies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy definition:&lt;/strong&gt; Click the &lt;code&gt;...&lt;/code&gt; next to "Policy definition" and search for &lt;code&gt;Inherit a tag from the resource group&lt;/code&gt;. Select the definition named &lt;strong&gt;"Inherit a tag from the resource group if it is missing"&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameters:&lt;/strong&gt; Go to the "Parameters" tab.

&lt;ul&gt;
&lt;li&gt;For &lt;strong&gt;Tag Name&lt;/strong&gt;, enter &lt;code&gt;Cost Center&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;Tag value&lt;/strong&gt;, you can leave it blank (it will inherit the value from the RG itself) or specify a default like &lt;code&gt;000&lt;/code&gt; if your RG doesn't have it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crucial Setup:&lt;/strong&gt; Ensure the Resource Group you're scoping this to &lt;em&gt;itself&lt;/em&gt; has the &lt;code&gt;Cost Center&lt;/code&gt; tag with the value &lt;code&gt;000&lt;/code&gt;. The policy inherits the tag &lt;em&gt;from&lt;/em&gt; the resource group.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remediation (for existing resources - discussed below):&lt;/strong&gt; For now, you can leave "Create a remediation task" unchecked. We'll explain this in the next section.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Review + create&lt;/strong&gt;, then &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Now, whenever you create a new resource within the assigned scope (your Resource Group), if it doesn't already have a &lt;code&gt;Cost Center&lt;/code&gt; tag, Azure Policy will automatically add it with the value from the parent Resource Group!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Remediation: Applying Tags to Existing Resources
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Modify&lt;/code&gt; effect primarily works on &lt;em&gt;newly created&lt;/em&gt; or &lt;em&gt;updated&lt;/em&gt; resources. What about resources that already exist in your Resource Group and are missing the &lt;code&gt;Cost Center&lt;/code&gt; tag?&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;Remediation Tasks&lt;/strong&gt; come in.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;After assigning the "Modify" policy:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;strong&gt;Policy&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Remediation&lt;/strong&gt; in the Azure portal.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;+ New remediation task&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select your newly assigned policy (e.g., "Inherit a tag from the resource group if it is missing").&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;scope&lt;/strong&gt; (Resource Group) you want to target.&lt;/li&gt;
&lt;li&gt;Azure will identify non-compliant resources within that scope.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Remediate&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&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%2Fybcf1bcf6wync98gx1jl.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%2Fybcf1bcf6wync98gx1jl.png" alt=" " width="800" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This task will go through all existing resources in the specified scope that are non-compliant (i.e., missing the &lt;code&gt;Cost Center&lt;/code&gt; tag) and apply the tag and its inherited value, bringing them into compliance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;strong&gt;&lt;code&gt;Modify&lt;/code&gt; policy effect&lt;/strong&gt; to automatically add or update tags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid &lt;code&gt;Deny&lt;/code&gt; policies&lt;/strong&gt; if your goal is auto-tagging; they will block deployments.&lt;/li&gt;
&lt;li&gt;Ensure the parent resource (like the Resource Group) &lt;strong&gt;itself has the tag&lt;/strong&gt; if your policy is set to "inherit" the tag value.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Remediation Tasks&lt;/strong&gt; to apply policies to existing, non-compliant resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By leveraging Azure Policy with the correct effects, you can enforce robust tagging strategies across your environment, improving governance and cost management without manual intervention.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Local development environment configuration for Azure CLI</title>
      <dc:creator>DongAn</dc:creator>
      <pubDate>Sun, 31 Aug 2025 03:40:40 +0000</pubDate>
      <link>https://dev.to/lim_cym_2fa1d7812a11592a7/local-development-environment-configuration-for-azure-cli-3d6k</link>
      <guid>https://dev.to/lim_cym_2fa1d7812a11592a7/local-development-environment-configuration-for-azure-cli-3d6k</guid>
      <description>&lt;p&gt;&lt;strong&gt;Install the following tools&lt;/strong&gt;: &lt;br&gt;
● Visual Studio Code with Azure Extensions &lt;br&gt;
● The Azure CLI &lt;br&gt;
● Configure your local Python environment for Azure &lt;br&gt;
● The Azure Functions Core Tools, for local development of serverless functions. &lt;/p&gt;

&lt;p&gt;Authenticate from your local shell. let Azure pop open a browser and go through their OAuth flow to authenticate you.&lt;/p&gt;

&lt;p&gt;You can go to your local command prompt, and launch Azure Cloud Shell.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You need to open the link that the shell prompted, and enter Azure provided code. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the authenticated, hit y to login.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Fhug9k1e2780uft51xbqd.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%2Fhug9k1e2780uft51xbqd.png" alt=" " width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before you can use Azure Cloud Shell, you must register the &lt;strong&gt;Microsoft.CloudShell&lt;/strong&gt; resource provider. Access to resources is enabled through provider namespaces that must be registered in your subscription.&lt;/p&gt;

&lt;p&gt;1.On your subscription page, expand Settings in left menu and select Resource providers.&lt;/p&gt;

&lt;p&gt;2.In the Filter by name... box, enter cloudshell to search for the resource provider.&lt;/p&gt;

&lt;p&gt;3.Select the Microsoft.CloudShell resource provider from the provider list.&lt;/p&gt;

&lt;p&gt;4.Select Register to change the status from unregistered/Re-register to Registered&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%2Fxypbwuto2q31zhv626mq.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%2Fxypbwuto2q31zhv626mq.png" alt=" " width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PS: The first time you start Cloud Shell you're prompted to create an Azure Storage account for the Azure file share.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set your subscription&lt;/strong&gt;&lt;br&gt;
1.List subscriptions you have access to:&lt;br&gt;
&lt;em&gt;az account list&lt;/em&gt;&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%2F7orf5vwws2xpoimuhbdr.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%2F7orf5vwws2xpoimuhbdr.png" alt=" " width="760" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default, the command returns a JSON array. Each object in the array represents one Azure subscription and contains several key-value pairs.&lt;br&gt;
name: The human-readable name of the subscription (e.g., "My Development Subscription").&lt;/p&gt;

&lt;p&gt;id: The unique Subscription ID (a GUID). This is crucial for many CLI commands to specify which subscription you want to work with.&lt;/p&gt;

&lt;p&gt;isDefault: A boolean (true or false) that indicates which subscription is currently active for your CLI session. Any commands you run will target the subscription where isDefault is true.&lt;/p&gt;

&lt;p&gt;state: The current status of the subscription, most commonly "Enabled".&lt;/p&gt;

&lt;p&gt;tenantId: The Microsoft Entra ID (formerly Azure Active Directory) tenant that the subscription belongs to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changing the Output Format&lt;/strong&gt;&lt;br&gt;
The default JSON output is great for scripting but can be hard to read. Use the &lt;strong&gt;--output&lt;/strong&gt; (or -o) flag for better formatting.&lt;br&gt;
&lt;em&gt;az account list --output table&lt;/em&gt;&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%2F0f5a1tj6by7ab935lf68.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%2F0f5a1tj6by7ab935lf68.png" alt=" " width="800" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This command will display the subscriptions in a clean, tabular format, which is much easier for human eyes.&lt;/p&gt;

&lt;p&gt;2.Set the active subscription for your session:&lt;br&gt;
&lt;em&gt;az account set --subscription 'my-subscription-name/my-subscription-ID'&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;PS: When you're done building something and don't need to run it anymore, delete the Azure resource group out of your organization. (If you've used proper infrastructure-as-code(IaC), you haven't lost anything - you can just deploy the code in a new account later!)&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
