<?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>Azure | TekCookie</title>
	<atom:link href="https://tekcookie.com/category/azure/feed/" rel="self" type="application/rss+xml" />
	<link>https://tekcookie.com</link>
	<description>Everything about IT</description>
	<lastBuildDate>Sun, 13 Jun 2021 08:31:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/tekcookie.com/wp-content/uploads/2021/06/cropped-TekCookie-211.png?fit=32%2C17&#038;ssl=1</url>
	<title>Azure | TekCookie</title>
	<link>https://tekcookie.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">174510684</site>	<item>
		<title>Create NSG in Azure using PowerShell</title>
		<link>https://tekcookie.com/create-nsg-in-azure-using-powershell/</link>
					<comments>https://tekcookie.com/create-nsg-in-azure-using-powershell/#respond</comments>
		
		<dc:creator><![CDATA[jeffythampi]]></dc:creator>
		<pubDate>Fri, 14 Aug 2020 13:12:01 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Azure Virtual Network]]></category>
		<category><![CDATA[NSG]]></category>
		<category><![CDATA[Subnet]]></category>
		<category><![CDATA[Virtual Network]]></category>
		<guid isPermaLink="false">https://tekcookie.com/?p=1471</guid>

					<description><![CDATA[This article is about how to create a Network Security Group in Azure Cloud. NSG (a very basic firewall) is a service provided by Azure cloud to manage the traffic flow in Azure virtual network and resources. The traffic management is done by access control lists (ACL). The security rules defines the protocol (TCP, UDP, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>This article is about how to create a Network Security Group in Azure Cloud. NSG (a very basic firewall) is a service provided by Azure cloud to manage the traffic flow in Azure virtual network and resources. <br>The traffic management is done by access control lists (ACL). The security rules defines the protocol (TCP, UDP, ICMP), source, source port, destination, destination port, allow/deny and priority. NSG can be attached to the subnet or virtual machines NIC and the security rules are applied to the whole subnet or the virtual machines accordingly.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/tekcookie.com/wp-content/uploads/2020/08/NSG-1.jpg?w=1080&#038;ssl=1" alt="" class="wp-image-1475"/></figure></div>



<p>NSG is stateful, which means if an incoming port is open and when a connection hits the port, outgoing port is automatically opened to allow the return traffic.</p>



<p>In the previous post, we saw how to create virtual network and subnets in Azure. </p>



<figure class="wp-block-embed is-type-wp-embed is-provider-tekcookie wp-block-embed-tekcookie"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="pLPppd1iib"><a href="https://tekcookie.com/create-virtual-network-in-azure-using-powershell/">Create Virtual Network in Azure using PowerShell</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;Create Virtual Network in Azure using PowerShell&#8221; &#8212; TekCookie" src="https://tekcookie.com/create-virtual-network-in-azure-using-powershell/embed/#?secret=pLPppd1iib" data-secret="pLPppd1iib" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<p><strong>Existing infrastructure diagram (refer the above mentioned article) </strong></p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img data-recalc-dims="1" fetchpriority="high" decoding="async" src="https://i0.wp.com/tekcookie.com/wp-content/uploads/2020/08/Network-basic-vnetsubnetonly.jpg?resize=343%2C210&#038;ssl=1" alt="" class="wp-image-1476" width="343" height="210"/><figcaption>Virtual network and Subnets</figcaption></figure></div>



<p>This article will describe how to create two network security group for the internal and DMZ subnet.</p>



<p>For the subnets, two NSG is required to manage the traffic.</p>



<pre title="#Create NSG in Azure VNet and attach to a Subnet" class="wp-block-code"><code lang="powershell" class="language-powershell line-numbers">
#Connect to azure network
Connect-AzAccount 

#virtual network information
$resource_locaton_main = 'West US'
$resourceGroup_Name = "RG-HOSite"
$vnet_Name = "vnet-ho"

#Fetching information about resource group and virtual network
$rg = Get-AzResourceGroup $resourceGroup_Name
$vnet = Get-AzVirtualNetwork -Name $vnet_Name -ResourceGroupName $rg.ResourceGroupName

#Getting subnet information from the virtual network object
$subnet_INT = $vnet.Subnets[0]
$subnet_DMZ = $vnet.Subnets[1]


#Creating internal network NSG
$nsg_int = New-AzNetworkSecurityGroup -Name "nsg-int" `
-Location $rg.Location `
-ResourceGroupName $rg.ResourceGroupName

#Adding the nsg to VNET INT
Set-AzVirtualNetworkSubnetConfig -NetworkSecurityGroup $nsg_int `
-Name $subnet_INT.Name `
-VirtualNetwork $vnet `
-AddressPrefix $subnet_INT.AddressPrefix | Set-AzVirtualNetwork

#Creating DMZ network NSG
$nsg_dmz = New-AzNetworkSecurityGroup -Name "nsg-dmz" `
-Location $vnet.Location `
-ResourceGroupName $rg.ResourceGroupName

#adding the DMZ NSG to subnet
Set-AzVirtualNetworkSubnetConfig -Name $subnet_DMZ.Name  `
-VirtualNetwork $vnet  `
-NetworkSecurityGroup $nsg_dmz `
-AddressPrefix $subnet_DMZ.AddressPrefix | Set-AzVirtualNetwork</code></pre>



<p>Executing the above script will create two NSG and attach to the internal and DMZ subnet as shown below.</p>



<figure class="wp-block-image size-large is-resized"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/tekcookie.com/wp-content/uploads/2020/08/vnet-subnet-dmz.jpg?resize=368%2C339&#038;ssl=1" alt="" class="wp-image-1477" width="368" height="339"/></figure>



<div style="height:70px" aria-hidden="true" class="wp-block-spacer"></div>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Hope this is informative and thank you for reading.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://tekcookie.com/create-nsg-in-azure-using-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1471</post-id>	</item>
		<item>
		<title>Create Virtual Network in Azure using PowerShell</title>
		<link>https://tekcookie.com/create-virtual-network-in-azure-using-powershell/</link>
					<comments>https://tekcookie.com/create-virtual-network-in-azure-using-powershell/#respond</comments>
		
		<dc:creator><![CDATA[jeffythampi]]></dc:creator>
		<pubDate>Sun, 02 Aug 2020 17:53:18 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Azure Virtual Network]]></category>
		<category><![CDATA[Subnet]]></category>
		<category><![CDATA[Virtual Network]]></category>
		<guid isPermaLink="false">https://tekcookie.com/?p=1399</guid>

					<description><![CDATA[In Azure IaaS, Virtual network is required to enable communications between resources such as VM&#8217;s, load balancers, gateways etc. This article shows how to create a virtual network resource and subnets in Azure. Create Azure Virtual Network and Subnet using PowerShell Create a Virtual network with address prefix 172.17.0.0/16 with 2 subnets. One subnet having [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>In Azure IaaS, Virtual network is required to enable communications between resources such as VM&#8217;s, load balancers, gateways etc.</p>



<p>This article shows how to create a virtual network resource and subnets in Azure.</p>



<h2 class="has-text-align-center wp-block-heading">Create Azure Virtual Network and Subnet using PowerShell</h2>



<div class="wp-block-image"><figure class="aligncenter size-large"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/tekcookie.com/wp-content/uploads/2020/08/Azure-VNET.jpg?w=1080&#038;ssl=1" alt="" class="wp-image-1400"/></figure></div>



<p>Create a Virtual network with address prefix 172.17.0.0/16 with 2 subnets. One subnet having network  172.17.1.0/24 and second network 172.17.10.0/24</p>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Step &#8211; 1: Login to Azure</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">Connect-AzAccount</code></pre>



<p>Executing the above cmdlet brings a browser popup. Enter the azure credential to complete the login.</p>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Step &#8211; 2: Create a Resource Group</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$resource_locaton_main = 'Central US'
$resourceGroup_Name = "RG-MainSite"

#Create new Resource Group
New-AzResourceGroup -Name $resourceGroup_Name -Location $resource_locaton_main</code></pre>



<p>Resource group named &#8220;RG-MainSite will be created in Central US location&#8221;</p>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Step -3: Create virtual network with one subnet(internal subnet). Second subnet(DMZ) will be added after creating the virtual network. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Note: Both the subnets can be created along with virtual network.</p></blockquote>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$vnet_Name = "vnet-main"
$vnet_Prefix = "172.17.0.0/16"
$vsubnet_int = "172.17.1.0/24"

#Create a Vnet and Subnet
$subnetInternal = New-AzVirtualNetworkSubnetConfig -Name "v-subnet-int" `
-AddressPrefix $vsubnet_int

New-AzVirtualNetwork -Name $vnet_Name -AddressPrefix $vnet_Prefix `
-Subnet $subnetInternal -ResourceGroupName RG-MainSite `
-Location $resource_locaton_main</code></pre>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Step &#8211; 4: Add second subnet to virtual network</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">$vsubnet_dmz = "172.17.10.0/24"

#Fetch virtual network details
$vnet = Get-AzVirtualNetwork -Name $vnet_Name

#Add a subnet to existing vnet
Add-AzVirtualNetworkSubnetConfig -Name "v-subnet-dmz" -VirtualNetwork $vnet `
-AddressPrefix $vsubnet_dmz | Set-AzVirtualNetwork</code></pre>



<hr class="wp-block-separator"/>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p><strong>Full Script:</strong></p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell line-numbers">#Connect to Azure
Connect-AzAccount

#Variable Declaration
$vnet_Name = "vnet-main"
$vnet_Prefix = "172.17.0.0/16"
$vsubnet_int = "172.17.1.0/24"
$vsubnet_dmz = "172.17.10.0/24"
$resource_locaton_main = 'Central US'
$resourceGroup_Name = "RG-MainSite"

#Create new Resource Group
New-AzResourceGroup -Name $resourceGroup_Name -Location $resource_locaton_main

#Create a Vnet and Subnet
$subnetInternal = New-AzVirtualNetworkSubnetConfig -Name "v-subnet-int" `
-AddressPrefix $vsubnet_int

New-AzVirtualNetwork -Name $vnet_Name -AddressPrefix $vnet_Prefix `
-Subnet $subnetInternal -ResourceGroupName RG-MainSite `
-Location $resource_locaton_main

#Fetch virtual network details
$vnet = Get-AzVirtualNetwork -Name $vnet_Name

#Add a subnet to existing vnet
Add-AzVirtualNetworkSubnetConfig -Name "v-subnet-dmz" -VirtualNetwork $vnet `
-AddressPrefix $vsubnet_dmz | Set-AzVirtualNetwork
</code></pre>



<p>Executing the above script will create a resource group, virtual network and 2 subnets.</p>



<div style="height:70px" aria-hidden="true" class="wp-block-spacer"></div>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Hope this is informative and thank you for reading the article.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://tekcookie.com/create-virtual-network-in-azure-using-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1399</post-id>	</item>
	</channel>
</rss>
