<?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 Viktors Telle on Medium]]></title>
        <description><![CDATA[Stories by Viktors Telle on Medium]]></description>
        <link>https://medium.com/@viktors.telle?source=rss-b437a66eaa99------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O0mwPsPyFW3SYUk668jlRQ.jpeg</url>
            <title>Stories by Viktors Telle on Medium</title>
            <link>https://medium.com/@viktors.telle?source=rss-b437a66eaa99------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:32:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@viktors.telle/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[How To Be Productive And Healthy When Working From Home]]></title>
            <link>https://medium.com/@viktors.telle/how-to-be-productive-and-healthy-when-working-from-home-226c11d67eae?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/226c11d67eae</guid>
            <category><![CDATA[parenting]]></category>
            <category><![CDATA[work-from-home]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[work-life-balance]]></category>
            <category><![CDATA[stay-healthy]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Mon, 31 Aug 2020 10:33:04 GMT</pubDate>
            <atom:updated>2020-08-31T10:33:04.419Z</atom:updated>
            <content:encoded><![CDATA[<h4>I will share my experience, daily routine, and tips on how to manage your day to be productive at work, stay healthy, and also spend time with your family.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rv78V_LH_G-XAl2o" /><figcaption>Photo by <a href="https://unsplash.com/@srz?utm_source=medium&amp;utm_medium=referral">Sydney Rae</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I work from home for five months. I will lie if I say that it was easy. It definitely would have been easier if I did not have two small kids at home. I know that because I had worked remotely in the past when I did not have kids. In general, I was more productive at home than working at the office. The main reason for that is fewer distractions. Currently, I am a system architect at a large enterprise company. Before Covid-19 started, I worked from home occasionally. Mostly to allow my wife to do the important things for her while I look after our daughter. We had only one child at that time. Most of the parents will probably agree with me that it is much easier to manage your day if you have only one child. Now we have two kids with a small age difference. And it is much harder now to organize your day so that everyone is happy.</p><h3>Decide On Your Working Hours</h3><p>Find the most productive and acceptable time for work. For me, it is morning. I wake up at 6:00 and work until my daughter (oldest child) wakes up, which is usually around 7:00. Then I prepare the breakfast for us. I let my wife sleep until 8:00 since she has to wake up in the night to feed our son. Then I spent about 30 minutes with them, make a coffee, and switch back to work mode. I have a separate working room, and the doors are closed when I am working. If something important happens, then my wife can come and ask for my assistance. We eat lunch together at noon. After lunch, I go for a walk with my daughter. I listen to a <a href="https://www.viktorstelle.com/blog/podcasts-that-i-recommend-listening-to/">few podcasts</a> when she falls asleep. After one hour of walk, I usually leave her to sleep outside by the window and resume working. When she wakes up, I go downstairs and bring her home for an afternoon snack. After that, I continue to do my tasks for a few more hours.</p><p>To conclude the daily routine topic, I must say that effectively my workday is organized into many 1–2 hour sprints, which is fine, and I manage to do my job.</p><h3>Spend Time With Your Kids</h3><p>I beg to differ with the statement that the father should only work, and the mother should take care of the children. Of course, the mother does most of the job, but the father should be a part of raising the children, especially when children are at a young age. It helps you to develop a strong relationship with your children. Dedicate at least a couple of hours a day to spent quality time with children without distractions. Do not use smartphones and other sorts of gadgets. I have noticed that quite a few parents stare in the screens when going out with their kids. Try to avoid that as much as possible. Probably that email or message can wait. Usually, people call when something urgent is needed. I spent at least 2–3 hours with my daughter every day. Every weekend I take her with me to drive to someplace like a playground, forest, watch airplanes near the airport. I am not perfect and sometimes I spend less time with her. Try not feeling guilty about it, but decide on one activity that you will do together every day. We have put to bed routine that I do every evening to keep bonding with her.</p><h3>Find The Activity To Keep You Fit And Healthy</h3><p>I walk every day to stay fit. There are plenty of sports activities available such as running, swimming, cycling. Get yourself a smartwatch or fitness tracker to help you stay motivated. I have a smartwatch, and I check every day if I reach the 10k steps daily goal. If you think that walking is boring, try listening to podcasts or music. Also, why not try exercising during the day if your work schedule allows it. Here are my statistics for the last 6 months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*tyKGA0gOCsqtbxEpeV1xdg.png" /></figure><p>For example, in May I did 13 246 steps on average per day.</p><h4>Trying To Eat Healthy Food</h4><p>Whether I want it or not, I tend to eat healthier food. We, as a family, try to eliminate salt, sugar, and white flour from our menu, and eat more vegetables. Also, we eat more or less at the same time every day, which helps to live a healthier lifestyle.</p><h3>How To Stay Focused</h3><p>Try to eliminate all the unnecessary distractions like social networks. You would be surprised how much time they eat from your day. I use an app called <a href="https://getcoldturkey.com/">Cold Turkey</a>, which blocks certain websites such as social networks, YouTube, Reddit, in all browsers. It works, and I am more focused on my tasks. Also, focus on one concrete task and get it done. Doing many tasks in parallel usually does not work so well, and in the end, you get done fewer things. In the time window during the morning from 6–7 AM, I completely ignore the phone and emails and focus on the chosen task.</p><h3>Find Time For Your Hobbies</h3><p>I have found a few new hobbies recently. Writing and studying investing are among them. Mostly, I write during weekends or early in the morning. Podcasts like <a href="https://www.theinvestorspodcast.com/we-study-billionaires/">We Study Billionaires</a> are the primary source of knowledge when it comes to investing and finances. I also check the financial news on <a href="https://finance.yahoo.com/">Yahoo Finance</a>. I am sure you already have some hobbies, or you can discover them. Just find the specific time to focus on them. Some of you might say that I don’t have time for hobbies. It might be correct, but it could be that you spent a lot of time watching movies, shows, or playing video games. It is OK if these are your hobbies, but if not, then consider reducing the time spent on these activities.</p><h3>Find Time To Relax</h3><p>It is normal to relax in the evening and do virtually nothing. We are not robots and should not work for the whole day. Most importantly, listen to yourself. If you feel tired, stop working and rest for a while.</p><h3>Conclusion</h3><p>Here are the key takeaways from my article:</p><ul><li>Set up the daily routine and stick to it.</li><li>Spend quality time with your kids without gadgets.</li><li>Choose your sports activity and do it regularly. Buy a smartwatch or fitness tracker for additional motivation.</li><li>Eat regularly and avoid using salt, sugar, and white flour in your meals.</li><li>Do one task at a time and eliminate distractions such as social networks.</li><li>Do not forget about your hobbies and allocate some time for them.</li><li>Do not work non-stop. Find time to rest. Go outside for a walk, grab a coffee, or lay down.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=226c11d67eae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ways to ensure decent code quality in the project]]></title>
            <link>https://medium.com/if-tech/ways-to-ensure-decent-code-quality-in-the-project-bd2352c2f2f6?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd2352c2f2f6</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[quality-software]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[static-code-analysis]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Wed, 05 Aug 2020 06:17:50 GMT</pubDate>
            <atom:updated>2021-11-11T11:19:32.940Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ways To Ensure Decent Code Quality In The Project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HRMH9qWbPWAuZjNFX94gAQ.png" /><figcaption>SonarQube Quality Metrics (<a href="https://www.sonarqube.org/">https://www.sonarqube.org/</a>)</figcaption></figure><p>Code quality is the most important goal that you should pursue in your project. If neglected, it can cause a devastating effect in the long run. Your project becomes hard to maintain. Costs increase, and the motivation of developers to work with such a project declines. In this article, I am going to describe the ways how you can ensure better code quality in your codebase.</p><h3>Unit Tests</h3><p>The main benefit of writing unit tests is the confidence that your application will not break when making changes to its codebase. Strive for 100% coverage, and enforce the least allowed code coverage by using a <a href="https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis">static code analyzer</a>. If unit coverage is not enough, do not allow completing the pull request. Developers are lazy, and sometimes applying strict rules is the only way to ensure that unit tests are written.</p><p>If somebody says that writing unit tests is the waste of time, then run from that person as fast as you can. Never compromise on the quality because it can backfire on you later.</p><p>If you are a front-end developer, you can use <a href="https://jestjs.io/">Jest</a>, which is a JavaScript unit testing framework. I have tried it in Angular and React projects, and it works well.</p><p>For projects based on .NET, you can use either <a href="https://nunit.org/">nUnit</a> or <a href="https://xunit.net/">xUnit</a>. Both of them are great, but I prefer xUnit.</p><h3>Static Code Analysis</h3><p>Static code analysis is the way to ensure the code meets a certain quality bar. Many tools on the market provide this functionality. I have personally used <a href="https://www.sonarqube.org/">SonarQube</a>, and I very much like it. It has a Community edition, which you can use for free in both personal and commercial projects. The main drawback of the community edition is the inability to analyze many git branches at the same time. Consider purchasing the Developer edition if you need per branch analysis. I have used Developer edition, and so far it works great. Beware of one thing if you are planning to buy Developer edition. SonarQube sales team is responding slowly, and it took me almost 2 months to get the license from them.</p><p>What are the benefits of static code analysis?</p><ul><li>First of all, it reduces the manual work for other developers during the code review.</li><li>It provides a safety net. A static code analyzer will highlight the potential issues in your code before these issues ever get to production.</li><li>It helps you to manage the technical debt. You can analyze older projects, and see how much technical debt is at hand.</li></ul><p>I recommend using <a href="https://www.sonarlint.org/">SonarLint IDE</a> plugin to catch potential issues before SonarQube detects them during the continuous integration (CI) process. You will see the issues as you type. You can use it in your favorite IDE such as Eclipse, IntelliJ IDEA, Visual Studio, VS Code.</p><h3>Code Reviews</h3><p>Establish a code review practice for every change you make in the codebase. Once you establish that, you can do the code review in two ways. One way is to press the approve button without having a detailed look. Another way is a thorough review. I have seen both approaches. You should review the code thoroughly, otherwise, you can’t call it a code review at all.</p><p>You can do code reviews remotely or in person. Both approaches are good, but in-person code reviews have a slight edge because you can immediately provide the feedback, and explain the findings in more detail. Also, you can bond with the person better.</p><p>Everyone in the team should take part in the code reviews. It does not matter if you are a junior or senior developer. Junior developers can also contribute a lot, and quite often, surprise you in a good way.</p><h3>Automated CI/CD Pipeline</h3><p>Use CI/CD tools like <a href="https://azure.microsoft.com/en-us/services/devops/">Azure DevOps</a>, <a href="https://www.jetbrains.com/teamcity/">TeamCity</a>, <a href="https://www.jenkins.io/">Jenkins</a>, or others. Builds should run automatically for the main branch, and also for other branches, e.g., feature branches. Display the build status in the pull request and restrict the merge to the main branch if the build fails. You could also add the SonarQube pull request decoration and disallow to complete it if SonarQube <a href="https://docs.sonarqube.org/latest/user-guide/quality-gates/">quality gate</a> fails.</p><p>Consider automatic provisioning of the new environment for each pull request branch. Cloud platforms such as Netlify provide the creation of the new environment for each pull request branch. In Netlify this feature is called <a href="https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/">Deploy Previews</a>.</p><p>Ideally, deploys should be fully automated. Production can be an exception to that, but not always. One way to automate the deployment is to set up deployment triggers based on branch names. For example, the dev branch is deployed to a dev environment, release branch to the staging environment, and merge to the master branch triggers the deployment to production.</p><p>Tools such as Octopus Deploy provide the possibility to schedule deployment to a particular time. I encourage you to build an infrastructure that allows you to perform zero-downtime deployments. Then you also can automate the deployments, and deploy every feature to the production automatically.</p><h3>Automated (UI) Tests</h3><p>Automated tests should provide you with even more confidence that new functionality did not break the existing one.</p><p>If you are a .NET developer, then <a href="https://specflow.org/">SpecFlow</a> is one of the best choices. SpecFlow is the #1 .NET open-source framework for Behavior Driven Development, Acceptance Test Driven Development, and Specification by Example.</p><p>To run the SpecFlow scenarios in the browser, you need a browser automation framework. <a href="https://www.selenium.dev/documentation/en/webdriver/">Selenium WebDriver</a> goes hand in hand with SpecFlow, and allows you to run the SpecFlow scenarios in the browser, and interact with your web application.</p><p>Automated tests should be a part of your CI pipeline.</p><h3>Conclusion</h3><p>Apply these techniques, and I am sure that code quality in your project will increase.</p><p>How do you ensure the code quality in your projects? Please share your thoughts in the comments section.</p><p>Thanks for taking the time to read my article!</p><h3>Resources</h3><ul><li><a href="https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis">List of tools for static code analysis</a></li><li><a href="https://jestjs.io/">Jest</a></li><li><a href="https://nunit.org/">NUnit.org</a></li><li><a href="https://xunit.net/">Home</a></li><li><a href="https://www.sonarqube.org/">Code Quality, Security &amp; Static Analysis Tool with SonarQube</a></li><li><a href="https://www.sonarlint.org/">SonarLint | Free and Open Source Code Quality &amp; Security IDE Extension</a></li><li><a href="https://azure.microsoft.com/en-us/services/devops/">Azure DevOps Services | Microsoft Azure</a></li><li><a href="https://www.jetbrains.com/teamcity/">TeamCity: the Hassle-Free CI/CD Tool by JetBrains</a></li><li><a href="https://www.jenkins.io/">Jenkins</a></li><li><a href="https://docs.sonarqube.org/latest/user-guide/quality-gates/">quality gates</a></li><li><a href="https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/">Introducing Deploy Previews in Netlify | Netlify</a></li><li><a href="https://specflow.org/">BDD Framework for .NET - SpecFlow - Find Bugs before they happen</a></li><li><a href="https://www.selenium.dev/">Selenium</a></li><li><a href="https://www.selenium.dev/documentation/en/webdriver/">WebDriver</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd2352c2f2f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/if-tech/ways-to-ensure-decent-code-quality-in-the-project-bd2352c2f2f6">Ways to ensure decent code quality in the project</a> was originally published in <a href="https://medium.com/if-tech">If Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Five podcasts that I recommend listening to]]></title>
            <link>https://medium.com/@viktors.telle/five-podcasts-that-i-recommend-listening-to-9bd8c4e56dd4?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bd8c4e56dd4</guid>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[podcast]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[enterpreneurship]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 03:21:08 GMT</pubDate>
            <atom:updated>2020-08-05T08:27:34.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>Five Podcasts That I Recommend Listening To</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tt-nIiTKuVEH4ehb" /><figcaption>Photo by <a href="https://unsplash.com/@firmbee?utm_source=medium&amp;utm_medium=referral">William Iven</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When the Covid-19 outbreak started, I started to work from home as many people did. It meant that I do not have to spend extra hours on the commute. So I decided to spend the saved time to invest more in broadening my knowledge in finance, entrepreneurship, and information technology. Investing in your knowledge is the best investment that you could do. Listening to the podcasts was one of the new things that I started to do. I mostly listen to them during my everyday walk with my daughter, but only when she falls asleep in the stroller.</p><p>Here is the list of the five podcasts that I listen to regularly.</p><h3>We Study Billionaires</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*NqJD6K7RK15xiThG.png" /><figcaption>We Study Billionaires</figcaption></figure><p>First, I wanted to understand finances better so I did the research and found a couple of promising podcasts. This is one of my favorites. It comes out every Sunday and informs you of the latest developments in economics and investing. The podcast hosted by Preston Pysh and Stig Brodersen talks about the investment strategies of famous investors like Warren Buffet and Ray Dalio. They also review popular books on investing and entrepreneurship and invite guests to talk about the latest trends in economics and investing. I especially enjoyed these episodes:</p><p><a href="https://open.spotify.com/episode/5cR75xNOBhZnsO9r9zwq12?si=fjjTnt7VR2uaByZAbuAQXw">TIP307: Cullen Roche on Stocks, Inflation, &amp; COVID-19 (Business Podcast)</a></p><p><a href="https://open.spotify.com/episode/1WgFC5ajRTTyKlNcrE3KYo?si=IvnxRxuXS9KCMc0cMy7jxw">TIP 011: Billionaire Jeff Bezos — The Secrets to his Success (Investing Podcast)</a></p><p><a href="https://open.spotify.com/episode/5v09LZG7Np60A7CTvQ0hhq?si=dI_U0-AbQUSbWKFe3IcQHg">TIP 014: Guy Spier — The Education of a Value Investor (Investing Podcast)</a></p><p><a href="https://open.spotify.com/show/28RHOkXkuHuotUrkCdvlOP?si=sgpBam5cTV-00FPWApTThA">Link to the show on Spotify</a></p><h3>Techmeme Ride Home</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*0CCsR_2jJRCuvycM.jpg" /><figcaption>Techmeme Ride Home</figcaption></figure><p>This podcast comes out every weekday. Brian does a great job informing listeners of the latest technology news such as product news, recent acquisitions, earnings reports of the big tech companies. This podcast is based on <a href="https://www.techmeme.com/">techmeme.com</a>, which is Silicon Valley’s most-read news source.</p><p><a href="https://open.spotify.com/show/1jBNbPVlGUen3sWdd25ho6?si=TPm4Ua8ASnqhMr6cFOQ78w">Link to the show on Spotify</a></p><h3>The Web Platform Podcast</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*lphmwVrJBpA5tgky.png" /><figcaption>The Web Platform Podcast</figcaption></figure><p>I am a web developer myself. It is only reasonable that I should listen to the podcast that talks about the latest trends in web development.</p><p>This podcast was founded in 2014 by HTML W3C invited expert Erik Isaksen. It covers the latest topics in web development such as <a href="https://deno.land/">Deno</a>, which is the new runtime for JavaScript and TypeScript, and an alternative to <a href="https://nodejs.org/">Node.js</a>, modern HTML practices, or the latest tools for the web development.</p><p><a href="https://open.spotify.com/show/3apF0cv7ub3mC3J5e7Lq6v?si=NKRzqe9XSM-qHJFi93PPtA">Link to the show on Spotify</a></p><h3>AskPat 2.0</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*d5xmhHki1yIma23c.png" /><figcaption>AskPat 2.0</figcaption></figure><p>When it comes to entrepreneurship podcast by Pat Flynn is the best. This podcast comes out every day. Pat answers one question asked by one of his listeners. Questions like:</p><ul><li>How to create the best “About” page on your website?</li><li>How to increase engagement and participation in your community?</li><li>How do you handle negative reviews?</li></ul><p>These and many more questions get answered during the show and help you and your business to perform better. Probably later I will also listen to another Pat Flynn’s podcast: ”<a href="https://open.spotify.com/show/7wjv5MRCXWXImqTFhcufLy?si=EK4-SNgZRi6OrHW_NOYNdw">The Smart Passive Income Online Business and Blogging Podcast</a>“.</p><p><a href="https://open.spotify.com/show/00CuvjXkTsBJkp7F2v1Rjl?si=IHAYvyNaQcCy_X6Z89MC_Q">Link to the show on Spotify</a></p><h3>The College Investor Audio Show</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*MYoJAmGCSJZPYZHU.jpg" /><figcaption>The College Investor Audio Show</figcaption></figure><p>One more podcast covering finances and investing. I watched some episodes on topics that interested me at a particular time. For example:</p><ul><li>The Cheapest Investing Platforms and Robo-advisors.</li><li>6 Ideas to Diversify Your Income Streams</li><li>How To Invest In Stocks</li></ul><p><a href="https://open.spotify.com/show/2WtF5XvOdiNNLSXbkPmvLa?si=FqYbpLBpT12V267ITgKpWw">Link to the show on Spotify</a></p><h3>Final Words</h3><p>You can find all of these podcasts on Spotify. I have provided the links above. I encourage you to give them a shot and hope that you will enjoy them as I do. What are your favorite podcasts?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bd8c4e56dd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My questions to the developers in the job interview]]></title>
            <link>https://medium.datadriveninvestor.com/my-questions-to-the-developers-in-the-job-interview-560a866b3bf0?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/560a866b3bf0</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[interview-tips]]></category>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[recruitment]]></category>
            <category><![CDATA[hiring]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Sun, 19 Jul 2020 18:56:43 GMT</pubDate>
            <atom:updated>2020-07-27T09:48:21.631Z</atom:updated>
            <content:encoded><![CDATA[<h4>I have conducted over 50 job interviews with developers. What question do I usually ask? Are soft skills important for the developer? I will answer these questions and more in this article.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*daUXl7fbCVzMgC9M" /><figcaption>Photo by <a href="https://unsplash.com/@wocintechchat?utm_source=medium&amp;utm_medium=referral">Christina @ wocintechchat.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I will describe my own interviewing experience with developers. People who I interview, have different expertise levels. I have spoken with pure back-end and front-end developers and also full-stack developers. During the interview, I explain what is the team set-up and what technologies and methodologies we use. Also, I ask questions to understand the candidate’s level of experience. As I am a system architect, not an HR person, my questions are mostly technical ones.</p><h4>Questions I usually ask</h4><p>Since the code quality is one of the key metrics in software development, I usually start with the question:</p><ul><li>How do you and your team ensure a good code quality level?</li></ul><p>Then I proceed with the next questions:</p><ul><li>How does the code gets deployed to the production? Explain the journey of the code starting from the commit until it ends up in production.</li><li>What are the ways you gain new knowledge in software development?</li><li>What is the latest technology, programming language, or framework you have learned?</li><li>Are you familiar with the SOLID principles? Can you explain a few of these principles from your own experience?</li><li>Do you follow some other best practices when writing the code?</li><li>How do you detect and troubleshoot production issues?</li><li>What is the branching strategy that you use in the latest projects?</li><li>Do you write unit tests daily? What are the benefits of unit tests?</li></ul><p>If I see that person is familiar with unit testing, then I ask about the test coverage.</p><p>It’s fine not to have the answers to all of these questions. You can tell the level of seniority based on how questions are answered.</p><p>Look, I am not a fan of asking theoretical questions. I am not saying that you should not know the software development theory. I believe that my questions can better reflect the maturity and hand-on experience of the person. As you can see, none of the questions include the specifics of any programming language. It is not necessary to ask such questions since you can assess the technical knowledge differently.</p><h4>How to test technical knowledge?</h4><p>The best way to assess candidate technical skill levels is by giving them a coding task. I prefer the option to allow the candidate to complete the task at home. A person can then write the code without unnecessary stress and set the deadline by themself.</p><p>Once you have received the completed task, you can check:</p><ul><li>Readability. It is arguably the most important metric of the code. We spend more time reading other people’s code than writing our code. Names of variables, classes, properties, etc, should be understandable and describe their intent. Ideally, you should read the code like a book.</li><li>Code structure. Is the code separated by folders? Are the unit tests structured according to the main project structure? Is the project structure logical? For example, you should not place DTOs (Data Transfer Object) under the Domain folder.</li><li>Attention to the details. Has the candidate read the assignment carefully and implemented all the required features? Has he or she asked the questions if something was unclear? It is always better to ask the questions, rather than make assumptions and redo later if the assumptions turned out to be incorrect.</li><li>Knowledge depth of the programming language. Is the candidate using the latest language features? Are the optimal data structures used in particular situations? Are language best practices followed?</li><li>Quality of the unit tests. Are the names of the test clear? Can you understand the intent of the test? Is the test verifying only a single value or scenario? What is the test coverage? Is the test verifying both positive and negative scenarios?</li><li>Compliance with <a href="https://en.wikipedia.org/wiki/SOLID">SOLID</a> principles. This is extremely important. SOLID are fundamental principles in software development that make your applications well maintainable.</li><li>The simplicity of the solution. Is the KISS (Keep it Simple, Stupid) principle followed? You don’t need to impress the reviewer by creating a complex solution with a lot of classes and abstractions to show off your knowledge.</li></ul><blockquote>“Genius is making complex ideas simple, not making simple ideas complex.” — Albert Einstein.</blockquote><p>After reviewing the home task, the detailed code review is always sent back to the candidate.</p><h4>What about soft skills?</h4><p>What are soft skills anyway? Soft skills are, but not limited to, communication, critical thinking, leadership, positive attitude, teamwork, work ethic. It is not enough to have only great technical skills. Ok, if you are developing your project without need talking to other people, then it is acceptable lacking soft skills. Yet, in real-life projects, you have to communicate with different people like fellow developers, testers, product owners, even business people sometimes. You have to have at least a basic set of soft skills. Here is what raises a red flag to me immediately.</p><ul><li>The person is arrogant. You can see that by watching how a candidate behaves. Sometimes a person thinks that he or she is already hired before having the interview and only has come to ask us the questions and decide if we meet the expectations. There are also situations when candidates do not understand why I am asking them about SOLID principles. They say something like this: “I know a lot of principles because I have 10+ years of experience in software development. Why are you asking me this? I am not answering this question.”. Years of experience alone do not necessarily correlate with the level of expertise. One more thing I encourage not to do is interrupting the interviewer all the time. Be humble and polite during the interview. Actions speak louder than words.</li><li>An interviewee is not tolerant of criticism. <br>How to determine the tolerance to the criticism? You can ask a simple question. Imagine you have created a new pull request. Your colleagues have reviewed it and left some comments with suggested improvements. How do you react to these comments?</li></ul><p>The hiring process is most likely not continued with a particular candidate if one of these negative traits is observed.</p><h4>Final words</h4><p>The aim of the questions I ask during the interview is to understand the maturity level of the candidate. Combine them with coding task and you should understand whether the candidate is the senior, middle, or junior developer.</p><p>What are your expectations of candidates? What questions do you ask? Your comments are the most welcome.</p><p>Thanks for taking the time to read my article!</p><p>Resources:</p><p><a href="https://www.thebalancecareers.com/list-of-soft-skills-2063770">Best Soft Skills to List on a Resume</a></p><p><a href="https://en.wikipedia.org/wiki/SOLID">https://en.wikipedia.org/wiki/SOLID</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=560a866b3bf0" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/my-questions-to-the-developers-in-the-job-interview-560a866b3bf0">My questions to the developers in the job interview</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install .Net Core Runtime in Service Fabric Using Terraform]]></title>
            <link>https://medium.com/swlh/how-to-install-net-core-runtime-in-service-fabric-using-terraform-dcca95dedb74?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcca95dedb74</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[service-fabric]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[powershell]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Sat, 04 Jul 2020 13:38:13 GMT</pubDate>
            <atom:updated>2020-07-24T19:32:38.739Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Install .Net Core Runtime in Service Fabric Using Terraform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YbHfYkafZRiswVOi" /><figcaption>Photo by <a href="https://unsplash.com/@jefflssantos?utm_source=medium&amp;utm_medium=referral">Jefferson Santos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, I am going to share my own experience and thought process since I could not find existing tutorials on how to do that. Recently, we have decided to install .NET Core runtime in the Service Fabric cluster to reduce the package size deployed to the cluster. It should reduce the deployment time for many .NET Core applications. Currently, we are using self-contained deployments, which result in deploying large packages that take a long time.</p><h4>First attempt</h4><p>In the beginning, I thought that this is a straightforward task to do, but I was so wrong. Why did I think that this is going to be easy? Well, we already had Terraform templates for the <a href="https://www.terraform.io/docs/providers/azurerm/r/service_fabric_cluster.html">Service Fabric cluster</a> and <a href="https://www.terraform.io/docs/providers/azurerm/r/virtual_machine_scale_set.html">Virtual Machine Scale Sets</a> (VMSS). We also had the .NET Framework 4.8 installation on VMSS via Powershell (.ps1) script added to the Terraform template as an extension to the VMSS.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a9de4a04dd825c3378cb63310699a31/href">https://medium.com/media/5a9de4a04dd825c3378cb63310699a31/href</a></iframe><p>First, I decided to look for a .ps1 script that could install the runtime non-interactively. It turned out that Microsoft already had such a <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#recommended-version">script</a>. I thought, great let me download it and add to the existing Terraform VMSS configuration as an additional extension. I did that and the result looked good, so I created a Pull Request (PR). My coworkers reviewed it, and also Terraform validation passed. After completing the PR, the feature branch was merged to the dev branch, and automatic deployment started to the dev environment. As you might probably guess, it did not work quite well. Unfortunately, Azure does not support many extensions of the same type.</p><h4>Second attempt</h4><p>All right, not a big deal, I will add this logic to the existing extension, which installs .NET Framework 4.8. I used the pipe operator to combine multiple .ps1 commands.</p><pre>powershell -ExecutionPolicy Unrestricted -File InstallDotNet-48.ps1 &amp;&amp; powershell -ExecutionPolicy Unrestricted -File dotnet-install.ps1 -Runtime dotnet -Channel 2.1 &amp;&amp; powershell -ExecutionPolicy Unrestricted -File dotnet-install.ps1 -Runtime dotnet -Channel 3.1</pre><p>I changed the Terraform template again and repeated the deployment process. Unfortunately, the deployment failed due to unable to download the needed files for the .NET Core runtime. Something was blocking the download of the files. My next move was to connect to the one of the Virtual Machines (VM) and launch the .NET Core installation .ps1 script manually to check what went wrong. I was able to reproduce the issue. Ok, how can I solve it? I started to research. After searching for some time, I found a possible solution in the documentation: <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples">https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples</a>. Scroll down until “Obtain script and install .NET Core CLI one-liner examples” section.</p><pre># Run a separate PowerShell process because the script calls exit, so it will end the current PowerShell session.<br>&amp;powershell -NoProfile -ExecutionPolicy unrestricted -Command &quot;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &amp;([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing &#39;<a href="https://dot.net/v1/dotnet-install.ps1&#39;">https://dot.net/v1/dotnet-install.ps1&#39;</a>))) &lt;additional install-script args&gt;&quot;</pre><p>This piece of code below helped to solve the problem since only Ssl3 and Tls security protocols were enabled in the PowerShell session on Windows Server 2016 Datacenter.</p><pre>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;</pre><p>I modified the Terraform template again and repeated the deployment process.</p><pre>powershell -ExecutionPolicy Unrestricted -File InstallDotNet-48.ps1 &amp;&amp; powershell -NoProfile -ExecutionPolicy unrestricted -Command \&quot;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &amp;([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing &#39;<a href="https://dot.net/v1/dotnet-install.ps1&#39;">https://dot.net/v1/dotnet-install.ps1&#39;</a>))) -Runtime dotnet -Channel 2.1 \&quot; &amp;&amp; powershell -NoProfile -ExecutionPolicy unrestricted -Command \&quot;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &amp;([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing &#39;<a href="https://dot.net/v1/dotnet-install.ps1&#39;">https://dot.net/v1/dotnet-install.ps1&#39;</a>))) -Runtime dotnet -Channel 3.1 \&quot;</pre><p>This time the deployment finished successfully, but there was another issue to solve.</p><h4>Third attempt</h4><p>It turned out that .NET Core apps expect the runtime to be in C:\Program Files\dotnet directory, but the .NET Core .ps1 installation script installs the runtime in the user profile folder by default.</p><p>There are two ways to solve this:</p><ul><li>Change the installation directory to the C:\Program Files\dotnet.</li><li>Add the DOTNET_ROOT environment variable with the path to the custom location of the dotnet.exe.</li></ul><p>I decided to add the installation directory argument to install it in the default directory. The result looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e1865495d117e52103efa29a4de6578/href">https://medium.com/media/1e1865495d117e52103efa29a4de6578/href</a></iframe><p>And this finally worked! My colleague made sure that it works by deploying the .NET Core app without passing --self-contained true parameter to the dotnet publish command.</p><h4>Conclusion</h4><p>Installing the .NET Core runtime in the Service Fabric cluster turned out to be not so straight forward task as it seemed in the beginning. The main reason is the lack of documentation and examples on how to do it via Terraform templates. Thanks for reading!</p><p>References:</p><p><a href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples">https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script</a></p><ul><li><a href="https://www.terraform.io/docs/providers/azurerm/r/service_fabric_cluster.html">Azure Resource Manager: azurerm_service_fabric_cluster - Terraform by HashiCorp</a></li><li><a href="https://www.terraform.io/docs/providers/azurerm/r/virtual_machine_scale_set.html">Azure Resource Manager: azurerm_virtual_machine_scale_set - Terraform by HashiCorp</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcca95dedb74" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-install-net-core-runtime-in-service-fabric-using-terraform-dcca95dedb74">How to Install .Net Core Runtime in Service Fabric Using Terraform</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 approaches on how to create reliable messaging architecture]]></title>
            <link>https://medium.datadriveninvestor.com/4-approaches-on-how-to-create-reliable-messaging-architecture-4aefcfc13cfd?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/4aefcfc13cfd</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[mass-transit]]></category>
            <category><![CDATA[messaging]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 19:02:51 GMT</pubDate>
            <atom:updated>2020-06-19T04:10:23.193Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gBrq3UGYUVJ76p5D" /><figcaption>Photo by <a href="https://unsplash.com/@katemacate?utm_source=medium&amp;utm_medium=referral">Kate Macate</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Microservice architecture is trendy these days. Quite often it comes together with asynchronous data handling via messaging infrastructure. By asynchronous handling, I mean the data processing functionality executed in the background. Our company is not an exception in that sense, and we are using messaging quite a lot in our applications. It allows the handling of time-consuming tasks in the background. Users don’t have to wait until something has finished processing. The application also becomes more responsive to users.</p><p>Have you ever thought of the way how to handle messages that tolerates various errors? And also needs less manual work to handle these errors? Let me introduce you to the message retries, idempotency, and outbox in the messaging pipeline.</p><p>In this article, I am going to describe how to implement error handling using the <a href="https://www.rabbitmq.com/">RabbitMQ</a> and <a href="https://masstransit-project.com/">MassTransit</a> library. It will make your data handling pipeline more resilient and reliable.</p><p>Here are some prerequisites before you can successfully run the sample code used in this article:</p><ul><li>Install RabbitMQ on <a href="https://www.rabbitmq.com/install-windows.html">Windows</a> or <a href="https://www.rabbitmq.com/install-debian.html">Linux</a>.</li><li>Install <a href="https://dotnet.microsoft.com/download/dotnet-core/3.1">.NET Core 3.1 SDK</a></li><li>Install <a href="https://www.mongodb.com/try/download/community">MongoDB</a></li></ul><p>Also, this article assumes you have knowledge of C# and basic knowledge of RabbitMQ, MassTransit, and MongoDB.</p><h4>First-level retries</h4><p>Imagine, one of the services you are integrated with becomes unavailable for a couple of minutes. You will most likely get service unavailable exception while the call is made to that particular service. Probably that should not cause immediate failure to the message handling because the message will be moved to the error queue, and who wants to handle potentially huge amounts of messages manually, right? First-level retries are life saviors in these types of situations.</p><p><a href="https://www.datadriveninvestor.com/2018/08/02/making-the-leap-from-speech-to-dialogue-the-challenge-for-human-to-machine-communication/">Making the Leap from Speech to Dialogue: The Challenge for Human to Machine Communication | Data Driven Investor</a></p><p>They mostly should be used to handle transient exceptions such as database deadlocks, brief connections unavailability, and other types of situations when the duration of the issue is short, and application can quickly recover.</p><p>Here is the code example of how first-level retries can be configured.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c16ecff46808490754be8c8ded9e3770/href">https://medium.com/media/c16ecff46808490754be8c8ded9e3770/href</a></iframe><p>I have created a simple .NET Core console application to show the configuration needed to enable retries and added a plain message handler to test the retry logic. Notice that message is retried for the three times when you run the application.</p><p>You can read more about first-level retries in the <a href="https://masstransit-project.com/usage/exceptions.html#retry">MassTransit documentation</a>.</p><h4>Second-level (redelivery) retries</h4><p>These retries are particularly useful when you have integrations with other systems, and those systems can potentially be unavailable due to various reasons for a longer period. Your application should be tolerant against such situations and not immediately send the message to the error queue. Error queue is the last resort in the message handling pipeline.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b79d1166ef4dd9f1e10bf53ba08ef12a/href">https://medium.com/media/b79d1166ef4dd9f1e10bf53ba08ef12a/href</a></iframe><p>I have slightly adjusted the previous example by adding a configuration that enables message redelivery.</p><p>I have chosen to use the <a href="https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/">RabbitMQ Delayed Message Plugin</a> because it is a lightweight alternative to Quartz, which does not require any storage outside of RabbitMQ.</p><p>You need to complete several steps for redelivery to work. To make this work with RabbitMQ, you also need to install the rabbitmq_delayed_message_exchange plugin by following the <a href="https://www.rabbitmq.com/installing-plugins.html">plugin installation guide</a>. After the plugin has been installed, run rabbitmq-plugins enable rabbitmq_delayed_message_exchange command in the RabbitMQ sbin command line to enable it.</p><p>After enabling it and launching the application, a new exchange is created (see the image below) to store the messages that need to be retried after a configured period and will guarantee that messages are not lost upon the RabbitMQ node restart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVdlwQ_FjhSVfFbkOE5YLg.png" /></figure><p>You can read more about the redelivery in <a href="https://masstransit-project.com/usage/exceptions.html#redelivery">MassTransit documentation</a>. When you run the updated application, you will notice that first-level retries are executed in the beginning, and only then redelivery kicks in for the messages that were not handled successfully during first-level retries. In this example, messages will eventually appear in the error queue because the exception is thrown all the time. Redelivery will not help in this case.</p><p><strong>Do not retry certain exceptions</strong></p><p>You might have situations when specific types of exceptions should be ignored during the execution of either the first or the second-level retries. For example, the message should not be retried if it fails some specific validation. Fortunately, MassTransit provides such functionality, and it is called <a href="https://masstransit-project.com/usage/exceptions.html#exception-filters">Exception filters</a>. You can either ignore certain exceptions or retry only specific ones.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b578461cfdd363189a019161b04d2efd/href">https://medium.com/media/b578461cfdd363189a019161b04d2efd/href</a></iframe><p>I have added this line of code in two places compared to the previous example.</p><p>retryConfigurator.Ignore(typeof(NameTooShortException));</p><p>This tells us to ignore retrying NameTooShortException for both first and second-level retries.</p><h4>Message idempotency</h4><p>Here is the definition of idempotence from <a href="https://en.wikipedia.org/wiki/Idempotence">Wikipedia</a>:</p><blockquote><strong>Idempotence</strong> (<a href="https://en.wikipedia.org/wiki/British_English">UK</a>: <a href="https://en.wikipedia.org/wiki/Help:IPA/English">/ˌɪdɛmˈpoʊtəns/</a>,<a href="https://en.wikipedia.org/wiki/Idempotence#cite_note-1">[1]</a> <a href="https://en.wikipedia.org/wiki/American_English">US</a>: <a href="https://en.wikipedia.org/wiki/Help:IPA/English">/ˌaɪdəm-/</a>)<a href="https://en.wikipedia.org/wiki/Idempotence#cite_note-2">[2]</a> is the property of certain <a href="https://en.wikipedia.org/wiki/Operation_(mathematics)">operations</a> in <a href="https://en.wikipedia.org/wiki/Mathematics">mathematics</a> and <a href="https://en.wikipedia.org/wiki/Computer_science">computer science</a> whereby they can be applied multiple times without changing the result beyond the initial application.</blockquote><p>How this applies to the messaging, you might ask. In the messaging architecture, the idempotency means making sure that it is possible to process the same message infinite times, and the result will always be identical. It means no duplicate database records, no emails, or other types of notifications sent many times. This approach has the following benefits:</p><ul><li>Excludes the need for transactions. They can be quite tricky in the messaging infrastructure. Usually, message handlers call other services, and it is quite difficult to manage transactions across many systems.</li><li>Enables the use of retries without concerns that something might fail when the consumer processes the message the second time.</li></ul><p>How to start using it? To avoid duplicate record creation in the database, you need to add a check. It will verify the existence of the record before adding a new record. If the record already exists, you should return the existing one or skip creating a new one. It depends on the concrete use case.</p><p>To avoid duplicate notification sending, e.g., email or SMS, you need to save the previous sending fact somewhere. The most obvious choice is the database. Then add a logic that will verify if the same type of notification was already sent.</p><p>Apply this pattern in all places on the consumer side, and you will be able to handle the same message infinite times.</p><h4>Message outbox</h4><p>Another way to improve the reliability of messaging is to use the message outbox on the producer (publisher) side. Message outbox is a great approach to deal with situations when you lose connection to the RabbitMQ. You want to send the message to the consumer anyway without failing the user action.</p><p>One way to implement this is by adding some persistent storage to save the serialized message. The type of persistent storage does not matter. It can depend on the database technology used in your company, or it may also be the database where you have the most knowledge. You also need to create a timer-based background job that will later resend these failed messages. It will guarantee that messages are not lost. Of course, the database can be unavailable too. In that case, one option is to show the error message in the GUI that something went wrong, and the user should contact the support.</p><p>Let me show you the two possible ways how to create an outbox.</p><p>MassTransit provides <a href="https://masstransit-project.com/2020/02/08/in-memory-outbox/">in-memory message outbox</a>. You can watch a great <a href="https://www.youtube.com/watch?v=P41IsVAc1nI">video</a> from Chris Patterson, where he shows the outbox in practice with sagas. You can check his source code on <a href="https://github.com/phatboyg/Trashlantis">GitHub</a>.</p><p>I am going to show another way how to implement a message outbox. In my case, the message outbox resides on the producer side, and it can handle the situations when RabbitMQ is down.</p><p>I have used the following technologies:</p><ul><li><a href="https://www.rabbitmq.com/">RabbitMQ</a></li><li><a href="https://masstransit-project.com/">MassTransit</a> library</li><li><a href="https://dotnet.microsoft.com/download/dotnet-core/3.1">.NET Core 3.1</a></li><li><a href="https://www.mongodb.com/">MongoDB</a></li></ul><p>I have created the .NET Core console application and used the <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&amp;tabs=visual-studio#worker-service-template">Worker Service</a> template to host three types of services:</p><ul><li>Message publisher service</li><li>Message outbox processing service</li><li>Consumer service</li></ul><p>Message publisher service handles saving the messages in the MongoDB if the publishing fails.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27df9426c3cf6508b90fa91eeabb5d23/href">https://medium.com/media/27df9426c3cf6508b90fa91eeabb5d23/href</a></iframe><p>Message outbox processing service collects all unprocessed messages from MongoDB and tries to publish them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09533bba0e888e6db69cd5ff8c1855ad/href">https://medium.com/media/09533bba0e888e6db69cd5ff8c1855ad/href</a></iframe><p>Notice that I have used MongoDB transaction while message processing is happening. In case of failure, the message status is set back to unprocessed. Another reason for using transaction is to ensure that records in the database are locked during the transaction. Here is the example of the method, which initiates the transaction. The complete code of the class is available on <a href="https://github.com/viktors-telle/mass-transit-examples/blob/master/src/MessageOutbox/Outbox/MessageOutboxRepository.cs">GitHub</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56a02c3423de9beb87ebd327d6681550/href">https://medium.com/media/56a02c3423de9beb87ebd327d6681550/href</a></iframe><p>If the previous step runs fine, consumer service will receive these messages.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a146f46254b25747af196e53c3e72854/href">https://medium.com/media/a146f46254b25747af196e53c3e72854/href</a></iframe><h4>Conclusions</h4><p>The approaches described here are battle-tested in the production environment and work quite well. Message redelivery, idempotency, and outbox reduced the manual work for the support engineers and made our services more stable and resilient against various errors.</p><p>You can look at the complete example on <a href="https://github.com/viktors-telle/mass-transit-examples">GitHub</a>.</p><p><strong>Gain Access to Expert View — </strong><a href="https://datadriveninvestor.com/ddi-intel"><strong>Subscribe to DDI Intel</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4aefcfc13cfd" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/4-approaches-on-how-to-create-reliable-messaging-architecture-4aefcfc13cfd">4 approaches on how to create reliable messaging architecture</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top ten mistakes found while performing code reviews]]></title>
            <link>https://medium.com/swlh/top-ten-mistakes-found-while-doing-code-reviews-b935ef44e797?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/b935ef44e797</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Wed, 25 Mar 2020 12:43:45 GMT</pubDate>
            <atom:updated>2020-07-28T15:32:13.851Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*5RhyUqWmrXugwrjchoA5rA.jpeg" /><figcaption><a href="https://www.osnews.com/story/19266/wtfsm/">https://www.osnews.com/story/19266/wtfsm/</a></figcaption></figure><p>Code review is an excellent way to have four or more eye principle for the written code. It improves the overall code quality in the project, of course, if you do it thoroughly. In the day-to-day work, we use Azure DevOps Git repositories and perform code reviews daily via pull requests. Below are the ten most common faults that I have encountered while doing code reviews in no particular order.</p><h4>1. Naming</h4><p>Naming is one of the most complicated elements while building the software. I struggle with it too! Ideally, you should choose to name your classes and properties so that your code can be read as a book. Try to choose the name of the method, class, property or variable as expressive as possible.</p><p>For variable name instead of using var timeElapsed = 0; try var timeElapsedInSeconds = 0;. Why another developer should guess what unit of measurement you chose for this particular variable? You can include it in the name so that the intent is clear. In the previous example, you could also use TimeSpan struct instead of int as it offers more flexibility. You could then change the name of the variable to timeElapsedSinceStart.</p><p>The name of the method should include a verb to represent the action that it does.</p><pre>public decimal CalculatePrice() { ... }<br>public User GetUser(int id) { ... }</pre><p>Instead of using some technical name for the class, try choosing the name to represent its business logic.</p><pre>public class SalaryCalculator { ... }<br>public class User { ... }</pre><h4>2. String comparison</h4><p>Quite often I notice that developers do not pay much attention to the case sensitivity or culture settings when comparing string values. However, this is important and neglecting it might lead to potential bugs.</p><p>Usually, I see a similar comparison to this if (name == &quot;John&quot;). Sometimes it might be what we want, but in many cases, you need to ignore whether the name was typed in uppercase or lowercase, for example, when implementing search by person name. You could change the previous comparison to the following.</p><pre>if (name.Equals(&quot;John&quot;, StringComparison.CurrentCultureIgnoreCase)) { <br>    ... <br>}</pre><p>It will allow searching for “JOHN”, “john” or any other combination of lowercase and uppercase letters by respecting the culture-specific language rules.</p><p>If you wanted to check the file extension the better choice would be to use OrdinalIgnoreCase comparison type because it performs a simple byte comparison that is independent of language.</p><h4>3. Deep nesting</h4><p>Have you ever seen a similar code to this?</p><pre>if (something)<br>{<br>    if (somethingElse)<br>    {<br>        ...<br>    }<br>}</pre><p>Most of us probably have. Such an approach makes it harder to read the code. One way to solve this issue is to invert if statement.</p><pre>if (!something)<br>{<br>    return;<br>}</pre><pre>if (!somethingElse)<br>{<br>    return;<br>}</pre><pre>...</pre><p>Just by inverting if statement and returning out of the method as soon as possible you eliminated the nesting and made the code more transparent.</p><p>Another option would be to combine the conditions in a single if statement.</p><pre>if (!something &amp;&amp; !somethingElse)<br>{<br>    return;<br>}</pre><p>You can further improve this piece of code by extracting both conditions to a separate method. Consider this example.</p><pre>if (account.Status != AccountStatus.Suspended<br>    &amp;&amp; account.Status != AccountStatus.Terminated)<br>{<br>    ...<br>}</pre><p>And this improved version.</p><pre>if (AccountIsActive())<br>{<br>    ...<br>}</pre><pre>private bool AccountIsActive()<br>{<br>    return account.Status != AccountStatus.Suspended<br>        &amp;&amp; account.Status != AccountStatus.Terminated<br>}</pre><p>Having a separate method to check if the account is active made your code more readable.</p><h4>4. Single responsibility principle violation</h4><p>My favorite Single responsibility principle (SRP) definition is by <a href="https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html">Uncle Bob</a>:</p><blockquote>The Single Responsibility Principle (SRP) states that each software module should have one and only one reason to change.</blockquote><blockquote>Gather together the things that change for the same reasons. Separate those things that change for different reasons.</blockquote><p>These statements can also be found in his outstanding book Clean Architecture.</p><p>From time to time I stumble upon the class/method that simply has too many responsibilities. Keep your methods short and make sure they do only one particular task. Extract extra logic to a separate method or class. Also, make sure that this exact method should really be placed in a particular class.</p><h4>5. Redundant null checks</h4><p>In my opinion, you should avoid null checks as much as possible because they pollute the code and make it less elegant. I am advocating that you should not check for null values. After all, in reference type languages like C#, null checks are quite common to guard against infamous NullReferenceException.</p><p>Let’s examine the following example.</p><pre>private readonly IUserStorage userStorage;</pre><pre>public IList&lt;User&gt; GetUsers()<br>{<br>    return userStorage.GetUsers() ?? new List&lt;User&gt;();<br>}</pre><p>It would more convenient for the method GetUsers() consumer if this method returns an empty list when users were not found in the database, rather than the null value.</p><p>Try to initialize class collection properties with an empty collection instead of hoping that consumers of the class will not forget to do it.</p><pre>public class User<br>{<br>    public User()<br>    {<br>        Roles = new List&lt;Role&gt;();<br>    }</pre><pre>    public IList&lt;Role&gt; Roles { get; set; }<br>}</pre><h4>6. Redundant comments</h4><p>Do not write comments for the self-explanatory code. Overusing comments can make your code harder to read. I have seen the code where people write comments for almost every line of code. Why not use better naming instead?</p><p>I accept only comments that explain the workaround of a known issue and provide the link to GitHub or some other place where this issue was raised.</p><h4>7. Overusing async</h4><p>You either go all the way async or sync. Don’t mix the sync and async code. It can lead to deadlocks. Please refer to this <a href="https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html">article</a> if you want to find more about how blocking async code can cause deadlocks. Take a look at the example below.</p><pre>public class UserController<br>{<br>    private readonly IUserStorage userStorage;<br> <br><strong>    public async Task&lt;IActionResult GetUser(int id)<br>    {<br>        return userStorage.GetUser(id).Result;<br>    }</strong><br> <br>    public async Task&lt;IActionResult GetUser(int id)<br>    {<br>        return await userStorage.GetUser(id);<br>    }<br>}</pre><p>The approach highlighted in <strong>bold</strong> should not be used because it will block the context thread that can potentially cause the deadlock. If your storage does not support asynchronous calls, then it is better to rewrite the code to the synchronous version similar to the example below.</p><pre>public class UserController<br>{<br>    private readonly IUserStorage userStorage;<br> <br>    public IActionResult GetUser(int id)<br>    {<br>        return userStorage.GetUser(id);<br>    }<br>}</pre><h4>8. Passing too many parameters</h4><p>It is considered good practice when a method has few parameters. When it doesn’t, it can potentially violate SRP. One of the options on how to reduce the number of parameters is extracting them to separate class and passing it instead of many parameters. Another option is to revise the necessity of each parameter and possibly split the method into multiple methods. Here is another great quote by Uncle Bob from his book Clean Code:</p><blockquote>The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic) should be avoided where possible. More than three (polyadic) requires very special justification — and then shouldn’t be used anyway.</blockquote><h4>9. Lack of unit tests</h4><p>You should cover your code with tests. Period. Make sure that code is covered by unit tests or use tools that will check that automatically. We use <a href="https://www.sonarqube.org/">SonarQube </a>or <a href="https://www.jetbrains.com/resharper/">ReSharper</a> test runner to check whether code is coverage is at the optimal level.</p><h4>10. Magic strings</h4><p>You should avoid using magic strings in the code. Sometimes the magic string repeats in multiple places and therefore violates DRY (Do not repeat yourself) principle. The easiest fix is to extract the string value to constant. Another option is to use the configuration file or database if this value can change due to some specific reasons like the deployment environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b935ef44e797" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/top-ten-mistakes-found-while-doing-code-reviews-b935ef44e797">Top ten mistakes found while performing code reviews</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure DevOps multi-stage deployments]]></title>
            <link>https://levelup.gitconnected.com/azure-devops-multi-stage-deployments-708a54700a85?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/708a54700a85</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Sun, 15 Mar 2020 20:07:01 GMT</pubDate>
            <atom:updated>2020-05-22T13:03:25.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ca70r4BQdQAJQp26" /><figcaption>Photo by <a href="https://unsplash.com/@luke_pamer?utm_source=medium&amp;utm_medium=referral">Luke Pamer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/get-started/multi-stage-pipelines-experience?view=azure-devops">multi-stage pipelines</a> feature is relatively new in Azure DevOps, and it is currently in preview mode. This feature allows you to split the deployment process into multiple stages and reuse them across multiple projects. Pipelines are described in yaml format. In this article, I will describe how to configure the deployment of Terraform templates to provision infrastructure in Azure.</p><p>You can read more about my experience with Terraform in the previous article:</p><p><a href="https://medium.com/@viktors.telle/deploy-infrastructure-to-azure-using-terraform-b55cbab13929">Deploy infrastructure to Azure using Terraform</a></p><h4>Problem to solve</h4><p>I had an assignment to configure the deployment of Terraform templates to the three environments: development, staging, and production.</p><p>The task sounds rather simple, but I did not have prior experience with yaml and multi-stage pipelines.</p><p>So my journey began with reading the <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&amp;tabs=schema%2Cparameter-schema">documentation</a> about yaml and after a while, it turned out to be the most popular resource that I have visited during the learning and implementing period.</p><h4>Template structure</h4><p>In the beginning, I created a separate Git repository for storing a deployment template that can be used by other projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*0E9P_973Ld9N8oFVM_XM7A.png" /></figure><p>main.yml is the entry point, which consists of validate<em> </em>and deploy<em> </em>stages.</p><p>Validate stage checks if Terraform configuration is syntactically valid. In turn, the deploy stage performs the actual deployment using deployment jobs.</p><h4>Deployment jobs</h4><p>Let’s talk about the actual code that performs deployment. According to Microsoft recommendations, I chose to use jobs of type of <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&amp;tabs=schema%2Cparameter-schema#deployment-job">deployment job</a>.</p><blockquote>Deployment jobs provide the following benefits:</blockquote><blockquote><strong>Deployment history</strong>: You get end-to-end deployment history across pipelines, down to a specific resource and status of the deployments for auditing.</blockquote><blockquote><strong>Apply deployment strategy</strong>: You define how your application is rolled out.</blockquote><p>I picked the runOnce deployment strategy because it covered my use case with Terraform template deployment and also is the most simple one. Here is the example of a deployment job that employs runOnce strategy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1487b625f0d13911338f0c71cd528ff/href">https://medium.com/media/e1487b625f0d13911338f0c71cd528ff/href</a></iframe><p>As you might notice, the actual deployment steps are defined in a separate template file because they are reused for each environment. Deployment job contains the following steps:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59c8581246b02e0ffb089913c464b0c9/href">https://medium.com/media/59c8581246b02e0ffb089913c464b0c9/href</a></iframe><ul><li>Check out the source code from the repository.</li><li>The <a href="https://marketplace.visualstudio.com/items?itemName=qetza.replacetokens">task to replace variable tokens</a> with real values from the variable group. More about variable groups in the next paragraph.</li><li>Initialize Terraform configuration that involves downloading of <a href="https://www.terraform.io/docs/providers/azurerm/index.html">azurerm</a> provider, and connecting to the central <a href="https://www.terraform.io/docs/backends/types/azurerm.html">backend</a> storage of Terraform state.</li><li>Validate the Terraform template.</li><li>Show the list of changes that will be applied to the infrastructure.</li><li>Apply the changes if there are any.</li></ul><h4>Variable groups</h4><p>You can use variables groups to store common deployment variables. I have utilized them to define variables such as the Azure Storage Account access key, Azure Service Principal client secret, and few more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*F_TznwS2WdpWWRSlhoBVsA.png" /></figure><p>I did not find a better way how to separate variables by environments other than adding environment postfix to the name of the variable group.</p><p>Azure DevOps also provides a way to <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&amp;tabs=yaml#link-secrets-from-an-azure-key-vault">link the variable group with Azure Key Vault</a>. To do it, you need to set up a <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&amp;tabs=yaml#create-a-service-connection">Service Connection</a> to connect to your Azure subscription. I have used the <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&amp;tabs=yaml#sep-azure-resource-manager">Azure Resource Manager (ARM)</a> service connection. In my opinion, it is a more robust way to store secrets because they are stored centrally and can be used in other places too.</p><h4>Putting everything together</h4><p>In the end, I have created the following deployment pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*eFClWdvCWIsOw0hv_BSPVQ.png" /></figure><p>It consists of validate and deploy stages. Deploy stage has three jobs, one for each environment. Deployment jobs are executed based on conditions involving Git repository branch names:</p><ul><li>Deploy to dev is executed when the pipeline is triggered in refs/heads/dev* branch.</li><li>Deploy to stage is executed when the refs/heads/rel* branch is created.</li><li>Deploy to prod is executed when refs/heads/rel* branch is merged into master.</li></ul><h4>Template usage example</h4><p>When you have multiple Git repositories that use a shared template, it is a good idea to store this template in the separate Git repository and reuse it.</p><p>I have added the shared deployment template here:</p><p><a href="https://github.com/viktors-telle/azure-devops-terraform-pipeline-template">viktors-telle/azure-devops-terraform-pipeline-template</a></p><p>Below is the sample yaml file that uses the template defined in the repository above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cdbf9867e3984384830f1a616af430b/href">https://medium.com/media/7cdbf9867e3984384830f1a616af430b/href</a></iframe><p>You can also check the sample here:</p><p><a href="https://github.com/viktors-telle/azure-devops-terraform-pipeline">viktors-telle/azure-devops-terraform-pipeline</a></p><h4>Wrap up</h4><p>I was able to achieve the desired goal to deploy Terraform configuration to multiple environments, but multi-stage pipelines somehow feel incomplete in terms of documentation and there should also be a more convenient way to define variables groups based on different environments. Let’s see if these issues will be resolved in the final release.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=708a54700a85" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/azure-devops-multi-stage-deployments-708a54700a85">Azure DevOps multi-stage deployments</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy your infrastructure to Azure using Terraform]]></title>
            <link>https://medium.com/swlh/deploy-infrastructure-to-azure-using-terraform-b55cbab13929?source=rss-b437a66eaa99------2</link>
            <guid isPermaLink="false">https://medium.com/p/b55cbab13929</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Viktors Telle]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 20:48:34 GMT</pubDate>
            <atom:updated>2022-07-19T11:32:18.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*H9qUYM9o12tBQBB8WeBl4Q.png" /></figure><p>First of all, what is <a href="https://www.terraform.io/">Terraform</a>? It is a great tool to describe your cloud infrastructure in the code (IaC) in a declarative way. The main benefit of using this approach is that you will be able to reproduce your infrastructure easily if something goes wrong. It also enables versioning and control over the changes you will make to the infrastructure. In this article, I am going to describe my own experience with Terraform while building infrastructure in Azure.</p><h4>A great alternative to the ARM template</h4><p>In the past <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/overview">ARM </a>template was the standard way to define infrastructure in Azure. ARM provided a way of describing infrastructure declaratively in JSON format. However, it has its downsides. I will list the most important ones to me:</p><ul><li>Verbose configuration. Don’t get me wrong, it is quite all right to describe the configuration in JSON as long as it does not get too long, but in the case of ARM, it usually means writing a lot of JSON.</li><li>Lack of resource validation before applying the changes to the real infrastructure.</li><li>Steep learning curve.</li></ul><h4>Terraform to the rescue</h4><p>One day colleague of mine suggested trying Terraform as a potential replacement for the ARM templates. We already had quite a few ARM templates defined for existing infrastructure, but it was cumbersome to maintain them. There was a new project about to start and so I decided to give Terraform a shot.</p><p>Terraform configuration is described using HashiCorp Configuration Language (HCL). Here is a simple example of what it looks like to define an Azure Storage Account.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61a16b874adb13722d8706b799af40de/href">https://medium.com/media/61a16b874adb13722d8706b799af40de/href</a></iframe><p>Here is the example of the same Storage Account definition using the ARM template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/879a2f8edc1f45584ab1bf4d5b5df6cf/href">https://medium.com/media/879a2f8edc1f45584ab1bf4d5b5df6cf/href</a></iframe><p>After seeing such a huge difference in the amount of configuration that needs to be written, I decided to continue exploring Terraform.</p><h4>Managing configuration for multiple environments</h4><p>This was the thing that I struggled with the most. How the heck I should organize the configuration to support configuration for different environments?</p><p>After reading quite a few blog posts about possible solutions, I came up with the following structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/137/1*VA6Iqi1QXpgpSLy5s9bmrQ.png" /></figure><p><a href="https://code.visualstudio.com/">VS Code</a> has been my standard code editor already for some time. It is free and works on Windows, Mac, and Linux. I have installed the <a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureterraform">Azure Terraform</a> extension for Terraform syntax support.</p><p>Variables are declared in the variables.tf file and are usually assigned with a default value. Variable values for each environment are defined in the variables.tfvars file in the separate folders (local, dev, stage, prod).</p><p>When using such a structure, you can execute terraform plan command and specify the relative path to variables file:</p><pre>terraform plan -var-file=&quot;environments\local\variables.tfvars&quot;</pre><p>You can examine the project structure in the GitHub repo: <a href="https://github.com/viktors-telle/terraform">https://github.com/viktors-telle/terraform</a></p><h4>Using modules</h4><p>The module is an excellent way to unify multiple resource definitions that are used together. The module sql-server contains definitions of the Azure SQL Server, Azure SQL Server firewall rules, and Azure SQL Elastic Pool.</p><p>All modules are called in the main.tf file. Here is an example of how you call the sql-server module in the main.tf file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98d9b78c3734847e9a89015580d2dfae/href">https://medium.com/media/98d9b78c3734847e9a89015580d2dfae/href</a></iframe><h4>Storing secrets</h4><p>Never store sensitive data in the code repository. Arguably you can store sensitive data for the development environment to ease up the onboarding of the new team members, but only when you use a private repository.</p><p>Luckily, Terraform provides a way of passing such data to the template during the deployment process. In the examples below, the Azure Storage Account access key and Azure AD Service Principal secret are considered sensitive data.</p><p>Example of the terraform init command where Azure Blob Storage is used as remote storage to store Terraform resource state in a <a href="https://www.terraform.io/docs/backends/types/azurerm.html">centralized way</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/644187b1de437f972bf459b22368e0f3/href">https://medium.com/media/644187b1de437f972bf459b22368e0f3/href</a></iframe><p>Below is an example of the terraform plan command where azure_client_secret of Azure AD service principal is used for authentication to the Azure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6dcb105d01ca4590ba5e3aa0f80db2a4/href">https://medium.com/media/6dcb105d01ca4590ba5e3aa0f80db2a4/href</a></iframe><p><a href="https://www.terraform.io/docs/providers/azurerm/guides/service_principal_client_secret.html">Guide on how to create a new service principal in Azure.</a></p><p>${storage_account_access_key} and azure_client_secret values can be passed as the parameters from the Azure Key Vault, for example.</p><h4>Pros and cons</h4><p>Terraform is not perfect, and has some downsides. I have listed some pros and cons that are important to me.</p><p><strong>Pros</strong>:</p><ul><li>Able to store Terraform resource state centrally in Azure Blob Storage, which allows running automatic deployments, e.g., Azure DevOps multi-stage deployments.</li><li>terraform plan is an excellent command to validate your configuration before applying. It helps tremendously.</li><li>Gentle learning curve.</li></ul><p><strong>Cons</strong>:</p><ul><li>Not everything is validated during terraform plan command execution. As an example, I can mention virtual machine scale set extensions. If you make a mistake in extension configuration, you will probably not see the errors during terraform plan command, but rather when applying the configuration using terraform apply command.</li><li>terraform import command is lacking the generation of the actual resource configuration. Currently, it supports only importing existing state into state file which helps a bit, but not too much if you have a large infrastructure.</li><li>Not all resources can be described via Terraform.</li></ul><h4>Final words</h4><p>Currently, I am finalizing the migration of the existing infrastructure described using ARM templates to Terraform. Terraform has proven to be convenient to use on a broader scale. Unfortunately, there is no straightforward way to replace ARM templates with Terraform templates since, at the moment of writing, Azure does not support exporting the existing resources in HCL format. To reduce the manual work of translating ARM JSON to HCL, I have written a tool in C# that performs naive conversion of Terraform state file (created by the terraform import command) to HCL resource configuration.</p><p>In my <a href="https://levelup.gitconnected.com/azure-devops-multi-stage-deployments-708a54700a85">next article</a>, I am going to focus on Terraform configuration deployment automation using Azure DevOps pipelines.</p><h4>Additional resources</h4><p>If you would like to learn more about Terraform variables, I recommend reading this article: <a href="https://spacelift.io/blog/how-to-use-terraform-variables">https://spacelift.io/blog/how-to-use-terraform-variables</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b55cbab13929" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/deploy-infrastructure-to-azure-using-terraform-b55cbab13929">Deploy your infrastructure to Azure using Terraform</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>