<?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 Desmond Harris Fernando on Medium]]></title>
        <description><![CDATA[Stories by Desmond Harris Fernando on Medium]]></description>
        <link>https://medium.com/@desmond80in?source=rss-36cefa51daac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*24cMPhoLKfWNzIdmXF_34g.jpeg</url>
            <title>Stories by Desmond Harris Fernando on Medium</title>
            <link>https://medium.com/@desmond80in?source=rss-36cefa51daac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:38:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@desmond80in/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[Stop Fine-Tuning BERT for Everything — A Practical Guide to When It Actually Matters]]></title>
            <link>https://medium.com/@desmond80in/stop-fine-tuning-bert-for-everything-a-practical-guide-to-when-it-actually-matters-7b53854e1b11?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b53854e1b11</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bert]]></category>
            <category><![CDATA[nlp-training]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 14:09:33 GMT</pubDate>
            <atom:updated>2026-02-11T14:09:33.682Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Every few months, a new team proudly ships a fine-tuned BERT model for a problem that could have been solved with ten lines of regex. Fine-tuning has become the default instinct in NLP — but defaults are expensive. This guide is about building the judgment to know when fine-tuning is a genuine force multiplier and when it’s an over-engineered detour. Whether you’re an ML engineer evaluating your next approach or a team lead deciding where to invest compute budget, this article gives you a practical framework for making that call — along with the use cases where fine-tuning truly shines and the anti-patterns that quietly burn time and money.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gR-zz3KVIOLhH3OLmXpOw.png" /></figure><h3><strong>Introduction to BERT</strong></h3><p>BERT (Bidirectional Encoder Representations from Transformers) is a foundational language model developed by Google in 2018 that fundamentally changed the landscape of Natural Language Processing (NLP). Unlike earlier models that read text either left-to-right or right-to-left, BERT processes text bidirectionally, meaning it considers the full context of a word by looking at all surrounding words simultaneously.</p><p>At its core, BERT is a transformer-based model pre-trained on massive amounts of text data using two key objectives: Masked Language Modeling (MLM), where the model learns to predict randomly masked words in a sentence, and Next Sentence Prediction (NSP), where it learns relationships between sentence pairs. This pre-training gives BERT a deep, general understanding of language structure, grammar, and semantics.</p><p>The key insight behind BERT is transfer learning: the model learns generalizable language representations from large-scale pre-training, which can then be adapted to specific downstream tasks through fine-tuning with relatively small amounts of labeled data.</p><h3><strong>What is Fine-Tuning?</strong></h3><p>Fine-tuning is the process of taking a pre-trained model and adapting it to a specific task or domain by training it further on a smaller, task-specific dataset. Rather than training a model from scratch, which requires enormous compute resources and data, fine-tuning leverages the knowledge already captured during pre-training and refines it.</p><h4>How Fine-Tuning Works</h4><p>The fine-tuning process typically involves three stages:<br> <strong>Load the pre-trained model: </strong>Start with a BERT checkpoint that has already been trained on large corpora and understands general language patterns. <strong>Add a task-specific layer: </strong>Attach a classification head, regression layer, or other architecture on top of the BERT encoder that is tailored to your downstream task.<br> <strong>Train on your data: </strong>Train the entire model (or selected layers) on your labeled, task-specific dataset using a lower learning rate to preserve pre-trained knowledge while adapting to new patterns.</p><p>The critical difference between fine-tuning and training from scratch is that fine-tuning starts from an informed position. The model already understands syntax, semantics, entity relationships, and contextual nuance. Fine-tuning simply steers that understanding toward your specific problem.</p><h4>Fine-Tuning vs. Other Approaches</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*alyv_f7ZFRhNwUpMyPSSAw.png" /></figure><h3><strong>When to Use Model Fine-Tuning</strong></h3><p>Fine-tuning is not always the right answer. Understanding when it adds genuine value versus when simpler approaches suffice is essential for making sound engineering and business decisions. Below are the primary use cases where fine-tuning delivers the most impact.</p><p><strong>Use Case 1: Domain-Specific Text Classification<br></strong>When you need to classify text in specialized domains such as medical records, legal documents, or financial filings, general-purpose models often lack the vocabulary and contextual understanding required. Fine-tuning BERT on domain-specific labeled data dramatically improves classification accuracy. For example, fine-tuning on clinical notes to detect patient risk levels, or on legal contracts to identify clause types.<br><strong>Use Case 2: Named Entity Recognition (NER)<br></strong>Extracting domain-specific entities like drug names, gene sequences, financial instruments, or proprietary product codes requires the model to learn patterns that do not exist in general training data. Fine-tuning is highly effective here because BERT can learn the contextual cues surrounding custom entity types in your corpus.<br><strong>Use Case 3: Sentiment Analysis with Nuance<br></strong>While off-the-shelf sentiment models work for generic reviews, industries with specialized language, sarcasm patterns, or domain jargon (such as gaming communities, financial analyst reports, or healthcare patient feedback) benefit significantly from fine-tuned models that understand the subtlety of sentiment within that context.<br><strong>Use Case 4: Semantic Similarity and Matching<br></strong>Tasks like duplicate question detection, semantic search, or document similarity in specialized fields benefit from fine-tuning. For instance, matching support tickets to knowledge base articles, or identifying semantically similar but lexically different research papers in a specific academic field.<br><strong>Use Case 5: Question Answering in Closed Domains<br></strong>Building Q&amp;A systems over proprietary documentation, internal wikis, or specialized knowledge bases becomes significantly more accurate when the model is fine-tuned on question-answer pairs drawn from that specific domain.<br><strong>Use Case 6: Intent Detection and Slot Filling<br></strong>Conversational AI systems and chatbots that need to understand user intent and extract specific parameters (slots) from utterances in a particular domain, such as booking systems, customer service, or technical support, benefit from fine-tuned BERT models that understand the specific intents and entities relevant to the application.</p><h3><strong>How to Decide If Fine-Tuning Is a Must</strong></h3><p>Before committing resources to fine-tuning, teams should evaluate several key factors to determine whether the investment will yield a meaningful return.<br><strong>Decision Framework</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*iGAp6nfVyoAtPWoZh1iYDQ.png" /></figure><p><strong>The ROI Test<br></strong>Consider fine-tuning worth the investment when at least three of the following conditions are true: your domain language is highly specialized, a baseline general model performs below acceptable thresholds, you have access to sufficient labeled training data, the task will be executed at high volume over a sustained period, and latency or data privacy requirements rule out hosted LLM APIs.</p><h3><strong>Advntages of Model Fine-Tuning</strong></h3><p><strong>Superior domain accuracy: </strong>Fine-tuned models consistently outperform general-purpose models on specialized tasks by 10–30% in accuracy, particularly in domains with unique vocabulary and patterns.<br><strong>Cost-effective at scale: </strong>Once trained, a fine-tuned model can serve millions of inference requests at a fraction of the cost of per-token LLM API pricing. Hosting a BERT model is significantly cheaper than high-volume GPT-4 or Claude API usage.<br><strong>Low latency inference: </strong>Fine-tuned BERT models can deliver predictions in single-digit milliseconds on GPU infrastructure, making them ideal for real-time applications like search ranking, content moderation, and fraud detection.<br><strong>Data privacy and control: </strong>Models can be deployed entirely on-premise or in private cloud environments, ensuring sensitive data never leaves your infrastructure.<br><strong>Compact and efficient: </strong>Fine-tuned models like DistilBERT or TinyBERT can be optimized for edge deployment, mobile devices, or resource-constrained environments while maintaining strong performance.<br><strong>Reproducible and deterministic: </strong>Unlike LLM API calls that may change behavior with model updates, a fine-tuned model produces consistent, versioned outputs that can be tested and validated.<br><strong>Customizable confidence thresholds: </strong>You can set precision-recall tradeoffs, confidence thresholds, and decision boundaries tailored to your specific business requirements.</p><h3><strong>Anti-Patterns of Model Fine-Tuning</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XBBtmLzCsULbr95vsGtlVw.png" /></figure><p>While fine-tuning is powerful, there are common mistakes and misapplications that teams should actively avoid. Recognizing these anti-patterns can save significant time, money, and frustration.<br><strong>Anti-Pattern 1: Fine-Tuning When Prompt Engineering Suffices<br></strong>If a well-crafted prompt to a general-purpose LLM achieves 90%+ accuracy on your task, fine-tuning a separate model introduces unnecessary complexity. Always benchmark a prompt-based approach before committing to fine-tuning. Many classification and extraction tasks can be solved with zero-shot or few-shot prompting.<br><strong>Anti-Pattern 2: Insufficient or Poor-Quality Training Data<br></strong>Fine-tuning on a few dozen noisy examples will produce a model that overfits to noise rather than learning meaningful patterns. The minimum viable dataset varies by task, but attempting fine-tuning with fewer than 500 labeled examples for classification, or without rigorous data quality checks, is a common and costly mistake.<br><strong>Anti-Pattern 3: Ignoring Class Imbalance<br></strong>Training on a dataset where 95% of examples belong to one class will produce a model that effectively ignores minority classes. Without proper stratification, oversampling, or loss weighting, the fine-tuned model will appear to have high accuracy while failing on the cases that matter most.<br><strong>Anti-Pattern 4: Not Establishing a Baseline<br></strong>Jumping directly to fine-tuning without first testing simpler approaches (rule-based systems, TF-IDF classifiers, pre-trained embeddings with logistic regression) makes it impossible to know whether the additional complexity of fine-tuning is justified. Always establish a baseline to measure the marginal improvement.<br><strong>Anti-Pattern 5: Overfitting to the Training Set</strong><br>Training for too many epochs, using an excessively high learning rate, or not using a validation set leads to models that perform brilliantly on training data but fail in production. Common symptoms include near-perfect training accuracy with poor generalization. Use early stopping, proper train/validation/test splits, and cross-validation.<br><strong>Anti-Pattern 6: Fine-Tuning for Structured Data Tasks<br></strong>Applying BERT fine-tuning to tasks that are fundamentally about structured data matching, such as record deduplication with clean fields like name, email, and company, is an anti-pattern. Traditional techniques like fuzzy string matching, Jaro-Winkler similarity, and probabilistic record linkage are more appropriate, interpretable, and efficient for structured data problems.<br><strong>Anti-Pattern 7: One-and-Done Training<br></strong>Deploying a fine-tuned model without monitoring for data drift, performance degradation, or distributional shifts is a recipe for silent failure. Language evolves, business contexts change, and models need periodic retraining. Treat fine-tuning as a continuous process, not a one-time project.<br><strong>Anti-Pattern 8: Neglecting Model Evaluation Rigor<br></strong>Relying solely on accuracy as the evaluation metric, especially for imbalanced datasets, leads to misleading conclusions. A comprehensive evaluation should include precision, recall, F1-score per class, confusion matrices, and ideally, performance on edge cases and adversarial examples specific to your domain.</p><h3>Conclusion</h3><p>BERT fine-tuning remains one of the most effective techniques in the NLP toolkit when applied to the right problems. It excels in domain-specific text understanding, offers cost and latency advantages at scale, and provides the data privacy guarantees that many enterprises require.</p><p>However, the decision to fine-tune should be deliberate and data-driven. Start with simpler baselines, validate that your data is sufficient and high-quality, and ensure the problem genuinely requires deep contextual language understanding rather than simpler pattern matching. When these conditions are met, fine-tuning delivers transformative results. When they are not, it becomes an expensive distraction from more appropriate solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b53854e1b11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Introduction to Gemini CLI: A Developer’s Honest Take]]></title>
            <link>https://medium.com/@desmond80in/my-introduction-to-gemini-cli-a-developers-honest-take-e15a5a5f2dd8?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/e15a5a5f2dd8</guid>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[google-gemini-cli]]></category>
            <category><![CDATA[tech-reviews]]></category>
            <category><![CDATA[ｐｒｏｇｒａｍｍｉｎｇ]]></category>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Sun, 29 Jun 2025 04:08:13 GMT</pubDate>
            <atom:updated>2025-06-29T04:14:38.777Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I dove into the world of Gemini CLI after watching [<a href="https://www.youtube.com/watch?v=CqL5kB8pOfo">aiwithbrandon’s YouTube walkthrough</a>]. The video was a game-changer, giving me the confidence and practical steps to get hands-on with Google’s latest AI-powered command-line tool. Huge thanks to the creator for making the learning curve feel almost non-existent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pY6Hwz6auUdhBfoFW4wjbQ.jpeg" /></figure><h3>First Impressions: Installation and Setup</h3><p>Gemini CLI immediately impressed me with its straightforward setup. If you have Node.js installed, it’s just a couple of commands and a Google login before you’re ready to go. The onboarding process is smooth, and you get access to Gemini 2.5 Pro’s powerful model for free, with generous daily limits.</p><h3>Experimenting with Real Projects</h3><p>Inspired by the demo, I was eager to see if Gemini CLI could adapt to my coding style and integrate with an existing project. At first, it didn’t quite “get” my approach, but after a few rounds of code edits and feedback, I noticed it started to align more with my conventions. The tool generated code snippets quickly — sometimes faster than I expected — which was both exciting and a little intimidating. It sparked the classic developer anxiety: “Will AI take my job?”</p><h3>The Integration Hurdle</h3><p>The real test came when I tried to merge Gemini-generated code into my main system. What followed was a cycle of tweaks and suggestions — some helpful, others leading me in circles. It felt like wandering in a desert, chasing mirages of a perfect solution. Eventually, I paused and solved the integration issue myself in under a minute, a stark reminder that AI is a powerful assistant, not a replacement for developer intuition.</p><h3>Comparing Gemini CLI to Other Tools</h3><p>In my experience, Claude AI outperformed Gemini CLI in terms of code generation and understanding complex requirements. However, Gemini CLI shines at handling basic tasks, managing repositories, writing documentation, and making detailed commit messages. Its integration with Google search and other tools directly from the terminal is a unique strength.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*SeJKrh5l66a-MEUmpaVd7g.png" /></figure><h3>Lessons Learned</h3><ul><li>Know your tools’ strengths and weaknesses. Gemini CLI is great for boilerplate, documentation, and quick fixes, but don’t rely on it for complex problem-solving.</li><li>AI can accelerate your workflow, but human insight is irreplaceable — especially when you’re stuck.</li><li>The best developers will be those who understand when to leverage AI and when to trust their own experience.</li></ul><h3>Final Thoughts</h3><p>Gemini CLI is a solid addition to the developer’s toolkit, especially for managing repositories and automating routine tasks. It’s not perfect, and it won’t replace thoughtful problem-solving, but used wisely, it can boost productivity and free up time for more creative coding.</p><p>If you’re curious, give it a try — but remember: the best results come when you combine AI’s speed with your own expertise</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e15a5a5f2dd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clara and the Evil Witch]]></title>
            <link>https://medium.com/@desmond80in/clara-and-the-evil-witch-dde26e452b79?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/dde26e452b79</guid>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Wed, 27 Nov 2024 11:08:02 GMT</pubDate>
            <atom:updated>2024-11-27T11:08:02.063Z</atom:updated>
            <content:encoded><![CDATA[<p>Once upon a time, there was a little girl named Clara and she loved to play with her animal friends. There were all types of animals you could ever find in the whole world like lions, tigers, monkeys, and even snakes! Little Clara was not scared of any animal, she loved them with all her heart. She also lived in a castle with its own jungle and lake for her little animal friends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*2eUoItc35aQMg8KGqMEZlw.png" /></figure><p>Now you might think that Clara lived a happy life and the story ends there but, opposite to the village far far away there was an evil witch and her name was Bella the Great. She was not “great” as in her name because, she casts evil spells among poor animals and make them into demons. Clara was very angry about this act. She was willing to stop this right away but she couldn’t because she was not of age. You see many brave people have tried fighting Bella the Great but, it ended tragically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*HKMNNvWhYN7IlcUPCpapsA.png" /></figure><p>Although it was not the same for Clara, the little girl was eager to fight this witch. Years later, Clara turned eighteen and it was time for her to fight the evil witch. She packed her bag which only had one loaf of cheese bread and a bottle of wine. As for her animals she took all of them making sure not to leave one behind. The girl had a long path she had to swim through the lake, climb the mountain, walk the dessert and cross the icy tundra. Although it may seem challenging to any human being, Clara did it with ease with the help of her animal friends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*W7MswOqF0qup7NkiRWLisw.png" /></figure><p>When she reached Bella the Great’s castle, Clara was shocked! There were so many dead people and demonized animals but there was no sign of Clara and the Evil Witch Bella the Great. Then out of no where came an evil laughing sound, it was the evil witch! The girl, Clara got startled by the witch’s laughter. “It is time to fight the evil witch”, Clara thought. Clara gathered all her animals and told them to fight and be loyal no matter what, the animals believed in Clara very much that they did what Clara told them to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*QXj7bcmLjGGOEGVnshXsIQ.png" /></figure><p>Guess what! The evil witch got defeated by Clara and the animals and all the demonized animals were transformed into their normal selves. The animals that were trapped thanked Clara and they all journeyed their way back to the village. Everyone praised Clara and from then on their village was saved. This story teaches us that, “If you have troubles working towards it will make you concur the troubles”. <strong>THE END</strong>.</p><p>By Maria Angel Desmond</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dde26e452b79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Azure Artifacts to manage the Packeges for your .NET Core projects in Local Machinie]]></title>
            <link>https://medium.com/@desmond80in/setting-up-azure-artifacts-to-manage-the-packeges-for-your-net-core-projects-in-local-machinie-4a831e8d6b3d?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a831e8d6b3d</guid>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Fri, 08 Nov 2024 23:04:00 GMT</pubDate>
            <atom:updated>2024-11-08T23:07:33.650Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up Azure Artifacts to manage the Nuget Packeges for your .NET Core projects in Local Machinie</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hB8EnAVlIgxNZZ6eD_1aQw.png" /></figure><p>Azure Artifacts is a robust package management service that integrates seamlessly with Azure DevOps, providing a centralized repository for developers to store, share, and manage dependencies like NuGet, npm, Maven, and Python packages. This service streamlines the package distribution process within a team, enabling developers to access pre-approved libraries and tools with ease. Azure Artifacts ensures that teams use consistent, verified, and reliable package versions, significantly reducing the risk of introducing vulnerabilities or outdated dependencies into their projects.</p><p>By utilizing Azure Artifacts, development teams can focus on building features without constantly managing dependency versions or verifying package security. It enables organizations to enforce security standards and streamline maintenance by allowing a designated team to control package updates, apply security patches, and manage access policies. This centralized approach ensures that packages are compliant and that vulnerabilities are addressed promptly, providing a safer, more stable foundation for project development across the organization.</p><p>Below mentioned steps are used to setup it in your local machine.</p><h4>1. Setting Up an Azure Artifacts Feed in Azure DevOps</h4><p>Login to Azure DevOps of your organization and go to your Project (I assume you have already set up these). Click on the Azure Artifacts as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*dHaoZw3l0VhzEN7Rv7qtuQ.png" /></figure><p>After cliking on the feed below page will be shown. Click on create feed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*VOuRRG3JmakWC3XEc1bYuw.png" /></figure><p>We will create the feed such that it will be allowed to access to specific developers within our team hence respective settings are choosen. Based on your need you could choose it to be acceesed to anyone in your organization (Azure DevOps) or Anyone in your Microsoft Tenant. It is always better to go with least access previledge and extend it as per need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*nZ8f4JVaITn8XhrFCs_JnA.png" /></figure><p>After creating the feed it will reditect you to the feed page. Since first time, it will show the buttons to connect to feed and search from Upsteam sources. Upsteam sources are like NUGET, npm, Maven etc when you can search and add the packages that are need for your team upfront.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*I1LuPANh-YFxS39Tbfa_zw.png" /></figure><p>Clicking on Connect to feed, will allow you to find the settings needed for different package sources and IDE environment. As shown below, we needed to create a feed that is to get NuGet packages for Visual Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*Nc0w5fdn8PR7clp8-ouFKA.png" /></figure><h4>2. Configuring NuGet Package Source in Visual Studio</h4><p>By clicking Visual Studio in the above screen, you will be redirected to the settings page. Copy the Name and source as shwon below that will be used to configure in Visual Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*xoTYruLh_bVK7onAsrf2ig.png" /></figure><p>There are multiple way to setup the feed in Visual Studio IDE as mentioned below.</p><ol><li>Tools Menu &gt; Options &gt; NuGet Package Manager &gt; Package Sources</li><li>In solution Exoplorer, right click on your solution &gt; Manage NuGet Packages for Solution.. &gt; Click on the Gear icon as shown below.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*dT-XCMlIJ8NXLyx9S7VbXw.png" /></figure><h4>3. Ensure you have permission to read and write to feed from you Azure Artifacts</h4><p>Go back to Azure Artifacts in your DevOps and select the feed. Click on the settings (configuration Icon) that is available in the top of menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*3rpmphU7pei1ThBDGJ4YOA.png" /></figure><p>Click on the Permissions tab and add User/ Groups button to searc and add your team memeber to give persmissio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*zRXNfELjcbYoU9r9hMUOWA.png" /></figure><p>Based on the user category select the appropriate permission. Since I wanted this user to contribute on adding new packages I have choosen collaborator. For rest of the team member you could choose Feed Reader so they can only read from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*p8xkDhxZVQfIL4Zz7gPkXg.png" /></figure><h4>4. Clearing Local NuGet Cache</h4><p>Once the feed is set up, firstly we need to cleant he nuget packaes that were used (installed) in the local machine. Executing below command will clean the already installed nuget pckages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*WW_apIFBv03fVmaGC8ZYXQ.png" /><figcaption><strong><em>dotnet nuget locals all — clear</em></strong></figcaption></figure><p>To confirm go to the folder paths mentioned above you will find empty directories.</p><h4>5. Restoring NuGet Packages from the Azure Artifacts Feed</h4><p>Now open your .NET solution and right click on the solution and select <strong><em>Restore Nuget Packages</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*oNQshO2faEp4fNaAr4itrA.png" /></figure><p>This will restore existing packages.</p><h3>Any Help:</h3><p>If you encounter any issues please comment and I will be happy to help you. Happy Coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a831e8d6b3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Azure Infrastructure as Code with Terraform — Implementing CI/CD using Azure Pipelines]]></title>
            <link>https://medium.com/@desmond80in/exploring-azure-infrastructure-as-code-with-terraform-implementing-ci-cd-using-azure-pipelines-3a1fa8cbf35b?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a1fa8cbf35b</guid>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 23:49:34 GMT</pubDate>
            <atom:updated>2024-08-05T23:49:34.359Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring Azure Infrastructure as Code with Terraform — Implementing CI/CD using Azure Pipelines</h3><p>We&#39;re reaching the pinnacle of our Azure Infrastructure Automation journey with Terraform. In our last chapter, we implemented Continuous Integration by creating a repository in Azure Repos, committing our configuration, and storing the Terraform state file in a private Azure Storage Account.</p><p>In this chapter, we’ll dive into Continuous Deployment (CD) using Azure Pipelines. First, we’ll configure Azure DevOps to access Azure environments and create resources. Then, we’ll write a YAML Pipeline to download our Terraform configuration code, build and validate it, and apply the configuration changes on Azure.</p><h3>Part 1: Configuring Azure DevOps to Access Azure Portal</h3><h4>Why We Need This Configuration:</h4><p>To deploy resources on Azure using Azure DevOps, we must grant Azure DevOps the necessary permissions to interact with the Azure environment. This involves ensuring the Azure DevOps user has the appropriate permissions and creating a Service Principal for Azure DevOps authentication.</p><h4><strong>Steps:</strong></h4><h4><strong>1. Check Permissions:</strong></h4><ul><li>Log in to the Azure Portal.</li><li>Navigate to your subscription and select “Access control (IAM)”.</li><li>Check if the Azure DevOps user has the “Contributor” role. If not, add the role by clicking “Add”, selecting “Add role assignment”, and choosing “Contributor”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3nNbTLpWJR_R6pk36xhmhQ.jpeg" /><figcaption>Assigning Contibutor role to the Azure DevOps User at the subscription level</figcaption></figure><ul><li>Check if the Azure DevOps user has the “User Access Administrator” role. If not, add the role by clicking “Add”, selecting “Add role assignment”, and choosing “User Access Administrator”.</li></ul><h4>2. Create a Service Principal:</h4><ul><li>Go to the Azure DevOps portal.</li><li>Navigate to your project and select “Project settings” at the bottom left.</li><li>Under “Pipelines”, select “Service connections”.</li><li>Click “New service connection” and choose “Azure Resource Manager”.</li><li>Select “Service principal (automatic)” and follow the prompts to create and configure the service principal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VnDVh6C-Gd_9wWgyPtLx2A.jpeg" /><figcaption>Selecting Azure Resource Manager connection type to the Service Connection</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*nejXurWZcn8LQQJVp1ZtZg.jpeg" /><figcaption>Selecting Service Principal (Automatic) authentication method for the service connection</figcaption></figure><p>If the Azure DevOps user is a member of your Microsoft Entra (Azure Active Directory) and has the Contributor Role assigned at the subscription level, you will be able to view the Subscriptions in the dropdown. Select the Resource Group created previously to store the Terraform State Files and provide a suitable name for the service connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*F3YnTt3bqhdwuu_KqVRjfA.png" /></figure><p>You might encounter an error at this stage. If so, assign the user the “Owner” or “User Access Administrator” role at the subscription level. These roles are necessary for managing access control and assigning roles, which are critical steps in configuring service connections in Azure DevOps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*fTUGbhuoLGUylgrnESrRIA.png" /></figure><p>After successfully saving the service connection, you can view the artifacts in two places:</p><ol><li>In Azure DevOps, click on project settings → Service Connections to see the newly created terraform-deploy-service connection.</li><li>Click on the service connection in Azure DevOps to view its details and then click on the “Manage Service Principal” link to view details in the Azure Portal.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_E_PlXNmSDh2uOWJ5PPwA.jpeg" /></figure><p>NOTE: You may be notice additional GUID appended to your name, but you could modify them by clicking on the Branding &amp; Properties.</p><h4>3. Grant Contributor Access to the newly created Service Principal:</h4><ul><li>If you are not in Azure Portal then log in to the Azure Portal.</li><li>Navigate to your subscription and select “Access control (IAM)”.</li><li>Add the “Contributor” role by clicking “Add,” selecting “Add role assignment,” and choosing “Contributor”.</li><li>In the Select Member Section, enter the service principal name [AzureDevOpsUser]_[ProjectName].</li></ul><p>Once correctly assigned you should be able to see your service principal has been assigned Contributor Role as the subscription level. This step is crucial without it your deployment pipeline would be able to read or modify any resources in Azure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6XhVeDyePMKRn3zoaVzuw.jpeg" /></figure><h3>Part 2: YAML Pipeline to create deployment pipeline</h3><p>Azure Pipelines is a cloud service that automates the build, test, and deployment processes for applications. By using Azure Pipelines, teams can implement continuous integration and continuous delivery (CI/CD) practices, ensuring that code changes are automatically tested and deployed to production environments.</p><h4>First YAML Pipline:</h4><p>Let’s now switch back to Visual Studio Code and load our TerraformJourney project. Create a new folder “deployment” and create a file called deployment.yaml.</p><pre># Trigger has been disabled for this pipeline<br>trigger:<br>  - none<br><br>stages:<br>  - stage: Deploy_Terraform<br>    jobs:<br>      - job: Deploy_Terraform<br>        pool:<br>          vmImage: &#39;ubuntu-latest&#39;<br>        steps:<br>          # Install Terraform<br>          - task: TerraformInstaller@0<br>            displayName: &quot;Install&quot;<br>            inputs:<br>              terraformVersion: &quot;1.8.3&quot;<br>          # Initialize Terraform<br>          - task: TerraformTaskV2@2<br>            displayName: &quot;Initialize Terraform&quot;<br>            inputs:<br>              provider: &quot;azurerm&quot;<br>              command: &quot;init&quot;<br>              workingDirectory: &quot;$(System.DefaultWorkingDirectory)/terraform&quot;<br>              backendServiceArm: &quot;terraform-deploy-serviceconnection&quot;<br>              backendAzureRmResourceGroupName: &quot;Terraform_States&quot;<br>              backendAzureRmStorageAccountName: &quot;madstudioterraformstate&quot;<br>              backendAzureRmContainerName: &quot;terraformjourney-state&quot;<br>              backendAzureRmKey: &quot;terraform.tfstate&quot;<br>          # Validate Terraform configuration<br>          - task: TerraformTaskV2@2<br>            displayName: &quot;Validate&quot;<br>            inputs:<br>              provider: &quot;azurerm&quot;<br>              command: &quot;validate&quot;<br>              workingDirectory: &quot;$(System.DefaultWorkingDirectory)/terraform&quot;<br>              environmentServiceNameAzureRM: &quot;terraform-deploy-serviceconnection&quot;<br>          # Plan configuration changes<br>          - task: TerraformTaskV2@2<br>            displayName: &quot;Plan&quot;<br>            inputs:<br>              provider: &quot;azurerm&quot;<br>              command: &quot;plan&quot;<br>              workingDirectory: &quot;$(System.DefaultWorkingDirectory)/terraform&quot;<br>              environmentServiceNameAzureRM: &quot;terraform-deploy-serviceconnection&quot;<br>          # Apply configuration changes<br>          - task: TerraformTaskV2@2<br>            displayName: &quot;Apply&quot;<br>            inputs:<br>              provider: &quot;azurerm&quot;<br>              command: &quot;apply&quot;<br>              workingDirectory: &quot;$(System.DefaultWorkingDirectory)/terraform&quot;<br>              environmentServiceNameAzureRM: &quot;terraform-deploy-serviceconnection&quot;</pre><h4>Understanding YAML Pipeline Structure:</h4><ul><li><strong>Stages:</strong> Represent the major phases of your CI/CD process. They help in managing the flow of the pipeline, ensuring stages run in the correct sequence.</li><li><strong>Jobs:</strong> A collection of steps that run on the same agent. Jobs can run sequentially or in parallel within a stage.</li><li><strong>Tasks:</strong> The smallest unit in the pipeline, representing individual actions, such as running a script or deploying an application</li></ul><h4>Runing the Azure YAML Pipeline for the first time:</h4><p><strong><em>Desclaimer</em></strong>: If you’re setting up the DevOps account for the first time, you might face some challenges, covered in the sections below.</p><p>Let’s first save the code in our VS Code editor, commit and sync to Azure Repos. The folder structure for the code is as follows.</p><pre>TerraformJourney (Project Folder)<br>|_ .terraform (will not be commited)<br>|<br>|- deployment<br>|  |_ deployment.yaml (the above code)<br>|<br>|- terraform<br>|  |_ main.tf (Existing terraform code)<br>|  |_ .terraform.lock.hcl (will not be commited)<br>|<br>|_ .gitgnore</pre><h4>1. Create Pipeline:</h4><p>Since our YAML Pipeline code has been committed to Azure Repos, the following steps show how to create the Azure Pipeline based on the existing YAML pipeline code. Save the Pipeline and do not run it yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*jzhDDDm928RXZ6NohnWXzQ.gif" /></figure><h4>2. Install TerraformTaskV2 Extention:</h4><p>Install the TerraformTaskV2 extension from the Visual Studio Marketplace. This extension allows Azure DevOps to run Terraform-related tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RkVgd15Me98H3ZKtNb-miQ.jpeg" /></figure><p>This will take you to Visual Studio Marketplace, click on Azure DevOps and search for Terraform installer and click on the plugin created by Microsoft as shown in the below image. After successful installation you would be abel to view your plugin under the installed section on Extenstions in Azure DevOps Organization settings page as shown in the above image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xa58etaNMOEkFuENtCspKw.jpeg" /></figure><h4>3. Generate Request to run Job Execution:</h4><p>Although we have a single job we are forced to submit a form to run job execution for private project. Click on the “request” you will be directed to a form, enter your details and submit. In most cases it will be approved within a day. Generally you will not receive a confirmation email of the approval but you should be able to run once approved on the next day.</p><blockquote>We have temporarily disabled the free grant of parallel jobs for public projects and for certain private projects in new organizations. However, you can request this grant by submitting <a href="https://aka.ms/azpipelines-parallelism-request">a request</a>. Existing organizations and projects are not affected. Please note that it takes us 2–3 business days to respond to your free tier requests.</blockquote><p>Failing to add Terraform Plugin in Azure DevOps you will encounter below error “No hosted parallelism has been purchased or granted”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_-cokiUCFoVK2rTFO58GQ.jpeg" /></figure><h4>4. Run Pipeline for the first time:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzSV46hgY4gbAWr7LtmVcA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vZ-S20rh8ZhLLpQW35y8HA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EK5sBUWPVFCgJiYCiVKhXg.jpeg" /></figure><h3>Conclusion:</h3><p>In this chapter, we successfully configured and built our Azure DevOps pipeline for Terraform deployments. We began by ensuring our Azure DevOps user had the necessary permissions, including Contributor and User Access Administrator roles. We then created a Service Principal to authenticate Azure DevOps with Azure, set up a service connection, and structured our YAML pipeline with stages, jobs, and tasks to streamline the deployment process. Each task was configured to install Terraform, initialize the environment, validate the configuration, plan changes, and apply those changes.</p><p>We explored the key components of our pipeline, including stages, jobs, and tasks, and tackled the challenges that came with setting up the pipeline. Installing essential extensions like TerraformTaskV2 and managing permissions and job execution approvals for private projects were crucial steps. Understanding and navigating these components and challenges allowed us to optimize our pipeline for efficient and secure deployments.</p><p>Looking ahead to the next chapter, we will delve into multi-stage deployments, enabling us to manage complex workflows and transitions between environments. We will implement approval mechanisms for production deployments, adding an extra layer of control and security. Additionally, we will focus on configuring enhanced security measures for the release branch to ensure robust and secure deployments. Stay tuned for the next exciting installment as we continue to unlock the full potential of Terraform and Azure DevOps.</p><p>Stay tuned and get ready to unlock the full potential of Terraform and Azure DevOps in our next exciting chapter!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a1fa8cbf35b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Azure Infrastructure as Code with Terraform — Getting started with Terraform]]></title>
            <link>https://medium.com/@desmond80in/exploring-azure-infrastructure-as-code-with-terraform-getting-started-with-terraform-05a1c15aacc8?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/05a1c15aacc8</guid>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 23:32:39 GMT</pubDate>
            <atom:updated>2024-08-05T23:32:39.173Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring Azure Infrastructure as Code with Terraform — Getting started with Terraform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b5bCyB0r3f-Jd0uK7VqdLA.jpeg" /></figure><p>In the ever-evolving landscape of cloud computing, mastering infrastructure management is a key skill for any IT professional. With Azure’s expansive array of services, the journey from manual resource provisioning to automated infrastructure deployment can seem daunting. However, by embracing Infrastructure as Code (IaC) principles and leveraging powerful tools like Terraform, this transition becomes not only achievable but also immensely rewarding. In this inaugural post of our series, we’ll embark on a journey to explore Azure Infrastructure as Code using Terraform, unlocking the potential for streamlined, scalable, and efficient cloud infrastructure management.</p><h4>Different Ways of Creating Resources in Azure:</h4><p>Before diving into Terraform, let’s briefly examine the traditional methods of resource creation in Azure. Whether through the Azure Portal’s intuitive graphical interface or the command-line interface (CLI) for more advanced users, Azure offers multiple avenues for provisioning resources. While these methods are effective for manual deployment, they often lack the scalability and repeatability required for modern cloud environments.</p><h4>Understanding Infrastructure as Code (IaC):</h4><p>Infrastructure as Code (IaC) represents a paradigm shift in the way we manage cloud infrastructure. At its core, IaC treats infrastructure configurations as code, enabling automation, version control, and reproducibility. Whether for small-scale projects or large-scale deployments, the benefits of IaC are profound. From reducing human error to facilitating collaboration and ensuring consistency across environments, IaC empowers organizations to scale their infrastructure with confidence.</p><h4>Available Options to Implement IaC:</h4><p>When it comes to implementing Infrastructure as Code on Azure, several tools and frameworks are at your disposal. From Azure Resource Manager (ARM) templates to third-party solutions like Ansible and Chef, each offers its own set of features and capabilities. However, in this series, we’ll focus on Terraform — an open-source IaC tool renowned for its simplicity, flexibility, and broad support for multi-cloud environments.</p><h4>Introducing Terraform:</h4><p>Terraform is a declarative configuration management tool that enables infrastructure provisioning and management through code. By defining infrastructure components in Terraform configuration files, known as “HCL” (HashiCorp Configuration Language), users can easily create, modify, and version-control their infrastructure. The Terraform workflow typically involves four key steps: writing configuration, initializing the Terraform workspace, planning changes, and applying those changes to the infrastructure.</p><h4>Prerequisites:</h4><p>Before we embark on our Terraform journey, let’s ensure we have the necessary tools and environment set up. To follow along with the examples in this series, you’ll need to download and install <a href="https://developer.hashicorp.com/terraform/install?product_intent=terraform">Terraform</a>, <a href="https://code.visualstudio.com/">Visual Studio Code</a> (or any preferred code editor), and the <a href="https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform#terraform-cloud-integration">Terraform extension</a> for your editor of choice.</p><h4>Terraform Installation</h4><p>The simplest way to install terraform is to copy the downloaded terraform binary (terraform) from your downloaded location and paste a location of your choice.(e.g. C:\Program Files) Add the location to the environment variable.</p><ol><li>Go to <strong><em>Control Panel -&gt; System -&gt; System settings -&gt; Environment Variables</em></strong></li><li>Scroll down in system variables until you find <strong><em>PATH</em></strong></li><li>Click on edit and append the folder location that you copied the terraform binary</li><li>Launch a new console and enter terraform — version to very terraform has been successfully installed.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNH9-N_-neHCZFxFj3gqrA.png" /><figcaption>terraform — version to check the installed version</figcaption></figure><p>Successful terraform installation and version change can be performed before writing the code using CMD or power-shell.</p><h4>Creating Azure Resources with Terraform:</h4><p>With our tools in place, it’s time to dive into the hands-on aspect of our journey. In this post, we’ll start by creating foundational Azure resources using Terraform. We’ll begin by provisioning an Azure Resource Group — a logical container for managing related resources. Next, we’ll explore how to create a Storage Account, demonstrating Terraform’s ability to handle complex resource configurations with ease.</p><p>Before we proceed, let’s outline the steps involved in creating resources using Terraform:</p><p><strong>Steps to be executed for the very first time:</strong></p><ol><li>Install Azure CLI tool</li><li>Authenticate to Azure using Azure CLI</li><li>Create a Service Principal</li><li>Set environment variables</li></ol><p><strong>Steps to be executed when creating a Terraform project:</strong></p><ol><li>Write configuration</li><li>Initialize Terraform configuration</li><li>Validate, plan, and apply Terraform configuration</li><li>Inspect your state</li></ol><h4>Install Azure CLI tool</h4><p>Azure CLI, a command-line tool offered by Microsoft Azure, plays a pivotal role in the seamless integration of Terraform — an infrastructure as code tool — within Azure environments. This powerful combination empowers users to efficiently create, configure, and manage Azure resources directly from Terraform scripts, streamlining the process of infrastructure provisioning and maintenance.</p><p><strong>What is Azure CLI?</strong></p><p>Azure CLI stands as a command-line interface provided by Microsoft Azure, designed for managing Azure services and resources through commands or scripts. Its versatile functionalities enable users to authenticate to Azure, create resource groups, deploy resources, and execute various management tasks — all with ease and efficiency.</p><p><strong>Integration with Terraform:</strong></p><p>When paired with Terraform, Azure CLI becomes an indispensable tool for orchestrating Azure infrastructure through code. By leveraging Azure CLI within Terraform scripts, users can seamlessly interact with Azure services, automate resource provisioning, and enforce infrastructure configurations — all within a unified, code-driven workflow.</p><p><strong>Key Capabilities:</strong></p><p>Azure CLI within Terraform offers a plethora of capabilities, including:</p><ol><li><strong>Authentication:</strong> Easily authenticate to Azure environments, ensuring secure access to Azure resources.</li><li><strong>Resource Provisioning: </strong>Effortlessly create and configure Azure resources, such as virtual machines, storage accounts, and databases, directly from Terraform scripts.</li><li><strong>Management Tasks:</strong> Execute various management tasks, including resource deployment, scaling, and monitoring, with simple, command-line instructions.</li><li><strong>Integration:</strong> Seamlessly integrate Azure CLI commands within Terraform configurations, enabling comprehensive infrastructure management within a single, unified environment.</li></ol><p>Click to download <a href="https://aka.ms/installazurecliwindowsx64">Azure CLI Tool</a> and install or upgrade your existing Azure CLI Version with <em>az update</em> command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUqPIZwWjJti_R7wWSWDbg.jpeg" /><figcaption>az — version command to check the installed azure-cli version</figcaption></figure><h4>Authenticate to Azure using Azure CLI</h4><p>To begin, open your command prompt and enter the command ‘az login’. This action will prompt your default web browser to open, requesting authentication to your Azure Account. Once you’ve successfully authenticated, you can close the browser window, and your subscription details will automatically load in the command prompt, as depicted in the image below. From this output, you need to copy the ‘id’ value. This ID corresponds to your subscription ID, which will be used to set up the Azure Account with AZ CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKXwjdYH-Xeqr0yFKjUrHA.jpeg" /><figcaption>az login command to login to azure account and get subscription details</figcaption></figure><h4>Create Service Principal</h4><p>To enhance security and ensure the protection of Azure resources, automated tools leveraging Azure services should operate with limited permissions. Instead of granting applications full privileges, Azure offers service principals. These principals are identities specifically designed for use with applications, hosted services, and automated tools. They provide controlled access to only the necessary resources, reducing the risk of unauthorized access and potential security breaches.</p><pre>az ad sp create-for-rbac --name terraform_SP --role &quot;contributor&quot; --scopes /subscriptions/7f5904ed-xxxx-xxxx-xxxx-xxxxxxxxxxxx</pre><p>Replace the ID (subscription id) you copied in the previous step to create a service principal name <strong><em>terraform_sp</em> </strong>and <strong><em>contributor</em></strong> role in your subscription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWqtHlXX6ZXgGbrnuELDaQ.jpeg" /><figcaption>az ad sp create-for-rbac — name terraform_sp — role “contributor” — scopes /subscription/xxxx to create a service principal with name terraform_sp</figcaption></figure><p>Immediately copy the <strong><em>appID </em></strong>(&lt;APPID_VALUE&gt;), <strong><em>password </em></strong>(&lt;PASSWORD_VALUE&gt;), <strong><em>tenant </em></strong>(&lt;TENANT_VALUE&gt;) along with your <strong><em>subscription id</em></strong><em> </em>(&lt;SUBSCRIPTION_ID&gt;) to sa safe location. You won’t be able to retrieve the password if you fail to copy it. In case of failure to copy, you’ll need to recreate another service principal, as demonstrated above.</p><h4>Set Environment Variable</h4><p>Let’s create environment variables that will be sued for the rest of the steps.</p><pre>$ $Env:ARM_CLIENT_ID = &quot;&lt;APPID_VALUE&gt;&quot;<br>$ $Env:ARM_CLIENT_SECRET = &quot;&lt;PASSWORD_VALUE&gt;&quot;<br>$ $Env:ARM_SUBSCRIPTION_ID = &quot;&lt;SUBSCRIPTION_ID&gt;&quot;<br>$ $Env:ARM_TENANT_ID = &quot;&lt;TENANT_VALUE&gt;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*vvR6kTANnNiH80p5EIJn-g.jpeg" /><figcaption>$ENV:ARM_CLIENT_ID = “XXXX” to store client id, client secret, subscription id, terant id in your shell environment.</figcaption></figure><h4>Write Configuration</h4><p>Create new file <em>(main.tf)</em> in Visual Studio Code Editor and paste the configuration below.</p><pre># Configure the Azure provider<br>terraform {<br>  required_providers {<br>    azurerm = {<br>      source  = &quot;hashicorp/azurerm&quot;<br>      version = &quot;~&gt; 3.0.2&quot;<br>    }<br>  }<br><br>  required_version = &quot;&gt;= 1.1.0&quot;<br>}<br><br>provider &quot;azurerm&quot; {<br>  features {}<br>}<br><br>resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {<br>  name     = &quot;terraform-rg&quot;<br>  location = &quot;westus2&quot;<br>}</pre><p>In the above code, the terraform {} block contains Terraform settings, including the required providers that Terraform will utilize to provision your infrastructure. Each provider is specified with the source attribute, which includes an optional hostname, namespace, and provider type. By utilizing the version attribute, which is optional, we can exercise control over the provider version. Otherwise, Terraform defaults to installing the latest version, which may introduce breaking changes. The azurearm provider is a plugin used by Terraform to create and manage Azure resources.</p><p>The resource block is utilized to define the components of your infrastructure. The two strings preceding the block, namely the resource type &quot;azurerm_resource_group&quot; and the resource name &quot;rg,&quot; together form the unique identifier of the configuration, &quot;azurerm_resource_group.rg.&quot; Detailed definitions for these resource types can be found in the <a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs">Azure Provider Documentation</a>, including documentation for the <a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group">azurerm_resource_group</a>.</p><h4>Initialize terraform configuration</h4><p>When you type “terraform init,” Terraform initializes a new or existing Terraform configuration. This process involves downloading any required provider plugins and modules specified in the configuration files. Terraform creates a “.terraform” directory in the working directory to store these dependencies. Additionally, during initialization, Terraform checks for any configuration syntax errors and verifies provider compatibility to ensure smooth execution of subsequent commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fhw2I8Rpt0KsrlDi8R39Dg.jpeg" /><figcaption>terraform init command to initialize the directory</figcaption></figure><h4>Validate, plan and apply terraform configuration</h4><p>When you execute the command terraform validate, Terraform ensures that the configuration is syntactically valid and internally consistent. It checks for any errors or inconsistencies in the configuration files.</p><p>On the other hand, terraform plan analyzes the Terraform configuration and generates an execution plan. This plan provides a detailed overview of the actions that Terraform will take to achieve the desired state of the infrastructure. It includes any additions, modifications, or deletions of resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5o0crPwjXKzk-jaKYUfZFQ.jpeg" /><figcaption>terraform validate and terraform plan commands to validate and preview the resources to be created or altered.</figcaption></figure><p>When the terraform plancommand is executed for the first time, Terraform checks if there is a resource group named “terraform-rg” in our Azure cloud environment. If such a resource group does not exist, Terraform will include it in the execution plan and inform us that it will create this resource when we run the terraform applycommand.</p><p>Similarly, when we run the terraform applycommand, Terraform performs the same checking process. If the resource group “terraform-rg” does not exist, Terraform requests our confirmation before proceeding to create the actual resources in the cloud environment. This confirmation step ensures that we are aware of and approve the changes Terraform intends to make to our infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bnvRklYryPJFvX_a-HrDnA.jpeg" /><figcaption>terraform apply command to apply the changes in cloud environment.</figcaption></figure><p>Let’s quickly jump to our azure portal and inspect the resource created with our terraform code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kdMZkvJrhY1JvjFyNvKaw.jpeg" /><figcaption>The resource group names terraform_sp created in Azure Portal under resource groups</figcaption></figure><h4>Inspect your state</h4><p>When we run terraform applyTerraform writes all the information related to the resources that were created into a file called “terraform.tfstate.” This file serves as a snapshot of the current state of our infrastructure, containing the IDs and properties of the resources created by Terraform. It enables Terraform to manage or destroy those resources in subsequent operations.</p><p>It’s important to note that the state file contains all of the data in our configuration, including potentially sensitive values in plaintext. Therefore, we must exercise caution and avoid sharing or checking it into source control repositories. By default, the state file is located in the same folder as our main configuration file (typically “main.tf”) in our Visual Studio Code editor. It’s crucial to keep this file secure to safeguard our infrastructure and maintain compliance with security best practices.</p><pre>{<br>  &quot;version&quot;: 4,<br>  &quot;terraform_version&quot;: &quot;1.8.3&quot;,<br>  &quot;serial&quot;: 1,<br>  &quot;lineage&quot;: &quot;xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&quot;,<br>  &quot;outputs&quot;: {},<br>  &quot;resources&quot;: [<br>    {<br>      &quot;mode&quot;: &quot;managed&quot;,<br>      &quot;type&quot;: &quot;azurerm_resource_group&quot;,<br>      &quot;name&quot;: &quot;rg&quot;,<br>      &quot;provider&quot;: &quot;provider[\&quot;registry.terraform.io/hashicorp/azurerm\&quot;]&quot;,<br>      &quot;instances&quot;: [<br>        {<br>          &quot;schema_version&quot;: 0,<br>          &quot;attributes&quot;: {<br>            &quot;id&quot;: &quot;/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/terraform-rg&quot;,<br>            &quot;location&quot;: &quot;westus2&quot;,<br>            &quot;name&quot;: &quot;terraform-rg&quot;,<br>            &quot;tags&quot;: null,<br>            &quot;timeouts&quot;: null<br>          },<br>          &quot;sensitive_attributes&quot;: [],<br>          &quot;private&quot;: &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxfX0=&quot;<br>        }<br>      ]<br>    }<br>  ],<br>  &quot;check_results&quot;: null<br>}</pre><p><strong><em>terraform show </em></strong>will read the resources from your state file and show and <strong><em>terraform state list</em></strong> would list the unique id of your resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-ZBsuJYTLdtP_RfcLnAJA.jpeg" /><figcaption>terraform show and terraform state list command to inspect the state file.</figcaption></figure><p>As our final step, let’s create a storage account in the “terraform-rg” resource group to conclude this initial phase of getting started with Terraform.</p><p><strong>Here are the steps to add a new resource to the Terraform configuration:</strong></p><ol><li><strong>Navigate to the </strong><a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs"><strong>Terraform Provider Documentation</strong></a><strong>: </strong>Start by visiting the Terraform provider documentation for Azure. This documentation provides comprehensive guidance on the resources and configurations supported by the Azure provider for Terraform.</li></ol><p><strong>2. Identify the </strong><a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account"><strong>Desired Resource</strong></a><strong>: </strong>Once in the documentation, locate the section related to storage accounts. Here, you’ll find information about the attributes and configurations available for creating storage accounts using Terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iT7yGJq2q72tFh7srFLryw.jpeg" /><figcaption>Find the terraform sample code in terraform registry</figcaption></figure><p><strong>3. Add the Resource Block to the Configuration:</strong> In your Terraform configuration file (typically “main.tf”), add a new resource block for the storage account. Specify the required attributes such as name, resource group, location, and any additional configurations based on your requirements.</p><pre># Configure the Azure provider<br>terraform {<br>  required_providers {<br>    azurerm = {<br>      source  = &quot;hashicorp/azurerm&quot;<br>      version = &quot;~&gt; 3.0.2&quot;<br>    }<br>  }<br><br>  required_version = &quot;&gt;= 1.1.0&quot;<br>}<br><br>provider &quot;azurerm&quot; {<br>  features {}<br>}<br><br>#Resource Group Code<br>resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {<br>  name     = &quot;terraform-rg&quot;<br>  location = &quot;westus2&quot;<br>}<br><br># Storage Account Code<br>resource &quot;azurerm_storage_account&quot; &quot;storage-ac&quot; {<br>  name                     = &quot;terraform-storage-ac&quot;<br>  resource_group_name      = azurerm_resource_group.rg.name<br>  location                 = azurerm_resource_group.rg.location<br>  account_tier             = &quot;Standard&quot;<br>  account_replication_type = &quot;LRS&quot;<br><br>  tags = {<br>    environment = &quot;development&quot;<br>  }<br>}</pre><p><strong>4. Run “terraform plan” and “terraform apply”:</strong> After adding the resource block, run “terraform plan” to generate an execution plan and review the proposed changes. Once satisfied, execute “terraform apply” to apply the changes and create the storage account in the specified resource group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*6Z-5AeWNsm_p4hcJAytGXg.jpeg" /><figcaption>Storage Account created using our new configuration</figcaption></figure><p>By following these steps and leveraging the Terraform provider documentation, you can seamlessly integrate new resources into your Terraform configuration, extending the capabilities of your infrastructure management workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zXDrDHCqZAFsYbHn4W-T1w.jpeg" /><figcaption>Created storage account with all settings</figcaption></figure><h4><strong>Congratulations! </strong>🎉</h4><p>We’ve successfully achieved our first goal in our journey. The basics we’ve learned in this step are an investment for life. If you’ve patiently read through this article, I’m confident you’ve made the decision to learn a new skill or try something new that will benefit you in various aspects of your life.</p><p>In our next step, we’ll explore how to maintain this Terraform code using source control and securely store the state file in a centralized location. This approach will enable us to manage resource management centrally, streamlining our infrastructure management workflow. Join me as we continue our journey toward mastering Azure infrastructure management with Terraform. See you in the next step!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05a1c15aacc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embark on Your Azure Infrastructure Automation Journey with Terraform]]></title>
            <link>https://medium.com/@desmond80in/embark-on-your-azure-infrastructure-automation-journey-with-terraform-4acda77b96b9?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/4acda77b96b9</guid>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 23:23:36 GMT</pubDate>
            <atom:updated>2024-08-05T23:23:36.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPm_rcykOTHm_t0aRHqYmQ.jpeg" /><figcaption>Journey towards IoC</figcaption></figure><p>Throughout my journey from navigating the Azure Portal to mastering Terraform for infrastructure automation, I found myself immersed in the realm of DevOps practices. This hands-on experience not only deepened my understanding of cloud infrastructure management but also provided invaluable insights into the principles of DevOps. By embracing tools like Terraform alongside Azure Repos and Pipelines, I discovered the transformative power of automation in streamlining deployment workflows and fostering collaboration within teams. This journey wasn’t just about mastering a set of tools; it was about embracing a mindset — a mindset that prioritizes efficiency, scalability, and continuous improvement. Join me as we explore this transformative journey together, empowering ourselves with the skills and knowledge needed to thrive in the world of DevOps and cloud infrastructure management.</p><h3><strong>Prerequisites:</strong></h3><p>Before we dive in, I assume you have some basic understanding of Azure and how to provision Azure resources using the Azure portal.</p><h3>Series Outline:</h3><h4>Getting Started with Terraform:</h4><p>In the inaugural part of this series, we’ll provide a brief overview of Terraform and guide you through the process of creating Azure resources (such as Resource Groups and Storage Accounts) directly from your local machine using Terraform within Visual Studio Code.</p><h4>Version Control and Centralized Storage:</h4><p>Moving forward, we’ll shift our infrastructure code to Azure Repositories for version control. Additionally, we’ll explore the importance of storing Terraform state files in a centralized, secure location to facilitate collaboration among team members.</p><h4>Implementing CI/CD with Azure Pipelines:</h4><p>Next up, we’ll introduce Azure Pipelines to enable Continuous Integration and Continuous Deployment, streamlining our deployment processes. We’ll also delve into creating multiple staging environments (DEV, STG &amp; PROD) using infrastructure-as-code principles.</p><h4>Maintaining Reusable Terraform Components:</h4><p>As our journey progresses, we’ll focus on maintaining reusable Terraform components in alignment with organizational standards and best practices. By doing so, we empower operations teams to swiftly create necessary infrastructure components. Additionally, we’ll expand our infrastructure repository by incorporating resources like Virtual Networks with VMs and SQL Servers.</p><h4>Generating Terraform Code and State File for Existing Resources:</h4><p>In this post, we’ll delve into the process of generating Terraform code and state files for an existing resource group provisioned in Azure. By understanding how to reverse-engineer our Azure infrastructure into Terraform configuration files and state files, we’ll pave the way for seamless integration and automation of our existing resources.</p><h3>Join Us on this Journey:</h3><p>Stay tuned as we embark on this series, offering you insights and strategies to elevate your Azure infrastructure provisioning and management skills. Let’s empower ourselves with greater control and efficiency in managing Azure resources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4acda77b96b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessing Microsoft Graph API to Retrieve User Information in Microsoft Azure Active Directory /…]]></title>
            <link>https://medium.com/@desmond80in/accessing-microsoft-graph-api-to-retrieve-user-information-in-microsoft-azure-active-directory-72128814f480?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/72128814f480</guid>
            <category><![CDATA[micsofoft-graph-api]]></category>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Sat, 20 Apr 2024 01:51:58 GMT</pubDate>
            <atom:updated>2024-04-24T16:49:34.016Z</atom:updated>
            <content:encoded><![CDATA[<h3>Accessing Microsoft Graph API to Retrieve User Information in Microsoft Azure Active Directory / Microsoft Entra (AAD)</h3><p>I recently undertook the task of developing an API to retrieve user lists and user information from my Microsoft Azure Active Directory (Azure AD), and encountered some challenges while attempting to access Microsoft Graph Information. Despite clear documentation, there were some discrepancies that arose during implementation. In this article, I will outline the necessary steps involved and address common errors you may encounter if not executed correctly.</p><p>To begin, let’s summarize the process:</p><ol><li>Create an App Registration in Azure AD: Start by creating an App Registration with the appropriate permissions.</li><li>Assign Roles: Ensure the correct roles are assigned to grant permission to access user information.</li><li>Generate Token: Generate a token with the required scope on the client side (e.g., Thunderbolt) and use it to query user endpoints to extract data.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*6AhNkdrYXJ7EbPPAZpizYw.png" /></figure><h3>Step 1: Create a Microsoft Azure AD App Registration with the Right Permissions</h3><p>Navigate to Azure Subscription &gt; Microsoft Azure AD &gt; App Registration &gt; [+ New Registration].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*we_zqJgAd-eed8Fqyvxstg.png" /><figcaption>Newly created App Registration</figcaption></figure><p>Once the App Registration is created, click on API Permissions, then click on [+ Add a Permission].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4OjkTnW2uxbmpM564B9Hog.png" /><figcaption>Adding API Permission to Read Users</figcaption></figure><p>Add the necessary permissions for reading users by selecting User.Read and User.Read.All under Delegated permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INxsEETVWVLRMjiLrx6L1A.png" /><figcaption>Filter User related endpoints in Microsoft Graph</figcaption></figure><h3>Step 2: Create Client Secret</h3><p>Generate a client secret and securely store it for later use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHoJAp4G7nyxN3UKm1DhNQ.png" /><figcaption>Client Secret Key to be used later</figcaption></figure><h3>Step 3: Assign Roles and Administrators</h3><p>Navigate back to Microsoft Azure AD and select Roles and Administrators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_H8fxfw7VX_4r0jlBSHwgA.png" /><figcaption>Roles and administrators</figcaption></figure><p>Filter and select the User Administrator role to grant sufficient privileges for operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zH_vrDfdooBX0IvtwHk6Cg.png" /><figcaption>User Administrator selection screen</figcaption></figure><p>This leads to the User Adminsitrator Previlidged Identity Management screen to add new assignement to your App you created. Click on Add Assignments and then on the add assginements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7wqU0fHpyWIpxEZqrFTkQ.png" /></figure><p>Under Add Assignments, click on “<strong>No members selected” </strong>then enter the APP Registration name we created before which will be found under the Enterprice Applications. Click on the check box and select and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ZVJc_61voWHJKCdF7-ZqiQ.png" /></figure><h3>Step 4: Obtain Access Token</h3><p>Utilize Thunderbolt or any REST API testing tool.</p><p>Provide the following information</p><p>URL: [POST] <a href="https://login.microsoftonline.com/%7Btenantid%7D/oauth2/v2.0/token">https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token</a></p><p>Headers: Content-Type: application/x-www-form-urlencoded</p><p>Body: Form-encoded parameters including client_id, client_secret, grant_type, and scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2avnpKsapgMdQlEHnQNmw.png" /></figure><p>client_id: Applciation (client) ID, client_secret : copied client secret, grant_type: client_credentials, scopt : https%3A%2F%2Fgraph.microsoft.com%2F.default (https://graph.microsoft.com/.default)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIxqh8x0JXCOTOsmSr5cKQ.png" /></figure><h3>Step 5: Query Microsoft Graph API</h3><p>Use the obtained access token to query user information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mz9dJWWrIDKrmzkgHNTSFg.png" /></figure><p>By following these steps meticulously, you should be able to successfully access user information from Microsoft Azure Active Directory using Microsoft Graph API. Should you encounter any errors, refer back to this guide to ensure each step is accurately executed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72128814f480" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reducing the UI Testing duration by parallel test execution]]></title>
            <link>https://medium.com/@desmond80in/reducing-the-ui-testing-duration-by-parallel-test-execution-1eaefada5076?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eaefada5076</guid>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[mstest]]></category>
            <category><![CDATA[unit-test-tools]]></category>
            <category><![CDATA[chromium]]></category>
            <category><![CDATA[visual-studio]]></category>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Wed, 16 Oct 2019 06:15:06 GMT</pubDate>
            <atom:updated>2019-10-16T06:18:08.679Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reduce UI Testing duration by parallel test execution</h3><p>Recently I had to implement UI test automation to my project. I had Visual Studio Professional editor hence choose to use the MSTest project and with the help of Selenium WebDriver.</p><p>Unfortunately, the UI testing took quite a long time as they were executed in a sequential manner. After some reach on the web I came to know about parallel test execution. Using the parallel test execution, I was able to save lots of the test execution time.</p><blockquote>MSTest V2 v1.3.0 Beta 2 supports parallel test execution.</blockquote><p>Create a blank solution and add new <em>Unit Test Project (.NET Framework).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXXtNNDiKu09bWdv6ViXQg.png" /><figcaption>Adding a new Unit Test Project (.NET Framework) to the solution.</figcaption></figure><p>Add bellow mentioned NuGet packages to support UI testing.</p><ol><li>Selenium.WebDriver (3.14.0)</li><li>Selenium.WebDriver.ChromeDriver (75.0.3770.8) — Chrome version ( 75.0.3770.80)</li></ol><p><strong>Do note</strong> that, Selenium.WebDriver.ChromeDriver’s version refers to the <strong>chrome browser version</strong> hence check the version of your chrome against the choice of your Selenium.WebDriver.ChromeDriver version. If the version of your chrome is not supported then you need to uninstall the current version of your chrome and install the WebDriver version that you have installed.</p><p>Start writing your test classes and their methods. For the purpose of the blog I have written single class with multiple methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*a2dv5SfgkifLFKEqEHy1Xw.png" /><figcaption>Test class with multiple methods for testing.</figcaption></figure><p>Now, run all your tests and confirm that things are working fine. As you could see the TestMethods in the TestClass will be executed sequentially. Here total time for executing all the tests are accumulation of individual tests (8s+11s+11s+11s) is around ~44 sec.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3W91M3XYR7W83fGJ6D0i5Q.png" /><figcaption>Sequential test execution duration</figcaption></figure><p>Now let me add parallel test execution to this project. First, we need to add some annotations to the assemblyInfo.cs.</p><p>[assembly: Parallelize(Workers = 4, Scope = Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope.MethodLevel)]</p><p>The above code lets assembly to parallel execute by spawning 4 worker threads based on Method scope (I wanted to simulate in a single class). There are <strong>3 scopes</strong> for parallelization (<strong>Class Level </strong>— default, <strong>Method Level</strong> and <strong>custom</strong>). The value for Workers are 0 to n ( 0 — Auto Config, use as may threads as possible).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oljsDbVAQ3TAE5EB8EDizw.png" /><figcaption>Parallel test execution duration.</figcaption></figure><p>All tests were completed close to 20 sec. Individual tests have their numbers which are higher than sequential execution since they run parallel, but overall test will complete its execution in much shorter duration than the sequential execution duration.</p><p>I have refereed the link that helped me to accomplish this. The link has more information regarding how it should be set using globally in your test server so that any test project will have its execution in parallel. How to avoid some of the test methods not to be executed in parallel.</p><p><a href="https://devblogs.microsoft.com/devops/mstest-v2-in-assembly-parallel-test-execution/">MSTest V2: in-assembly parallel test execution | Azure DevOps Blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eaefada5076" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multiple post-deployment scripts with SQL server project]]></title>
            <link>https://medium.com/@desmond80in/multiple-post-deployment-scripts-with-sql-server-project-5d3c9e2f52b4?source=rss-36cefa51daac------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d3c9e2f52b4</guid>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Desmond Harris Fernando]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 05:06:08 GMT</pubDate>
            <atom:updated>2019-10-14T21:38:57.063Z</atom:updated>
            <content:encoded><![CDATA[<p>SQL Server Database project has various features and functionality to work with database within your .NET solution. We can maintain the DB objects via scripts, source control them and publish them with different environments (dev/test/prod) manual publishing or via the CI / CD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*ba-N1yXWVKljrWtmPrMjeA.png" /><figcaption>SQL Project</figcaption></figure><p>I started with single post-deploy script (…_subscriptionData.sql) and published it on the server and it all worked as expected.</p><p>Maintaining your post-deployments in multiple files helps you in segregating them based on feature deployment. This will save you from having conflict resolution when working on a larger project. When I tried adding another script (…_languageData.sql) under the post-deploy folder and tried pushing it, only the first scripts content was executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*zF9zGqiKD7SG_GuC6pW8Jg.png" /><figcaption>PostPublishScripts having two files.</figcaption></figure><p>The script in the second file was not shown in the the generated script for deployment, as a result it was not published to the DB.</p><blockquote>A project can have only one pre-deployment and one post-deployment script.</blockquote><p>According to the documentat, post deployment should be single script hence the rest if the script files will not be executed. However we can extend this feature to have multiple sql files to be executed by adding SQLCMD syntax and variables in main scripts and set these in the database project properties.</p><p>Create the first post-deployment script with a generic name such as Script.PostDeployment.sql and in that file mention all your different post-deployment scripts with <em>:r .\myfile.sql.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*DIOgKk1XFBPmRlU6pBHsUQ.png" /><figcaption>Script.PostDeployment.sql refereeing to other script files.</figcaption></figure><p>This extends the feature of having multiple script files as post-deployment scripts. Now, when SQL project is built and published it will have all the script file’s content in the post-deployment script.</p><p><strong>Do note </strong>that, the file you have added as main post deployment script should have its <strong>Build Action</strong> set to <strong>PostDeploy</strong>.</p><p><a href="https://docs.microsoft.com/en-us/sql/ssdt/how-to-specify-predeployment-or-postdeployment-scripts?view=sql-server-ver15">How to: Specify Predeployment or Postdeployment Scripts - SQL Server</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d3c9e2f52b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>