<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>arm template best practices &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/tag/arm-template-best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Thu, 05 Nov 2020 16:32:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>arm template best practices &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Validating Azure ARM Template Never Been Easier</title>
		<link>https://mail.sibeeshpassion.com/validating-azure-arm-template-never-been-easier/</link>
					<comments>https://mail.sibeeshpassion.com/validating-azure-arm-template-never-been-easier/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Thu, 05 Nov 2020 16:32:19 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[arm template best practices]]></category>
		<category><![CDATA[arm template test toolkit]]></category>
		<category><![CDATA[arm templates]]></category>
		<category><![CDATA[arm test tool]]></category>
		<category><![CDATA[azure resource manager]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=14226</guid>

					<description><![CDATA[Here in this post, we are going to see how you can validate your ARM template. As you might have already known that the ARM template is a JSON file, how difficult is it to validate a JSON file? Things get ugly when you have many resources to work with, there are chances that you miss some important properties, made some syntax issues, most importantly you might have not followed the best practices. So let's dig in and see how to do this. ]]></description>
										<content:encoded><![CDATA[
<p>When you have many Azure resources to work with, and you are a lazy person who doesn&#8217;t want to create the resources one by one, that is when you should use the ARM templates, it is the Microsoft version of <strong>Infrastructure as a Code</strong>. It has many other advantages too, those are well documented <a rel="noreferrer noopener" href="https://azure.microsoft.com/en-us/overview/what-is-iaas/?WT.mc_id=AZ-MVP-5001828" target="_blank">here</a>. Here in this post, we are going to see how you can validate your ARM template. As you might have already known that the ARM template is a JSON file, how difficult is it to validate a JSON file? Things get ugly when you have many resources to work with, there are chances that you miss some important properties, made some syntax issues, most importantly you might have not followed the best practices. So let&#8217;s dig in and see how to do this. </p>



<h2 class="wp-block-heading">ARM Template Test Toolkit</h2>



<p>The thing about most of the Cloud Providers is they usually provide all the tools that you may have to work with. The case with Microsoft is no different. We have a tool called <a rel="noreferrer noopener" href="https://github.com/Azure/arm-ttk" target="_blank">ARM Template Toolkit </a>and if you ask me, it is so easy to configure it. </p>



<h3 class="wp-block-heading">Test Your ARM Template</h3>



<p>We will be running some commands in PowerShell, and if you don&#8217;t have it in your system, now is the time. Now download the toolkit from <a rel="noreferrer noopener" href="https://aka.ms/arm-ttk-latest" target="_blank">this link</a>.  Open a PowerShell window and go to the downloaded folder and extract the same, once it is done cd into the folder &#8220;arm-ttk&#8221;. Now, this is where we are going to run all of our commands. </p>



<pre class="wp-block-code"><code>Get-ChildItem *.ps1, *.psd1, *.ps1xml, *.psm1 -Recurse | Unblock-File</code></pre>



<p>Once it is done, we can import the required module. </p>



<pre class="wp-block-code"><code>Import-Module .\arm-ttk.psd1</code></pre>



<p>There are high chances that you get an error as in the preceding image. This is because of the PowerShell execution policy. No worries, you can easily change the same. </p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="254" src="/wp-content/uploads/2020/11/arm-test-tool-kit-import-error-1024x254.jpg" alt="" class="wp-image-14227" srcset="/wp-content/uploads/2020/11/arm-test-tool-kit-import-error-1024x254.jpg 1024w, /wp-content/uploads/2020/11/arm-test-tool-kit-import-error-300x74.jpg 300w, /wp-content/uploads/2020/11/arm-test-tool-kit-import-error-768x190.jpg 768w, /wp-content/uploads/2020/11/arm-test-tool-kit-import-error-1536x381.jpg 1536w, /wp-content/uploads/2020/11/arm-test-tool-kit-import-error.jpg 1549w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>arm test tool kit import error</figcaption></figure>



<p>Now we let&#8217;s check what our Execution Policy is, and change it. We already have<a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?WT.mc_id=AZ-MVP-5001828&amp;view=powershell-7" target="_blank"> a post</a> about the Execution Policies and reading it wouldn&#8217;t be a bad idea. For now, just run the command &#8220;Get-ExecutionPolicy&#8221; and &#8220;Get-ExecutionPolicy -List&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="287" src="/wp-content/uploads/2020/11/powershell-execution-policies-1024x287.jpg" alt="" class="wp-image-14228" srcset="/wp-content/uploads/2020/11/powershell-execution-policies-1024x287.jpg 1024w, /wp-content/uploads/2020/11/powershell-execution-policies-300x84.jpg 300w, /wp-content/uploads/2020/11/powershell-execution-policies-768x215.jpg 768w, /wp-content/uploads/2020/11/powershell-execution-policies.jpg 1186w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>PowerShell execution policies</figcaption></figure>



<p>Now is the time to change the policy, I am going to change it to &#8220;ByPass&#8221;, so that nothing is blocked. And once that is done, run the Import command again.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="168" src="/wp-content/uploads/2020/11/change-PowerShell-execution-policy-1024x168.jpg" alt="" class="wp-image-14229" srcset="/wp-content/uploads/2020/11/change-PowerShell-execution-policy-1024x168.jpg 1024w, /wp-content/uploads/2020/11/change-PowerShell-execution-policy-300x49.jpg 300w, /wp-content/uploads/2020/11/change-PowerShell-execution-policy-768x126.jpg 768w, /wp-content/uploads/2020/11/change-PowerShell-execution-policy-1536x253.jpg 1536w, /wp-content/uploads/2020/11/change-PowerShell-execution-policy.jpg 1544w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>change PowerShell execution policy</figcaption></figure>



<p>Runt the preceding command to validate the ARM template. Finally, yay!!!. </p>



<pre class="wp-block-code"><code>Test-AzTemplate -TemplatePath "C:\Source Code\ArmTemplates\arm-create-resources.json"         </code></pre>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="793" src="/wp-content/uploads/2020/11/test-azarm-template-1024x793.jpg" alt="" class="wp-image-14230" srcset="/wp-content/uploads/2020/11/test-azarm-template-1024x793.jpg 1024w, /wp-content/uploads/2020/11/test-azarm-template-300x232.jpg 300w, /wp-content/uploads/2020/11/test-azarm-template-768x595.jpg 768w, /wp-content/uploads/2020/11/test-azarm-template-1536x1190.jpg 1536w, /wp-content/uploads/2020/11/test-azarm-template.jpg 1598w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>test az arm template</figcaption></figure>



<p>As you can see that we get some errors in the red color, and fix them and run it again. Here is how your screen may look like now. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="571" src="/wp-content/uploads/2020/11/arm-teplate-validation-success-1024x571.jpg" alt="" class="wp-image-14231" srcset="/wp-content/uploads/2020/11/arm-teplate-validation-success-1024x571.jpg 1024w, /wp-content/uploads/2020/11/arm-teplate-validation-success-300x167.jpg 300w, /wp-content/uploads/2020/11/arm-teplate-validation-success-768x429.jpg 768w, /wp-content/uploads/2020/11/arm-teplate-validation-success-1536x857.jpg 1536w, /wp-content/uploads/2020/11/arm-teplate-validation-success.jpg 1561w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>arm template validation success</figcaption></figure>



<h3 class="wp-block-heading">ToDo</h3>



<p>There are many other things that you can do with this tool. For example, integrate it with Azure pipeline and customize the tests, etc. You should be able to do those by reading <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit?WT.mc_id=AZ-MVP-5001828" target="_blank">this post</a>, I wish all the very best.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Here in this post, we have seen how to validate our ARM templates, and this is critical especially when your ARM template is complex. Keep this in your mind whenever you work with ARM templates.</p>



<h2 class="wp-block-heading">About the Author</h2>



<p>I am yet another developer who is passionate about writing and video creation. I have written close to 500 blogs on my&nbsp;<a href="https://sibeeshpassion.com/" target="_blank" rel="noreferrer noopener">blog</a>. And I upload videos on my YouTube channels&nbsp;<a href="https://www.youtube.com/njanorumalayali" target="_blank" rel="noreferrer noopener">Njan Oru Malayali</a>&nbsp;and&nbsp;<a href="https://www.youtube.com/SibeeshPassion" target="_blank" rel="noreferrer noopener">Sibeesh Passion</a>. Please feel free to follow me.</p>



<ul class="wp-block-list"><li><a href="https://github.com/SibeeshVenu">GitHub</a></li><li><a href="https://medium.com/@sibeeshvenu">medium</a></li><li><a href="https://twitter.com/sibeeshvenu">Twitter</a></li></ul>



<h2 class="wp-block-heading">Your turn. What do you think?</h2>



<p>Thanks a lot for reading. Did I miss anything that you may think which is needed in this article? Could you find this post useful? Kindly do not forget to share your feedback.</p>



<p>Kindest Regards</p>



<p>Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/validating-azure-arm-template-never-been-easier/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
