<?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>IaC Archives - Apostolidis Cloud Corner</title>
	<atom:link href="https://www.cloudcorner.gr/category/microsoft/iac/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.cloudcorner.gr/category/microsoft/iac/</link>
	<description>Remarks from a Cloud Architect encounters</description>
	<lastBuildDate>Wed, 31 Jul 2024 10:23:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://www.cloudcorner.gr/wp-content/uploads/2021/04/cropped-cloudcorner2-32x32.png</url>
	<title>IaC Archives - Apostolidis Cloud Corner</title>
	<link>https://www.cloudcorner.gr/category/microsoft/iac/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Azure Virtual Desktop (AVD) LAB</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-virtual-desktop-avd-lab/</link>
					<comments>https://www.cloudcorner.gr/microsoft/azure/azure-virtual-desktop-avd-lab/#respond</comments>
		
		<dc:creator><![CDATA[Pantelis Apostolidis]]></dc:creator>
		<pubDate>Fri, 19 Apr 2024 11:57:35 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[IaC]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[avd]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[azure cli]]></category>
		<category><![CDATA[azure virtual desktop]]></category>
		<category><![CDATA[azure vm]]></category>
		<category><![CDATA[azurerm]]></category>
		<category><![CDATA[powershell]]></category>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=4091</guid>

					<description><![CDATA[<p>Think of Azure Virtual Desktop, or AVD for short, as your own personal workspace in the cloud. It’s like having</p>
<p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/azure-virtual-desktop-avd-lab/">Azure Virtual Desktop (AVD) LAB</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Think of Azure Virtual Desktop, or AVD for short, as your own personal workspace in the cloud. It’s like having your Windows 11 or Windows 10 desktop, but you can access it from anywhere. You can even choose to use just specific apps with something called RemoteApp. The cool part? You don’t need any gateway servers. It’s flexible enough to handle all sorts of workloads, and you can use your own image or pick one from the Azure Gallery. Just keep in mind, it’s more for businesses rather than individual users. With AVD, you’re setting up an environment that can grow and change with your needs.</p>



<p>If you’re curious and want to dive deeper into how all this works, I highly recommend checking out the&nbsp;<a is="cib-link" href="https://learn.microsoft.com/en-us/azure/architecture/guide/virtual-desktop/start-here" target="_blank" rel="noreferrer noopener">Azure Virtual Desktop architecture page</a>&nbsp;on the Microsoft Architecture Center. It’s a treasure trove of information!&nbsp;Here you can find the <a href="https://learn.microsoft.com/en-us/azure/architecture/example-scenario/azure-virtual-desktop/azure-virtual-desktop">Azure Virtual Desktop for enterprise</a> page including a Visio diagram that you can download and edit.</p>



<h2 class="wp-block-heading">Table of Contents</h2>



<ol>
<li><a rel="noopener" href="#avdlabsetup">AVD Lab Setup</a></li>
<li><a rel="noopener" href="#diagram">High level diagram of the Lab Setup</a></li>
<li><a rel="noopener" href="#labguidedsteps">LAB Guided Steps</a></li>
<li><a rel="noopener" href="#dc">Domain Controller</a></li>
<li><a rel="noopener" href="#upd">User Profile Disks</a></li>
<li><a rel="noopener" href="#dirsync">Create the DirSync server</a></li>
<li><a rel="noopener" href="#adjoinstorage">Join the Storage Account to the Active Directory Domain Services</a></li>
<li><a rel="noopener" href="#updfileshare">Create the File Share for the User Profile Disks</a></li>
<li><a rel="noopener" href="#fslogixgpo">Configure the FSLogix through Group Policy</a></li>
<li><a rel="noopener" href="#createimage">Create the Image</a></li>
<li><a rel="noopener" href="#hostpool">Create the Host Pool</a></li>
<li><a rel="noopener" href="#assignusers">Assign user to the host pool application group</a></li>
<li><a rel="noopener" href="#useraccess">User access</a></li>
<li><a rel="noopener" href="#updateimage">Update Image</a></li>
<li><a rel="noopener" href="#autoscale">Auto scale &#038; Start VM on connect</a></li>
<li><a rel="noopener" href="#scalingplan">Scaling plan</a></li>
<li><a rel="noopener" href="#automation">Session Limits &#038; Stop the VMs automation</a></li>
<li><a rel="noopener" href="#mfa">Authentication &amp; Security</a></li>
<li><a rel="noopener" href="#ux">User experience &amp; Security</a></li>
<li><a rel="noopener" href="#monitor">Monitoring</a></li>
</ol>



<h2 class="wp-block-heading" id="avdlabsetup">AVD Lab Setup</h2>



<p>We will create an Azure Virtual Desktop environment for 50 remote users that will work in a Pooled session host architecture. What that means? Pooled session hosts means that we will deploy a pool of 7 session hosts (Virtual Machines) where users will be load balanced to any session host in the <a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/terminology#host-pools">host pool</a>.</p>



<p>The operating system will be <a href="https://learn.microsoft.com/en-us/mem/intune/fundamentals/azure-virtual-desktop-multi-session">Windows 11 multi-session </a>with Office 365 preinstalled. We will select an Azure marketplace image; we will edit it to do any customizations we need and then we will create a custom image and use it for our AVD deployment. </p>



<p>To store the user profiles we need a persistent storage outside the hosts (virtual machines). We will store the images to an Azure File Share of a Storage Account and we will use the <a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/create-profile-container-azure-ad">FXLogix tool to manage the profile containers</a>.</p>



<h3 class="wp-block-heading" id="diagram">High level diagram of the Lab Setup</h3>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-1.png"><img fetchpriority="high" decoding="async" width="664" height="742" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-1.png" alt="" class="wp-image-4093" style="width:880px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-1.png 664w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-1-268x300.png 268w" sizes="(max-width: 664px) 100vw, 664px" /></a></figure>



<h2 class="wp-block-heading" id="labguidedsteps">LAB Guided Steps</h2>



<p>Create three Resource Groups, one for Identity, one for Networking and one for the AVD, that will include the AVD Resource, the hosts and the private endpoints, and create the corresponding Virtual Networks. The AVD-Resources Virtual Network will have two subnets, one for the Hosts and one for the Private Endpoint. Finaly peer the identity &amp; resources networks with the networking virtual network.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#create resource groups
az group create -n AVD-Identity-RG -l germanywestcentral
az group create -n AVD-Networking-RG -l germanywestcentral
az group create -n AVD-Resources-RG -l germanywestcentral

#create virtual networks
az network vnet create -n AVD-Identity-VNET -g AVD-Identity-RG --address-prefix 10.56.0.0/24 --subnet-name domain --subnet-prefixes 10.56.0.0/24
az network vnet create -n AVD-Networking-VNET -g AVD-Networking-RG --address-prefix 10.56.1.0/24 --subnet-name AzureFirewallSubnet --subnet-prefixes 10.56.1.0/26
az network vnet subnet create -g AVD-Networking-RG --vnet-name AVD-Networking-VNET -n AzureFirewallManagementSubnet --address-prefixes 10.56.1.64/26
az network vnet create -n AVD-Resources-VNET -g AVD-Resources-RG --address-prefix 10.56.2.0/24 --subnet-name hosts --subnet-prefixes 10.56.2.0/26
az network vnet subnet create -g AVD-Resources-RG --vnet-name AVD-Resources-VNET -n privatelink --address-prefixes 10.56.2.64/26

#create vnet peerings
# Get the id for vnet-1.
vNet1Id=$(az network vnet show -g AVD-Networking-RG --name AVD-Networking-VNET --query id --out tsv)
# Get the id for vnet-2.
vNet2Id=$(az network vnet show -g AVD-Identity-RG --name AVD-Identity-VNET --query id --out tsv)
# Get the id for vnet-3.
vNet3Id=$(az network vnet show -g AVD-Resources-RG --name AVD-Resources-VNET --query id --out tsv)
# peer vnet-1 to vnet-2
az network vnet peering create --name networking-to-identity -g AVD-Networking-RG --vnet-name AVD-Networking-VNET --remote-vnet $vNet2Id --allow-vnet-access
# peer vnet-1 to vnet-3
az network vnet peering create --name networking-to-resources -g AVD-Networking-RG --vnet-name AVD-Networking-VNET --remote-vnet $vNet3Id --allow-vnet-access
# peer vnet-2 to vnet-1
az network vnet peering create --name identity-to-networking -g AVD-Identity-RG --vnet-name AVD-Identity-VNET --remote-vnet $vNet1Id --allow-vnet-access --allow-forwarded-traffic
# peer vnet-3 to vnet-1
az network vnet peering create --name resources-to-networking -g AVD-Resources-RG --vnet-name AVD-Resources-VNET --remote-vnet $vNet1Id --allow-vnet-access --allow-forwarded-traffic

# Create an Azure Firewall Basic and add an allow network rule for the LAN
az network public-ip create --name "azfwpip" --resource-group "AVD-Networking-RG" --location "germanywestcentral" --sku "Standard"
az network public-ip create --name "azfwmpip" --resource-group "AVD-Networking-RG" --location "germanywestcentral" --sku "Standard"
az network firewall create -g AVD-Networking-RG -n AVDFirewall --sku AZFW_VNet --tier Basic --vnet-name AVD-Networking-VNET --conf-name avdIpConfig --m-conf-name avdmIpConfig --m-public-ip azfwmpip --public-ip azfwpip
az network firewall network-rule create --collection-name Net-Coll01 --destination-addresses 10.0.0.0/8 --destination-ports '*' --firewall-name AVDFirewall --name Allow-LAN --protocols Any --resource-group AVD-Networking-RG --priority 200 --source-addresses 10.0.0.0/8 --action Allow
az network firewall network-rule create --collection-name Net-Coll01 --destination-addresses '*' --destination-ports '*' --firewall-name AVDFirewall --name Allow-Internet --protocols Tcp --resource-group AVD-Networking-RG --source-addresses 10.0.0.0/8
az network firewall nat-rule create --collection-name Nat-Coll01 --priority 300 --dest-addr '4.185.80.0' --source-addresses '*' --destination-ports '3389' --firewall-name AVDFirewall --name rdptodc --protocols Any --resource-group AVD-Networking-RG --translated-address 10.56.0.4 --translated-port '3389' --action Dnat

# Create a Route Table (for the lab I created one route table to route all traffic to the Azure Firewall.) and associate it to the identity and resources subnets.
az network route-table create --name Firewall-rt-table --resource-group AVD-Networking-RG --location germanywestcentral --disable-bgp-route-propagation true
az network route-table route create --resource-group AVD-Networking-RG --name route-to-firewall --route-table-name Firewall-rt-table --address-prefix 0.0.0.0/0 --next-hop-type VirtualAppliance --next-hop-ip-address 10.56.1.4
RTiD=$(az network route-table show -g AVD-Networking-RG -n Firewall-rt-table --query id --out tsv)
az network vnet subnet update -n hosts -g AVD-Resources-RG --vnet-name AVD-Resources-VNET --route-table $RTiD
az network vnet subnet update -n privatelink -g AVD-Resources-RG --vnet-name AVD-Resources-VNET --route-table $RTiD
az network vnet subnet update -n domain -g AVD-Identity-RG --vnet-name AVD-Identity-VNET --route-table $RTiD

# create NSG (for the lab I will create just and allow lan rule)
az network nsg create -g AVD-Networking-RG -n AVD-NSG
az network nsg rule create -g AVD-Networking-RG --nsg-name AVD-NSG -n AllowLan --priority 100 --source-address-prefixes 10.0.0.0/8 --source-port-ranges '*' --destination-address-prefixes 10.0.0.0/8 --destination-port-ranges '*' --access Allow --protocol '*' --description "allowlan"
az network nsg rule create -g AVD-Networking-RG --nsg-name AVD-NSG -n AllowLanOut --priority 101 --source-address-prefixes 10.0.0.0/8 --source-port-ranges '*' --destination-address-prefixes 10.0.0.0/8 --destination-port-ranges '*' --access Allow --protocol '*' --description "allowlan" --direction Outbound
NSGId=$(az network nsg show -g AVD-Networking-RG --name AVD-NSG --query id --out tsv)
az network vnet subnet update -g AVD-Identity-RG -n domain --vnet-name AVD-Identity-VNET --network-security-group $NSGId
az network vnet subnet update -g AVD-Resources-RG -n hosts --vnet-name AVD-Resources-VNET --network-security-group $NSGId
az network vnet subnet update -g AVD-Resources-RG -n privatelink --vnet-name AVD-Resources-VNET --network-security-group $NSGId</pre>



<h2 class="wp-block-heading" id="dc">Domain Controller </h2>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Create a network interface with private ip address due to DNS requirements
az network nic create --resource-group AVD-Identity-RG --name "DCNic" --vnet-name "AVD-Identity-VNET" --subnet "domain" --private-ip-address "10.56.0.4"
# Create a virtual machine
az vm create --resource-group AVD-Identity-RG --name "DCVM" --image "win2022datacenter" --size "Standard_D2s_v3" --admin-username "azureuser" --admin-password "your-password" --nics "DCNic"</pre>



<p>Login to the VM and promote to Domain Controller &amp; DNS server. In case you have an on-premises Active Directory environment that you want to use, then you will need a hybrid connectivity (ExpressRoute or VPN) and instead of creating a new Domain, you will need to add this server as an additional domain controller. There are plenty of guides to create an Active Directory domain, like this <a href="https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-">Install Active Directory Domain Services (Level 100) | Microsoft Learn</a> . </p>



<p>After the promotion, and once the DNS role is ready, change the DNS settings of all Virtual Networks to the private IP address of the ADDS/DNS server.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Set DNS servers on VNets
az network vnet update --resource-group AVD-Identity-RG --name AVD-Identity-VNET --dns-servers "10.56.0.4"
az network vnet update --resource-group AVD-Networking-RG --name AVD-Networking-VNET --dns-servers "10.56.0.4"
az network vnet update --resource-group AVD-Resources-RG --name AVD-Resources-VNET --dns-servers "10.56.0.4"</pre>



<h2 class="wp-block-heading" id="upd">User Profile Disks</h2>



<p>Create one Storage Account with a Private Endpoint and a Private DNS Zone that is needed to access the Storage Account endpoint. In case of an Enterprise Scale deployment, the Private DNS Zones will be located in a centralized location. The Storage Account name needs to be globally unique.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Create storage account
az storage account create --name avdupd916 -g AVD-Resources-RG -l germanywestcentral --sku 'Standard_LRS' --allow-blob-public-access false --public-network-access Disabled --https-only true

# Get the Storage Account ID
storageAccountId=$(az storage account show -n avdupd916 -g AVD-Resources-RG --query id --output tsv)

# Get the Subnet ID
subnetId=$(az network vnet subnet show -g AVD-Resources-RG -n privatelink --vnet-name AVD-Resources-VNET --query id --out tsv)

# Create the private endpoint
az network private-endpoint create --name avdupd916files --resource-group AVD-Resources-RG --vnet-name AVD-Resources-VNET --subnet $subnetId --private-connection-resource-id $storageAccountId --group-ids file --connection-name avdupd916filesconnection

# Create the private DNS zone
az network private-dns zone create --name 'privatelink.file.core.windows.net' -g AVD-Resources-RG

# Create the private DNS zone group
az network private-endpoint dns-zone-group create --name avddnszonegroup --endpoint-name avdupd916files --private-dns-zone 'privatelink.file.core.windows.net' -g AVD-Resources-RG --zone-name 'privatelink.file.core.windows.net'

#Create a VNET link to the identity VNET
IDVnetId=$(az network vnet show -g AVD-Identity-RG --name AVD-Identity-VNET --query id --out tsv)
az network private-dns link vnet create -g AVD-Resources-RG -n fileslinktoid -z privatelink.file.core.windows.net -v $IDVnetId -e False</pre>



<h4 class="wp-block-heading" id="dirsync">Create the DirSync server</h4>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Create a network interface
az network nic create --resource-group AVD-Identity-RG --name "DSNic" --vnet-name "AVD-Identity-VNET" --subnet "domain"
# Create a virtual machine
az vm create --resource-group AVD-Identity-RG --name "DSVM" --image "win2022datacenter" --size "Standard_D2s_v3" --admin-username "azureuser" --admin-password "your-password" --nics "DSNic"</pre>



<h5 class="wp-block-heading">Sync the AD DS users using DirSync</h5>



<p>Go to the Microsoft Entra Connect / Connect Sync / and download the Microsoft Entra Connect. Install it to the DirSync server and complete the express installation. After this process the AD DS users will be synced to the Entra ID.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-5.png"><img decoding="async" width="781" height="374" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-5.png" alt="" class="wp-image-4105" style="width:543px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-5.png 781w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-5-300x144.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-5-768x368.png 768w" sizes="(max-width: 781px) 100vw, 781px" /></a></figure>



<h4 class="wp-block-heading" id="adjoinstorage">Join the Storage Account to the Active Directory Domain Services</h4>



<p>The Storage Account needs to be joined to the Active Directory Domain Servers in order to support domain user permissions and SSO. The process is described in this article: <a href="https://learn.microsoft.com/en-us/azure/storage/files/storage-files-identity-ad-ds-enable">Enable AD DS authentication for Azure file shares | Microsoft Learn</a></p>



<ul class="wp-block-list">
<li style="line-height:1.5">Login to the DirSync server</li>



<li style="line-height:1.5"> install the latest .Net Framework <a href="https://dotnet.microsoft.com/en-us/download/dotnet-framework">Download .NET Framework | Free official downloads (microsoft.com)</a> </li>



<li style="line-height:1.5">download the <a href="https://github.com/Azure-Samples/azure-files-samples/releases">AzFilesHybrid </a>module. </li>



<li style="line-height:1.5">Run J<a href="https://learn.microsoft.com/en-us/azure/storage/files/storage-files-identity-ad-ds-enable#run-join-azstorageaccount">oin-AzStorageAccount script</a>, changing the required parameters.</li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
# Navigate to where AzFilesHybrid is unzipped and stored and run to copy the files into your path
C:\temp&amp;gt;.\CopyToPSPath.ps1 
# Import AzFilesHybrid module
Import-Module -Name AzFilesHybrid
# Install the Az module and Connect to Azure
Install-Module Az
Connect-AzAccount
# Define parameters
$SubscriptionId = "********-****-****-****-********"
$ResourceGroupName = "AVD-Resources-RG"
$StorageAccountName = "avdupd916"
$SamAccountName = "avdupd916"
$DomainAccountType = "ComputerAccount"
$OuDistinguishedName = "OU=UPD,OU=AVDResources,DC=myavdd,DC=com"
# Select the target subscription for the current session
Select-AzSubscription -SubscriptionId $SubscriptionId 
# Register the target storage account with your active directory environment under the target OU 
Join-AzStorageAccount -ResourceGroupName $ResourceGroupName -StorageAccountName $StorageAccountName -SamAccountName $SamAccountName -DomainAccountType $DomainAccountType -OrganizationalUnitDistinguishedName $OuDistinguishedName</pre>



<p>After this process, a computer object will appear at the specified OU and the Storage Account, at the File Share settings will have the identity-based access as Configured.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-2.png"><img decoding="async" width="540" height="83" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-2.png" alt="" class="wp-image-4100" style="width:384px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-2.png 540w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-2-300x46.png 300w" sizes="(max-width: 540px) 100vw, 540px" /></a></figure>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-3.png"><img loading="lazy" decoding="async" width="236" height="65" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-3.png" alt="" class="wp-image-4102"/></a></figure>



<p>Create two Groups. One for the AVD Admins and one for the AVD Users. In my case is AVDAdmins and AVDUsers. Wait until the users and groups are synced to the Microsoft Entra ID.</p>



<h4 class="wp-block-heading" id="updfileshare">Create the File Share for the User Profile Disks</h4>



<p>Create the File Share and Add the Admins Group to the &#8220;Storage File Data SMB Share Elevated Contributor&#8221; Role of the Storage Account and the Users Group to the &#8220;Storage File Data SMB Share Contributor&#8221; Role.</p>



<ul class="wp-block-list">
<li>&#8220;avdadmins&#8221; the &#8220;Storage File Data SMB Share Elevated Contributor&#8221; role</li>



<li>&#8220;avdusers: the &#8220;Storage File Data SMB Share Contributor&#8221; role</li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># changing to PowerShell cause the Azure Cli caused me some problems. | Create the File Share
New-AzRmStorageShare -ResourceGroupName AVD-Resources-RG -StorageAccountName avdupd916 -Name updhare</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Back to Azure Cli | Provide access to the synced groups to the file share. To add a group you will need the object id of the group.
# avdadmins = ********************-0d5db5b092f8
az role assignment create --role "Storage File Data SMB Share Elevated Contributor" --assignee-object-id ********************-0d5db5b092f8 --assignee-principal-type Group --scope "/subscriptions/********************/resourceGroups/AVD-Resources-RG/providers/Microsoft.Storage/storageAccounts/avdupd916/fileServices/default/fileshares/updshare"
# avdusers = ********************-5e934d6f5c7d
az role assignment create --role "Storage File Data SMB Share Contributor" --assignee-object-id ********************-5e934d6f5c7d --assignee-principal-type Group --scope "/subscriptions/********************/resourceGroups/AVD-Resources-RG/providers/Microsoft.Storage/storageAccounts/avdupd916/fileServices/default/fileshares/updshare"</pre>



<p>Assign NTFS permissions to the share</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bat" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># mount the share to a member server to take a drive letter
net use Z: \\avdupd916.file.core.windows.net\updshare
icacls Z: /remove "Authenticated Users"
icacls Z: /remove "Builtin\Users"    
icacls Z: /remove "Creator Owner"
icacls Z: /grant "avdusers:(M)"
icacls Z: /grant "Creator Owner:(OI)(CI)(IO)(M)"</pre>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-7.png"><img loading="lazy" decoding="async" width="935" height="217" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-7.png" alt="" class="wp-image-4112" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-7.png 935w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-7-300x70.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-7-768x178.png 768w" sizes="auto, (max-width: 935px) 100vw, 935px" /></a></figure>



<h2 class="wp-block-heading" id="fslogixgpo">Configure the FSLogix through Group Policy</h2>



<p>Download the <a href="https://aka.ms/fslogix_download">FSLogix</a> zip and copy the admx and adml files to the correct location based to your setup. <a href="https://learn.microsoft.com/en-us/fslogix/how-to-use-group-policy-templates#local-group-policy-editor">Here for more info</a>. Open the Group Policy Management. Create a new GPO and link it to the AVD Hosts OU. If the admx/adml files are copied correctly you should see the FSLogix settings under Computer Configuration / Policies / Administrative Templates</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-18.png"><img loading="lazy" decoding="async" width="498" height="249" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-18.png" alt="" class="wp-image-4126" style="width:314px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-18.png 498w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-18-300x150.png 300w" sizes="auto, (max-width: 498px) 100vw, 498px" /></a></figure>



<p>Settings to configure:</p>



<p><strong>FSLogix / Profile Containers:</strong> </p>



<ol class="wp-block-list">
<li style="line-height:1.5">Enabled = Enabled</li>



<li style="line-height:1.5">VHD Locations: \avdupd916.file.core.windows.net\updshare</li>



<li style="line-height:1.5">DeleteLocalProfileWhenVHDShouldApply = Enabled</li>



<li style="line-height:1.5">LockedRetryCount = 3</li>



<li style="line-height:1.5">LockedRetryInterval = 5</li>



<li style="line-height:1.5">ProfileType = Normal</li>
</ol>



<p><strong>FSLogix / Profile Containers</strong> / Container and Directory Naming</p>



<ol class="wp-block-list">
<li style="line-height:1.5">VolumeType = VHDX</li>



<li style="line-height:1.5">SIDDirNameMatch = %username%.%userdomain%</li>



<li style="line-height:1.5">SIDDirNamePattern = %username%.%userdomain%</li>



<li style="line-height:1.5">VHDNameMatch = %username%</li>



<li style="line-height:1.5">VHDNamePattern = %username%</li>
</ol>



<h2 class="wp-block-heading" id="createimage">Create the Image</h2>



<p>Create a VM from the marketplace. I chose a Windows 11 multi-sesison image with MS apps.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Create a network interface
az network nic create --resource-group AVD-Resources-RG --name "ImageNic" --vnet-name "AVD-Resources-VNET" --subnet "hosts"
#find the image name
az vm image list --location germanywestcentral --publisher microsoftwindowsdesktop --offer office-365 --all --output table
# Create a virtual machine
az vm create --resource-group AVD-Resources-RG --name "ImageVM" --image "MicrosoftWindowsDesktop:office-365:win11-23h2-avd-m365:22631.3447.240409" --size "Standard_D2s_v3" --admin-username "vmadmin" --admin-password "*********" --nics "ImageNic"</pre>



<p>This image already has Microsoft 365, Teams, Edge, OneDrive in a multi-session installation and the FSLogix app to control the user profile disks.  Install whatever application is needed and do any configuration, like language etc. I will install 7-zip &amp; VLC Player just for the customization.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-8.png"><img loading="lazy" decoding="async" width="443" height="149" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-8.png" alt="" class="wp-image-4115" style="width:360px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-8.png 443w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-8-300x101.png 300w" sizes="auto, (max-width: 443px) 100vw, 443px" /></a></figure>



<p>Take a snapshot of the VM disk before performing sysprep. You will need this snapshot when you need to do any updates and customizations to this image. After the sysprep you will no longer be able to spin an Azure VM. It is recommended to stop/deallocate the VM to take the snapshot. Open the Disk resource and press + Create Snapshot</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-26.png"><img loading="lazy" decoding="async" width="726" height="126" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-26.png" alt="" class="wp-image-4137" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-26.png 726w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-26-300x52.png 300w" sizes="auto, (max-width: 726px) 100vw, 726px" /></a></figure>



<p>Generalize the image with sysprep</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bat" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">C:\Windows\System32\Sysprep\sysprep.exe /oobe /generalize /shutdown</pre>



<p>Capture the VM to create the Image. This is done by the Azure Portal, at the VM Overview blade, press Capture. Since the sysprep makes the OS unusable, select to delete the VM after creating the image. I like using the Azure compute gallery to store the images and versions, so I will select to add the image to a gallery.</p>



<ul class="wp-block-list">
<li>Share image to Azure compute gallery: Yes</li>



<li>Automatically delete this virtual machine after creating the image: Yes</li>



<li>Azure compute gallery: AVDACG</li>



<li>Operating system state: Generalized</li>



<li>Target VM image definition: win11-23H2</li>



<li>Version number: 0.0.1</li>



<li>Source virtual machine: imagevm</li>
</ul>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-9.png"><img loading="lazy" decoding="async" width="842" height="155" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-9.png" alt="" class="wp-image-4117" style="width:636px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-9.png 842w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-9-300x55.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-9-768x141.png 768w" sizes="auto, (max-width: 842px) 100vw, 842px" /></a></figure>



<h2 class="wp-block-heading" id="hostpool">Create the Host Pool</h2>



<p>At the Azure Portal, go to the Azure Virtual Desktop and Create a host pool</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-10.png"><img loading="lazy" decoding="async" width="848" height="224" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-10.png" alt="" class="wp-image-4118" style="width:666px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-10.png 848w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-10-300x79.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-10-768x203.png 768w" sizes="auto, (max-width: 848px) 100vw, 848px" /></a></figure>



<p>Basics: Select the subscription, the Resource Group, the Host Pool Name, location for the metadata, I will create an environment for Desktops, in a Pooled host pool type, so there will be no dedicated VMs per users. </p>



<p>Virtual Machines: Select to add Virtual Machines. Give a prefix up to 12 characters, since AVD will add -## numbering. Select the image from the shared image gallery and how many VMs will be spined in total. At he networking select the network that is prepared for the hosts. For domain join add the UPN of the user (not domain\user, you need user@domain.com), enter the domain name and the OU distinguished name. Finaly add details for the local admin user. </p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-11.png"><img loading="lazy" decoding="async" width="730" height="864" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-11.png" alt="" class="wp-image-4119" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-11.png 730w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-11-253x300.png 253w" sizes="auto, (max-width: 730px) 100vw, 730px" /></a></figure>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-12.png"><img loading="lazy" decoding="async" width="731" height="762" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-12.png" alt="" class="wp-image-4120" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-12.png 731w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-12-288x300.png 288w" sizes="auto, (max-width: 731px) 100vw, 731px" /></a></figure>



<p>Workspace: Register the host pool to a workspace.</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-13.png"><img loading="lazy" decoding="async" width="723" height="146" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-13.png" alt="" class="wp-image-4121" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-13.png 723w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-13-300x61.png 300w" sizes="auto, (max-width: 723px) 100vw, 723px" /></a></figure>



<p>Advanced: Enable the diagnostic settings. You will need to have prepared a log analytics workspace.</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-14.png"><img loading="lazy" decoding="async" width="716" height="405" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-14.png" alt="" class="wp-image-4122" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-14.png 716w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-14-300x170.png 300w" sizes="auto, (max-width: 716px) 100vw, 716px" /></a></figure>



<p>When the process is complete you will see two computer accounts at you active directory</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-15.png"><img loading="lazy" decoding="async" width="602" height="144" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-15.png" alt="" class="wp-image-4123" style="width:472px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-15.png 602w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-15-300x72.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-15-600x144.png 600w" sizes="auto, (max-width: 602px) 100vw, 602px" /></a></figure>



<p>and at the Azure Portal / Azure virtual Desktop / host pool will see the two hosts ready to connect</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-16.png"><img loading="lazy" decoding="async" width="330" height="147" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-16.png" alt="" class="wp-image-4124" style="width:251px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-16.png 330w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-16-300x134.png 300w" sizes="auto, (max-width: 330px) 100vw, 330px" /></a></figure>



<p>Go to Azure Monitor and enable the monitor for the host virtual machines.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-24.png"><img loading="lazy" decoding="async" width="790" height="492" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-24.png" alt="" class="wp-image-4134" style="width:435px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-24.png 790w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-24-300x187.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-24-768x478.png 768w" sizes="auto, (max-width: 790px) 100vw, 790px" /></a></figure>



<h2 class="wp-block-heading" id="assignusers">Assign users access to the Azure Virtual Desktop hosts</h2>



<p>For the users to be able to see the session and connect, they need to be assigned access to the application group of the specific host pool. Go to the Azure Virtual Desktop / Host Pools / YourHostPool / Application Groups / YourApplicationPool Assignments and add the AVD Users group.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-17.png"><img loading="lazy" decoding="async" width="672" height="501" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-17.png" alt="" class="wp-image-4125" style="width:880px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-17.png 672w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-17-300x224.png 300w" sizes="auto, (max-width: 672px) 100vw, 672px" /></a></figure>



<h2 class="wp-block-heading" id="useraccess">User access</h2>



<p>AVD Web Access: <a href="https://aka.ms/avdweb">https://aka.ms/avdweb</a></p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-19.png"><img loading="lazy" decoding="async" width="542" height="372" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-19.png" alt="" class="wp-image-4128" style="width:374px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-19.png 542w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-19-300x206.png 300w" sizes="auto, (max-width: 542px) 100vw, 542px" /></a></figure>



<p>AVS Client for Windows, MacOS, iOS, Android, ChromeOS &amp; Thin Clients: <a href="https://aka.ms/avdclient">https://aka.ms/avdclient</a></p>



<p>after the first login, the folder that stores the User Profile Disk will appear at the Azure File Share</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-22.png"><img loading="lazy" decoding="async" width="677" height="210" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-22.png" alt="" class="wp-image-4131" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-22.png 677w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-22-300x93.png 300w" sizes="auto, (max-width: 677px) 100vw, 677px" /></a></figure>



<p>Disk Management run as administrator, see the attached VHDX User Profile Disk.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-21.png"><img loading="lazy" decoding="async" width="489" height="381" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-21.png" alt="" class="wp-image-4130" style="width:361px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-21.png 489w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-21-300x234.png 300w" sizes="auto, (max-width: 489px) 100vw, 489px" /></a></figure>



<h2 class="wp-block-heading" id="updateimage">Update Image</h2>



<p>There are some options here. If we need to change the OS version, either from Windows 10 to 11, or from a version of 11 to another like 22H2 to 23H3, then create a new VM the marketplace with the target version, customize, capture and add it to the gallery as a new version. If you need to make changes to the existing image, create a VM from the image snapshot, customize and add it to the gallery as a new version. </p>



<p>In my lab I will create a VM from the snapshot just to see the process. Find the disk snapshot at the Azure Portal and press +Create Disk. </p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-27.png"><img loading="lazy" decoding="async" width="455" height="169" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-27.png" alt="" class="wp-image-4138" style="width:347px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-27.png 455w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-27-300x111.png 300w" sizes="auto, (max-width: 455px) 100vw, 455px" /></a></figure>



<p>Open the disk and Create VM</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-28.png"><img loading="lazy" decoding="async" width="387" height="143" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-28.png" alt="" class="wp-image-4139" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-28.png 387w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-28-300x111.png 300w" sizes="auto, (max-width: 387px) 100vw, 387px" /></a></figure>



<p>Once the VM is ready do any customizations and run Sysprep, the same way we run it for the initial image, then Capture the VM and select to add it to the gallery as a new version. I selected the same gallery, the same VM image definition, since it is still win11, and I changed the version number. </p>



<div class="wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-8cf370e7 wp-block-group-is-layout-flex">
<ul class="wp-block-list">
<li style="line-height:1.5">Share image to Azure compute gallery: Yes</li>



<li style="line-height:1.5">Automatically delete this virtual machine after creating the image: Yes</li>



<li style="line-height:1.5">Azure compute gallery: AVDACG</li>



<li style="line-height:1.5">Operating system state: Generalized</li>



<li style="line-height:1.5">Target VM image definition: win11-23H2</li>



<li style="line-height:1.5">Version number:<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-primary-color"> <strong>0.0.2</strong></mark></li>



<li style="line-height:1.5">Source virtual machine: imagevm</li>
</ul>



<p>The process of updating the host pool</p>



<ul class="wp-block-list">
<li>Add new hosts to the host pool, selecting the latest image</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-32.png"><img loading="lazy" decoding="async" width="637" height="244" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-32.png" alt="" class="wp-image-4147" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-32.png 637w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-32-300x115.png 300w" sizes="auto, (max-width: 637px) 100vw, 637px" /></a></figure>
</div>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-31.png"><img loading="lazy" decoding="async" width="726" height="74" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-31.png" alt="" class="wp-image-4146" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-31.png 726w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-31-300x31.png 300w" sizes="auto, (max-width: 726px) 100vw, 726px" /></a></figure>



<p>Once the new hosts are ready &amp; Available at the host pool, select the old hosts and turn n drain mode, in order to stop accepting new sessions. After that point all new sessions will go to the new hosts. Once the old hosts are empty, remove them from the pool and delete the VMs.</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-33.png"><img loading="lazy" decoding="async" width="865" height="166" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-33.png" alt="" class="wp-image-4149" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-33.png 865w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-33-300x58.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-33-768x147.png 768w" sizes="auto, (max-width: 865px) 100vw, 865px" /></a></figure>



<p>After log off / log on:</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-34.png"><img loading="lazy" decoding="async" width="883" height="161" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-34.png" alt="" class="wp-image-4150" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-34.png 883w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-34-300x55.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-34-768x140.png 768w" sizes="auto, (max-width: 883px) 100vw, 883px" /></a></figure>



<h2 class="wp-block-heading" id="autoscale">Auto scale &amp; Start VM on connect</h2>



<p>There are two options to save a lot of money by using auto scale and start VM on connect. With auto scale, you can have one host running 24/7 and the rest stopped. Once the host reach the max session limit, the AVD will start the next host, until it reaches the maximum hosts created for this host pool. Combining the auto scale with the start VM on connect, even the first host can be stopped, and it will start when the first user will try to logon. With a Scaling Plan, you can have the hosts start and stop based to a schedule, like weekdays and working hours. </p>



<h3 class="wp-block-heading">Some requirements</h3>



<p>You must have a configured Max Session Limit parameter for that host pool &amp; enable the Start VM On connect (if you need this feature too). Those options are at the Host Pool Properties.</p>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-35.png"><img loading="lazy" decoding="async" width="769" height="523" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-35.png" alt="" class="wp-image-4151" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-35.png 769w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-35-300x204.png 300w" sizes="auto, (max-width: 769px) 100vw, 769px" /></a></figure>



<p>you must assign the Desktop Virtualization Power On Off Contributor RBAC role to the Azure Virtual Desktop service principal l with your Azure subscription as the assignable scope. Go to the Subscription / Access Control (AIM, Add role assignment, select Role: &#8220;Desktop Virtualization Power On Off Contributor&#8221;, select member the service principal &#8220;Azure Virtual Desktop&#8221; and assign.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-36.png"><img loading="lazy" decoding="async" width="748" height="204" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-36.png" alt="" class="wp-image-4152" style="width:528px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-36.png 748w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-36-300x82.png 300w" sizes="auto, (max-width: 748px) 100vw, 748px" /></a></figure>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-39.png"><img loading="lazy" decoding="async" width="885" height="340" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-39.png" alt="" class="wp-image-4155" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-39.png 885w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-39-300x115.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-39-768x295.png 768w" sizes="auto, (max-width: 885px) 100vw, 885px" /></a></figure>



<p>At this point, you can stop/deallocate the VMs from the Azure portal and then try to access the SessionDesktop with one user. The user will see a message stating that the VM is starting, and it may take up to 5 minutes and at the host pool you will see the first VM starting. For the LAB, I configured the max sessions to 1, so once I try to login with the second user, I will see the same message and it will start the second VM. If you need at least one VM to stay running, you can add a resource lock and make is read-only so the automation will not be able to deallocate it.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-40.png"><img loading="lazy" decoding="async" width="423" height="126" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-40.png" alt="" class="wp-image-4157" style="width:359px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-40.png 423w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-40-300x89.png 300w" sizes="auto, (max-width: 423px) 100vw, 423px" /></a></figure>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-41.png"><img loading="lazy" decoding="async" width="550" height="114" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-41.png" alt="" class="wp-image-4158" style="width:454px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-41.png 550w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-41-300x62.png 300w" sizes="auto, (max-width: 550px) 100vw, 550px" /></a></figure>



<h4 class="wp-block-heading" id="scalingplan">Scaling plan</h4>



<p>Create a Scaling plan. Go to the Azure Virtual Desktop, under Manage select Scaling plans and Create a scaling plan. At the scaling plan you select a General configuration, like weekdays, select a presentence of the host to ramp-up a specific hour, to spin the VMs to be ready for your users in order to don&#8217;t wait 5 minutes for the VM to start on connect, select the peak hours, where most of your users are working, then select the Ramp-down, where a percentage of the hosts will stop. Here you can select if you will force log off the users or it will wait for the last user to log off. <a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/autoscale-create-assign-scaling-plan">You can learn more here</a>.</p>



<p>Once the scaling plan is created, select Next: Host pool assignments and assign the Schedule to one or more host pools. </p>



<h4 class="wp-block-heading" id="automation">Session Limits &amp; Stop the VMs automation</h4>



<p>One thing that is recommended is to configure the Session limits for the Remote Desktop Session Hosts. You can use the same GPO as the FSLogix settings, as it is computer configuration too. Open the GPO and go to Computer Configuration &gt; Administrative Templates &gt; Windows Components &gt; Remote Desktop Services &gt; Remote Desktop Session Host &gt; Session Time Limits. </p>



<p>Set time limit for disconnected sessions: End a disconnected session = 30 minutes. Keep in mind that setting this after 30 minutes the disconnected session will be logged off.</p>



<p>If you want to trigger the Hosts to Stop/Deallocate once there are no active sessions, you can leverage Azure Automation account. There are plenty of guides like this: <a href="https://learn.microsoft.com/en-us/answers/questions/1180844/how-to-automate-avd-vm-shutdown-based-on-usage-and">How to automate AVD VM shutdown based on usage and disconnected state? &#8211; Microsoft Q&amp;A</a></p>



<p>The specific guide creates a runbook that runs a PowerShell script that queries the hosts for active sessions. If a host has no active sessions, then it stops the VM. First create a managed identity and assign the &#8220;Desktop Virtualization On Off Contributor&#8221; Azure role at the Hosts Resource Group. I altered it to check all the Session Hosts in a Host Pool:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#Please enable appropriate RBAC permissions to the system identity of this automation account. Otherwise, the runbook may fail

# Authenticate to Azure with user assigned managed identity
try
{
    "Logging in to Azure..."
    Connect-AzAccount -Identity
}
catch {
    Write-Error -Message $_.Exception
    throw $_.Exception
}

# Set the Azure subscription ID, resource group name, and VM name
$subscriptionId = "*************-360a051fbe3d"
$hostPoolName = "AVDPooledHP"
$resourceGroupName = "avd-resources-rg"
$myADDSDomain = ".myavdd.com"

$sessionhosts = Get-AzWvdSessionHost -ResourceGroupName $resourceGroupName -HostPoolName $hostPoolName
foreach ($sessionhost in $sessionhosts) {
$splitText = $sessionhost.name.Split("/")
$hostName = $splitText[1]
$vmName = $hostName.Replace($myADDSDomain, "")
# Get the connected user count
$connectedUserCount = Get-AzWvdSessionHost -ResourceGroupName $resourceGroupName -HostPoolName $hostPoolName -Name $hostName | Select-Object -ExpandProperty Session
# Check if the conditions are met and deallocate the VM
if ($connectedUserCount -eq 0 ) {Stop-AzVM -ResourceGroupName $resourceGroupName -Name $vmName -Force}
}</pre>



<h2 class="wp-block-heading" id="mfa">Authentication &amp; security</h2>



<p>Microsoft Entra ID provides some security features that can help secure the access to the Azure Virtual Desktop. One of those features is the Conditional Access Policies. Conditional Access Policies are essentially if-then statements used to enforce organizational security policies. They bring together various signals (like user or group membership, IP location, device information, etc.) to make access decisions. For example, if a user wants to access a resource, they might be required to complete an action like multifactor authentication. </p>



<p>Add a Policy to require MFA to access Azure Virtual Desktop</p>



<ol class="wp-block-list">
<li>From the Azure Portal go to Microsoft Entra ID / Security / Conditional Access / Create new policy</li>



<li>Users: Select the group that includes the avd users. Mine is &#8220;avdusers&#8221; group.</li>



<li>Target resources: Include / Select apps / Select / Azure Virtual Desktop</li>
</ol>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-43.png"><img loading="lazy" decoding="async" width="632" height="391" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-43.png" alt="" class="wp-image-4181" style="width:509px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-43.png 632w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-43-300x186.png 300w" sizes="auto, (max-width: 632px) 100vw, 632px" /></a></figure>



<ul class="wp-block-list">
<li>4. Conditions: Client Apps / select Browser and Mobile apps and desktop clients</li>
</ul>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-44.png"><img loading="lazy" decoding="async" width="880" height="373" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-44.png" alt="" class="wp-image-4182" style="width:742px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-44.png 880w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-44-300x127.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-44-768x326.png 768w" sizes="auto, (max-width: 880px) 100vw, 880px" /></a></figure>



<p>5. Access Controls: Grand / Grand access / Require multi factor authentication</p>



<p>6. Session: It is not required but you can select the frequency that the user will be required to re-authenticate. You can select a periodic authentication and select some hours or some days or you can select every time.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-45.png"><img loading="lazy" decoding="async" width="922" height="297" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-45.png" alt="" class="wp-image-4183" style="width:752px;height:auto" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-45.png 922w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-45-300x97.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-45-768x247.png 768w" sizes="auto, (max-width: 922px) 100vw, 922px" /></a></figure>



<p>Find out more here: <a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/set-up-mfa?tabs=avd">Enforce Microsoft Entra multifactor authentication for Azure Virtual Desktop using Conditional Access &#8211; Azure | Microsoft Learn</a></p>



<h2 class="wp-block-heading" id="ux">User experience &amp; Security</h2>



<p style="line-height:1.5">Many settings can be set directly from the Host Pool RDP Properties, like Device Redirection, Display Settings and Session behavior. Some other security settings, like Screen capture protection and Watermarking must be set by the GPO or Intune, by using the <a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/administrative-template?tabs=group-policy-domain">AVD Administrative Template</a>. Once you install the templates the policy settings will be available under Azure Virtual Desktop administrative template is available, browse to Computer Configuration &gt; Policies &gt; Administrative Templates &gt; Windows Components &gt; Remote Desktop Services &gt; Remote Desktop Session Host &gt; Azure Virtual Desktop.</p>



<ul style="line-height:1.5" class="wp-block-list">
<li style="line-height:1.5"><a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/screen-capture-protection">Screen capture protection in Azure Virtual Desktop &#8211; Azure | Microsoft Learn</a></li>



<li style="line-height:1.5"><a href="https://learn.microsoft.com/en-us/azure/virtual-desktop/watermarking">Watermarking in Azure Virtual Desktop | Microsoft Learn</a></li>
</ul>



<p>In addition, the Hosts can be hardened by using GPO or/and <a href="https://learn.microsoft.com/en-us/mem/intune/fundamentals/azure-virtual-desktop">Intune</a>. </p>



<h2 class="wp-block-heading" id="monitor">Monitoring</h2>



<p>Azure Virtual Desktop Insights have plenty of information about Connection Reliability, Diagnostics, Performance, Users, Utilization, Clients and alerts out-of-the-box. You can customize the Insights dashboards and you can create a Workbook that fit your needs.</p>



<figure class="wp-block-image size-large"><a href="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42.png"><img loading="lazy" decoding="async" width="1024" height="475" src="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42-1024x475.png" alt="" class="wp-image-4161" srcset="https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42-1024x475.png 1024w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42-300x139.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42-768x356.png 768w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42-1320x612.png 1320w, https://www.cloudcorner.gr/wp-content/uploads/2024/04/image-42.png 1358w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img loading="lazy" decoding="async" src="https://www.e-apostolidis.gr/wp-content/uploads/2019/05/mvpsummit2019.jpg" width="100"  height="100" alt="Pantelis Apostolidis" itemprop="image"></div><div class="saboxplugin-authorname"><a href="https://www.cloudcorner.gr/author/admin/" class="vcard author" rel="author"><span class="fn">Pantelis Apostolidis</span></a></div><div class="saboxplugin-desc"><div itemprop="description"><p>Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.</p>
</div></div><div class="saboxplugin-web "><a href="https://www.cloudcorner.gr" target="_self" >www.cloudcorner.gr</a></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Facebook" target="_blank" href="https://www.facebook.com/pantelis.apostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_blank" href="https://www.linkedin.com/in/papostolidis/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Instagram" target="_blank" href="https://www.instagram.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Rss" target="_blank" href="https://wwwcloudcorner.gr/feed/rdf/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-rss" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041 64.04 28.673 64.04 64.041zm175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018 111.832 7.284 201.473 96.702 208.772 208.772.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79zm144.249.288C439.596 229.677 251.465 40.445 16.503 32.01 7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999 191.179 7.839 344.627 161.316 352.465 352.465.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504z"></path></svg></span></a><a title="Twitter" target="_blank" href="https://twitter.com/papostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Github" target="_blank" href="https://github.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-github" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></span></a><a title="User email" target="_self" href="mailto:pr&#111;xi&#109;agr&#064;&#104;ot&#109;a&#105;&#108;.&#099;&#111;&#109;" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-user_email" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"></path></svg></span></a></div></div></div><p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fazure-virtual-desktop-avd-lab%2F&amp;linkname=Azure%20Virtual%20Desktop%20%28AVD%29%20LAB" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_print" href="https://www.addtoany.com/add_to/print?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fazure-virtual-desktop-avd-lab%2F&amp;linkname=Azure%20Virtual%20Desktop%20%28AVD%29%20LAB" title="Print" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fazure-virtual-desktop-avd-lab%2F&#038;title=Azure%20Virtual%20Desktop%20%28AVD%29%20LAB" data-a2a-url="https://www.cloudcorner.gr/microsoft/azure/azure-virtual-desktop-avd-lab/" data-a2a-title="Azure Virtual Desktop (AVD) LAB"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" alt="Share"></a></p><p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/azure-virtual-desktop-avd-lab/">Azure Virtual Desktop (AVD) LAB</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cloudcorner.gr/microsoft/azure/azure-virtual-desktop-avd-lab/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Bicep: Azure Virtual WAN Playground</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/bicep-azure-virtual-wan-playground/</link>
					<comments>https://www.cloudcorner.gr/microsoft/azure/bicep-azure-virtual-wan-playground/#respond</comments>
		
		<dc:creator><![CDATA[Pantelis Apostolidis]]></dc:creator>
		<pubDate>Fri, 13 Oct 2023 09:24:26 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[IaC]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[azure firewall]]></category>
		<category><![CDATA[azure vm]]></category>
		<category><![CDATA[azurerm]]></category>
		<category><![CDATA[bicep]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[iac]]></category>
		<category><![CDATA[virtual wan]]></category>
		<category><![CDATA[vwan]]></category>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=4064</guid>

					<description><![CDATA[<p>Azure Virtual WAN is a networking service that brings many networking, security, and routing functionalities together to provide a single</p>
<p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/bicep-azure-virtual-wan-playground/">Bicep: Azure Virtual WAN Playground</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><a href="https://learn.microsoft.com/en-us/azure/virtual-wan/virtual-wan-about">Azure Virtual WAN</a> is a networking service that brings many networking, security, and routing functionalities together to provide a single operational interface. A virtual hub is a Microsoft-managed virtual network that enables connectivity from other resources. When a virtual hub is created from a Virtual WAN in the Azure portal, a virtual hub VNet and gateways (optional) are created as its components.</p>



<p>Recently I created a Bicep code to create an <strong>Azure Virtual WAN with 2 Hubs, Azure Firewalls, and spoke VNETs &amp; VMs</strong>, to use it for PoCs, Labs, and Tests. You can find it at my repo: <a href="https://github.com/proximagr/VWAN"><strong>https://github.com/proximagr/VWAN</strong></a></p>



<p><strong>The script deploys</strong>:</p>



<ul class="wp-block-list">
<li>One Log Analytics workspace</li>



<li>Four VETS, two on each Azure Region.</li>



<li>one VWAN with two VWAN HUBs, each on a different Azure Region.</li>



<li>Two Azure Firewalls inside the VWAN Hubs, each on a different Azure Region. The Azure Firewalls have diagnostic settings sending all logs to a log analytics workspace.</li>



<li>Two Azure Firewalls outside the VWAN Hubs, each on a different Azure Region. The Azure Firewalls have diagnostic settings sending all logs to a log analytics workspace.</li>



<li>Four VMs, Ubuntu, one in each VNET</li>
</ul>



<p><strong>You can choose to</strong>:</p>



<ul class="wp-block-list">
<li>deploy VWAN or not</li>



<li>deploy Azure Firewall inside the VWAN Hubs</li>



<li>deploy VMs or not</li>



<li>deploy Azure Firewall outside the VWAN Hubs or not</li>



<li>how many Public IPs will be created and attached to the Azure Firewalls</li>



<li>The Azure Firewall SKU between Basic and Standard</li>
</ul>



<p><strong>The script does NOT deploy the connections</strong>&nbsp;between the VWAN Hubs &amp; the VNETS. Once the VWAN Hubs are ready, with Hub Status &#8220;Succeeded&#8221;&nbsp;<strong>and</strong>&nbsp;Router Status &#8220;Provisioned&#8221;, create the connections manually. This is because to create a connection the VWAN Hub Router Status must be &#8220;Provisioned&#8221; and currently, the is no way of getting this Status.</p>



<p>The VMs are for testing &amp; troubleshooting. Ubuntu Linux, without Public IP. I usually use the Serial console.</p>



<h2 class="wp-block-heading" id="user-content-deployment-commands-for-azure-cli">Deployment Commands for Azure Cli:</h2>



<p><strong>create the Resource Group</strong>&nbsp;az group create &#8211;name ResourceGroupName &#8211;location PreferedLocation</p>



<p><strong>deploy the bicep script and answer the questions interactively</strong>&nbsp;az deployment group create &#8211;resource-group ResourceGroupName &#8211;template-file main.bicep</p>



<p><strong>deploy the bicep script with the required parameters and choose true false</strong>&nbsp;az deployment group create &#8211;resource-group ResourceGroupName &#8211;template-file main.bicep &#8211;parameters numberOfFirewallPublicIPAddresses=1 adminPassword=&#8217;#########&#8217; adminUserName=&#8217;######&#8217; deployVWAN=true addFirewallToVWAN=true deployFirewall=true deployFirewallBasic=true deployVMs=true</p>



<h2 class="wp-block-heading">Deployment Diagram</h2>



<figure class="wp-block-image size-large"><a href="https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white.png"><img loading="lazy" decoding="async" width="702" height="1024" src="https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white-702x1024.png" alt="" class="wp-image-4065" srcset="https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white-702x1024.png 702w, https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white-206x300.png 206w, https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white-768x1120.png 768w, https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white-1053x1536.png 1053w, https://www.cloudcorner.gr/wp-content/uploads/2023/10/vwan-white.png 1254w" sizes="auto, (max-width: 702px) 100vw, 702px" /></a></figure>



<h2 class="wp-block-heading">VWAN Lab: <a href="https://github.com/proximagr/VWAN">https://github.com/proximagr/VWAN</a></h2>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img loading="lazy" decoding="async" src="https://www.e-apostolidis.gr/wp-content/uploads/2019/05/mvpsummit2019.jpg" width="100"  height="100" alt="Pantelis Apostolidis" itemprop="image"></div><div class="saboxplugin-authorname"><a href="https://www.cloudcorner.gr/author/admin/" class="vcard author" rel="author"><span class="fn">Pantelis Apostolidis</span></a></div><div class="saboxplugin-desc"><div itemprop="description"><p>Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.</p>
</div></div><div class="saboxplugin-web "><a href="https://www.cloudcorner.gr" target="_self" >www.cloudcorner.gr</a></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Facebook" target="_blank" href="https://www.facebook.com/pantelis.apostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_blank" href="https://www.linkedin.com/in/papostolidis/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Instagram" target="_blank" href="https://www.instagram.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Rss" target="_blank" href="https://wwwcloudcorner.gr/feed/rdf/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-rss" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041 64.04 28.673 64.04 64.041zm175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018 111.832 7.284 201.473 96.702 208.772 208.772.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79zm144.249.288C439.596 229.677 251.465 40.445 16.503 32.01 7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999 191.179 7.839 344.627 161.316 352.465 352.465.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504z"></path></svg></span></a><a title="Twitter" target="_blank" href="https://twitter.com/papostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Github" target="_blank" href="https://github.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-github" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></span></a><a title="User email" target="_self" href="mailto:&#112;&#114;o&#120;i&#109;&#097;g&#114;&#064;&#104;&#111;&#116;m&#097;il.&#099;om" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-user_email" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"></path></svg></span></a></div></div></div><p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fbicep-azure-virtual-wan-playground%2F&amp;linkname=Bicep%3A%20Azure%20Virtual%20WAN%20Playground" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_print" href="https://www.addtoany.com/add_to/print?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fbicep-azure-virtual-wan-playground%2F&amp;linkname=Bicep%3A%20Azure%20Virtual%20WAN%20Playground" title="Print" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fbicep-azure-virtual-wan-playground%2F&#038;title=Bicep%3A%20Azure%20Virtual%20WAN%20Playground" data-a2a-url="https://www.cloudcorner.gr/microsoft/azure/bicep-azure-virtual-wan-playground/" data-a2a-title="Bicep: Azure Virtual WAN Playground"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" alt="Share"></a></p><p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/bicep-azure-virtual-wan-playground/">Bicep: Azure Virtual WAN Playground</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cloudcorner.gr/microsoft/azure/bicep-azure-virtual-wan-playground/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Azure Policy to enable network policies for private endpoints</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-policy-to-enable-network-policies-for-private-endpoints/</link>
					<comments>https://www.cloudcorner.gr/microsoft/azure/azure-policy-to-enable-network-policies-for-private-endpoints/#respond</comments>
		
		<dc:creator><![CDATA[Pantelis Apostolidis]]></dc:creator>
		<pubDate>Thu, 23 Feb 2023 07:57:49 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[IaC]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[azure policy]]></category>
		<category><![CDATA[azurerm]]></category>
		<category><![CDATA[compliance]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=4003</guid>

					<description><![CDATA[<p>Network security policies are a very handy feature when you use Private Endpoints on Azure. If you enable network security</p>
<p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/azure-policy-to-enable-network-policies-for-private-endpoints/">Azure Policy to enable network policies for private endpoints</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Network security policies are a very handy feature when you use Private Endpoints on Azure. If you enable network security policies for User-Defined Routes, the /32 routes that are generated by the private endpoint and propagated to all the subnets in its own VNet and directly peered VNets will be invalidated if you have User-Defined Routing, which is useful if you want all traffic (including traffic addressed to the private endpoint) to go through a firewall, since otherwise, the /32 route would bypass any other route.</p>



<p>By default, network policies are disabled for a subnet in a virtual network and you need to enable it manually, from the Azure Portal after the VNET creation, or you need to specify it in your script if you are deploying with PowerShell, Cli, Bicep or any other IaC. </p>



<p>To ensure that Network security policies are enabled, and force enable it, we can use an Azure Policy. The below Azure Policy checks if the Network security policies are enabled, and if not it automatically enables it. The result of this policy is:</p>



<ul class="wp-block-list">
<li>for new Virtual Networks, it automatically enables Network security policies to all subnets, even if you forgot to select it upon the creation</li>



<li>for existing virtual Network subnets, it uses a remediation plan to evaluate and enable the Network security policies.</li>
</ul>



<p>The Policy:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
  "mode": "All",
  "policyRule": {
    "if": {
      "field": "Microsoft.Network/virtualNetworks/subnets[*].privateEndpointNetworkPolicies",
      "notEquals": "Enabled"
    },
    "then": {
      "effect": "modify",
      "details": {
        "roleDefinitionIds": [
          "/providers/Microsoft.Authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7"
        ],
        "operations": [
          {
            "operation": "addOrReplace",
            "field": "Microsoft.Network/virtualNetworks/subnets[*].privateEndpointNetworkPolicies",
            "value": "Enabled"
          }
        ]
      }
    }
  },
  "parameters": {}
}</pre>



<p>To add the Policy to your Azure environment:</p>



<ul class="wp-block-list">
<li>Go to the Azure Policy Definitions blade (shortcut: <a href="https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyMenuBlade/~/Definitions">Policy &#8211; Microsoft Azure</a> )</li>



<li>Add Policy Definition </li>
</ul>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image.png"><img loading="lazy" decoding="async" width="138" height="37" src="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image.png" alt="" class="wp-image-4004"/></a></figure>



<ul class="wp-block-list">
<li>Provide a location (subscription) to save the policy object, and give a name and a category. Use the existing Network category.</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-1.png"><img loading="lazy" decoding="async" width="787" height="513" src="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-1.png" alt="" class="wp-image-4005" srcset="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-1.png 787w, https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-1-300x196.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-1-768x501.png 768w" sizes="auto, (max-width: 787px) 100vw, 787px" /></a></figure>



<ul class="wp-block-list">
<li>Paste the policy Json</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-2.png"><img loading="lazy" decoding="async" width="790" height="590" src="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-2.png" alt="" class="wp-image-4006" srcset="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-2.png 790w, https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-2-300x224.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-2-768x574.png 768w" sizes="auto, (max-width: 790px) 100vw, 790px" /></a></figure>



<ul class="wp-block-list">
<li>Select a Role Assignment. You need a role that will have editor access to the subnet. For my demo, I used the Network Contributor build-in role (4d97b98b-1d4f-4787-a291-c67834d212e7) for the action.</li>



<li>Once the Policy is created, open it and you need to assign it to a scope (MG, Subscription, Resource Group)</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-3.png"><img loading="lazy" decoding="async" width="84" height="30" src="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-3.png" alt="" class="wp-image-4007"/></a></figure>



<ul class="wp-block-list">
<li>Assign the policy to the scope you want, like Management Group, Subscription, or Resource Group and one thing that needs attention is to create a remediation task and a Managed Identity.</li>



<li>The remediation task is needed to remediate the existing resources and the Managed Identity for the modification action.</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-5.png"><img loading="lazy" decoding="async" width="767" height="554" src="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-5.png" alt="" class="wp-image-4009" srcset="https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-5.png 767w, https://www.cloudcorner.gr/wp-content/uploads/2023/02/image-5-300x217.png 300w" sizes="auto, (max-width: 767px) 100vw, 767px" /></a></figure>



<p>The Policy is in Audit only mode, in case you just need to audit if there are any subnets that don&#8217;t have privateEndpointNetworkPolicies enabled.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Network/virtualNetworks/subnets"
        },
        {
          "field": "Microsoft.Network/virtualNetworks/subnets[*].privateEndpointNetworkPolicies",
          "notEquals": "Enabled"
        }
      ]
    },
    "then": {
      "effect": "audit"
    }
  },
  "parameters": {}
}</pre>



<p>You can get the Policy Json files at my Github repo: <a href="https://github.com/proximagr/automation#policy-audit---enable-network-policy-for-private-endpoints-blog-post">https://github.com/proximagr/automation#policy-audit&#8212;enable-network-policy-for-private-endpoints-blog-post</a></p>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img loading="lazy" decoding="async" src="https://www.e-apostolidis.gr/wp-content/uploads/2019/05/mvpsummit2019.jpg" width="100"  height="100" alt="Pantelis Apostolidis" itemprop="image"></div><div class="saboxplugin-authorname"><a href="https://www.cloudcorner.gr/author/admin/" class="vcard author" rel="author"><span class="fn">Pantelis Apostolidis</span></a></div><div class="saboxplugin-desc"><div itemprop="description"><p>Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.</p>
</div></div><div class="saboxplugin-web "><a href="https://www.cloudcorner.gr" target="_self" >www.cloudcorner.gr</a></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Facebook" target="_blank" href="https://www.facebook.com/pantelis.apostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_blank" href="https://www.linkedin.com/in/papostolidis/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Instagram" target="_blank" href="https://www.instagram.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Rss" target="_blank" href="https://wwwcloudcorner.gr/feed/rdf/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-rss" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041 64.04 28.673 64.04 64.041zm175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018 111.832 7.284 201.473 96.702 208.772 208.772.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79zm144.249.288C439.596 229.677 251.465 40.445 16.503 32.01 7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999 191.179 7.839 344.627 161.316 352.465 352.465.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504z"></path></svg></span></a><a title="Twitter" target="_blank" href="https://twitter.com/papostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Github" target="_blank" href="https://github.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-github" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></span></a><a title="User email" target="_self" href="mailto:&#112;&#114;o&#120;&#105;ma&#103;&#114;&#064;&#104;o&#116;&#109;&#097;i&#108;.&#099;&#111;&#109;" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-user_email" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"></path></svg></span></a></div></div></div><p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fazure-policy-to-enable-network-policies-for-private-endpoints%2F&amp;linkname=Azure%20Policy%20to%20enable%20network%20policies%20for%20private%20endpoints" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_print" href="https://www.addtoany.com/add_to/print?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fazure-policy-to-enable-network-policies-for-private-endpoints%2F&amp;linkname=Azure%20Policy%20to%20enable%20network%20policies%20for%20private%20endpoints" title="Print" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fazure-policy-to-enable-network-policies-for-private-endpoints%2F&#038;title=Azure%20Policy%20to%20enable%20network%20policies%20for%20private%20endpoints" data-a2a-url="https://www.cloudcorner.gr/microsoft/azure/azure-policy-to-enable-network-policies-for-private-endpoints/" data-a2a-title="Azure Policy to enable network policies for private endpoints"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" alt="Share"></a></p><p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/azure-policy-to-enable-network-policies-for-private-endpoints/">Azure Policy to enable network policies for private endpoints</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cloudcorner.gr/microsoft/azure/azure-policy-to-enable-network-policies-for-private-endpoints/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Infrastructure as Code &#124; Deploy a VNET &#038; NSG &#038; UDR</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/infrastructure-as-code-deploy-a-vnet-nsg-udr/</link>
					<comments>https://www.cloudcorner.gr/microsoft/azure/infrastructure-as-code-deploy-a-vnet-nsg-udr/#comments</comments>
		
		<dc:creator><![CDATA[Pantelis Apostolidis]]></dc:creator>
		<pubDate>Wed, 11 Mar 2020 22:45:35 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[IaC]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[azure template]]></category>
		<category><![CDATA[azurerm]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[iac]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[network security group]]></category>
		<category><![CDATA[nsg]]></category>
		<category><![CDATA[route table]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[udr]]></category>
		<category><![CDATA[virtual network]]></category>
		<category><![CDATA[vnet]]></category>
		<guid isPermaLink="false">https://www.e-apostolidis.gr/?p=3297</guid>

					<description><![CDATA[<p>Infrastructure as Code &#124; Deploy a VNET with NSG and UDRs Infrastructure as Code, or just IaC, provides three three</p>
<p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/infrastructure-as-code-deploy-a-vnet-nsg-udr/">Infrastructure as Code | Deploy a VNET &#038; NSG &#038; UDR</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Infrastructure as Code | Deploy a VNET with NSG and UDRs</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3312" src="https://www.e-apostolidis.gr/wp-content/uploads/2020/03/IaC.png" alt="IaC" width="1095" height="838" srcset="https://www.cloudcorner.gr/wp-content/uploads/2020/03/IaC.png 1095w, https://www.cloudcorner.gr/wp-content/uploads/2020/03/IaC-300x230.png 300w, https://www.cloudcorner.gr/wp-content/uploads/2020/03/IaC-1024x784.png 1024w, https://www.cloudcorner.gr/wp-content/uploads/2020/03/IaC-768x588.png 768w" sizes="auto, (max-width: 1095px) 100vw, 1095px" /></p>
<p>Infrastructure as Code, or just IaC, provides three three main advantages: cost reduction, faster execution and risk reduction, the attributes of the DevOps culture.</p>
<p style="text-align: justify;">Microsoft Azure Resource Manager allows the managing and provisioning of Azure Resources, that can be Virtual Machines, Virtual Networks, Storage Accounts, Apps, SQL Databases and everything that a computer data center includes, through machine-readable definition files, known as JSON templates, without the need of physical hardware configuration or interactive configuration tools.</p>
<p style="text-align: justify;">I am starting a series of posts about building infrastructure with JSON templates.</p>
<p style="text-align: justify;">The tool I use to build my Azure Json templates is the Visual Studio Code. You can download it from <a href="https://code.visualstudio.com/">https://code.visualstudio.com/</a> for every platform.</p>
<p style="text-align: justify;">To work with Azure Resource Manager you need the Azure Resource Manager Tools extension. Open the VS Code, go to the Extensions Section, search and install the Azure Resource Manager Tools extension.</p>
<p id="SEhVTIV"><img loading="lazy" decoding="async" class="alignnone wp-image-3306 size-full" src="https://www.e-apostolidis.gr/wp-content/uploads/2020/03/img_5e695dd565ae7.png" alt="infrastructure as code" width="488" height="353" srcset="https://www.cloudcorner.gr/wp-content/uploads/2020/03/img_5e695dd565ae7.png 488w, https://www.cloudcorner.gr/wp-content/uploads/2020/03/img_5e695dd565ae7-300x217.png 300w" sizes="auto, (max-width: 488px) 100vw, 488px" /></p>
<p>The extension is very helpful since it highlights the code, it provides references and intellisense.</p>
<p>At this post I am sharing &amp; explaining my Azure json template for deploying a Virtual Network, a Network Security Group and a Route Table.</p>
<p>You can find and download my working template at <a href="https://github.com/proximagr" target="_blank" rel="noopener noreferrer">my Git account</a> :</p>
<p><a href="https://github.com/proximagr/ARMTemplates/tree/master/VNET-2sub-NSG-UDR" target="_blank" rel="noopener noreferrer">https://github.com/proximagr/ARMTemplates/tree/master/VNET-2sub-NSG-UDR</a></p>
<h3>Json Template Guide</h3>
<p>Below you can find my template with comments, for better understanding.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="droide">{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
//** Define the Virtual Network Name */
    "vnetName": {
      "type": "string",
      "defaultValue": "Cloud-Corner-VNET",
      "metadata": {
        "description": "Cloud Corner VNET"
      }
//** Define the Address Space of the Virtual Network */
    },
      "vnetAddressPrefix": {
        "type": "string",
        "defaultValue": "10.0.0.0/24",
        "metadata": {
          "description": "Address prefix"
        }
//** Define the Address Space of the the First Subnet */
      },
      "subnet1Prefix": {
        "type": "string",
        "defaultValue": "10.0.0.0/27",
        "metadata": {
          "description": "Subnet 1 Prefix"
        }
//** Define the Name of the the First Subnet */
      },
      "subnet1Name": {
        "type": "string",
        "defaultValue": "Subnet1",
        "metadata": {
          "description": "Subnet 1 Name"
        }
//** Define the Address Space of the the Second Subnet */
      },
      "subnet2Prefix": {
        "type": "string",
        "defaultValue": "10.0.0.32/27",
        "metadata": {
          "description": "Subnet 2 Prefix"
        }
//** Define the Name of the the First Subnet */
      },
      "subnet2Name": {
        "type": "string",
        "defaultValue": "Subnet2",
        "metadata": {
          "description": "Subnet 2 Name"
        }
      },
//** Define the Name of the the Network Security Group */
      "networkSecurityGroup01Name": {
        "type": "string",
        "defaultValue": "Cloud-Corner-NSG-01",
        "metadata": {
          "description": "This is the name of the network security group"
        }
      },
//** Define the Name of the the First Route Table */
      "RouteTable01Name": {
        "type": "string",
        "defaultValue": "Cloud-Corner-UDR-01",
        "metadata": {
        "description": "Route Table 01 Name."
        }
      },
//** Define the Name of the the First Route of the First Route Table */
      "Route01Name": {
        "type": "string",
        "defaultValue": "To-internet",
        "metadata": {
          "description": "Route 01 Name."
        }
      },
//** Define the Next Hop Type of the the First Route of the First Route Table */
      "Route01NextHopType": {
        "type": "string",
        "allowedValues": [
        "VirtualNetworkGateway",
        "VnetLocal",
        "Internet",
        "VirtualAppliance",
        "None"
      ],
      "defaultValue": "VirtualAppliance",
        "metadata": {
          "description": "Route 01 Next Hop Type."
        }
      },
//** Define the Address Prefix of the First Route of the First Route Table */
      "Route01AddressPrefix": {
        "type": "string",
        "defaultValue": "0.0.0.0/0",
        "metadata": {
          "description": "Route 01 Address Prefix."
        }
      },
//** If you set "Virtyal Appliance for Next Hop Type, then you need to define the Next Hop IP Address, */
//** meaning the appliance's IP address. Here you define it for the First Route of the First Route Table */
        "RT01Route01NextHopIPAddress": {
        "type": "string",
        "defaultValue": "10.0.0.40",
        "metadata": {
          "description": "Next Hop IP Addess."
        }
      },
//** Define the Name of the Second Route Table */
      "RouteTable02Name": {
        "type": "string",
        "defaultValue": "Cloud-Corner-UDR-02",
        "metadata": {
          "description": "Route Table 02 Name."
        }
      },
//** Define the Name of the the First Route of the Second Route Table */
      "RT02Route01Name": {
        "type": "string",
        "defaultValue": "Local-Subnet",
        "metadata": {
        "description": "Route Table 02 Route 01 Name."
        }
      },
//** Define the Next Hop Type of the the First Route of the Second Route Table */
      "RT02Route01NextHopType": {
        "type": "string",
        "allowedValues": [
        "VirtualNetworkGateway",
        "VnetLocal",
        "Internet",
        "VirtualAppliance",
        "None"
      ],
      "defaultValue": "VnetLocal",
        "metadata": {
          "description": "Route 02 Next Hop Type."
        }
      },
//** Define the Address Prefix of the the First Route of the Second Route Table */
      "RT02Route01AddressPrefix": {
        "type": "string",
        "defaultValue": "10.0.0.0/27",
        "metadata": {
          "description": "Route Table 02 Route 01 Address Prefix."
        }
      },
//** Define the Name of the the Second Route of the Second Route Table */
        "RT02Route02Name": {
          "type": "string",
          "defaultValue": "To-subnet-1",
          "metadata": {
            "description": "Route Table 02 Route 01 Name."
          }
        },
//** Define the Next Hop Type of the the Second Route of the Second Route Table */
        "RT02Route02NextHopType": {
          "type": "string",
          "allowedValues": [
          "VirtualNetworkGateway",
          "VnetLocal",
          "Internet",
          "VirtualAppliance",
          "None"
        ],
        "defaultValue": "VirtualAppliance",
          "metadata": {
            "description": "Route 02 Next Hop Type."
          }
        },
//** Define the address prefix of the the Second Route of the Second Route Table */
        "RT02Route02AddressPrefix": {
          "type": "string",
          "defaultValue": "10.0.0.32/27",
          "metadata": {
            "description": "Route Table 02 Route 01 Address Prefix."
          }
      },
//** Define the next hop IP address (the virtual appliance's address) of the the Second Route of the Second Route Table */
        "RT02Route02NextHopIPAddress": {
          "type": "string",
          "defaultValue": "10.0.0.40",
          "metadata": {
            "description": "Next Hop IP Addess."
          }
        }
    },
//** I dont use any variables, you can exclude this section*/
  "variables": {},
  "resources": [
//* create the First Route Table &amp; Route*/
    {
    "apiVersion": "2017-10-01",
    "type": "Microsoft.Network/routeTables",
    "name": "[parameters('RouteTable01Name')]",
    "location": "[resourceGroup().location]",
    "properties": {
    "disableBgpRoutePropagation": true,
    "routes": [
      {
        "name": "[parameters('Route01Name')]",
        "properties": {
          "addressPrefix": "[parameters('Route01AddressPrefix')]",
          "nextHopType": "[parameters('Route01NextHopType')]",
          "nextHopIpAddress": "[parameters('RT01Route01NextHopIPAddress')]"
          }
        }
      ]
    }
  },
//* create the Second Route Table &amp; Routes*/
    {
    "apiVersion": "2017-10-01",
    "type": "Microsoft.Network/routeTables",
    "name": "[parameters('RouteTable02Name')]",
    "location": "[resourceGroup().location]",
    "properties": {
    "disableBgpRoutePropagation": true,
    "routes": [
      {
        "name": "[parameters('RT02Route01Name')]",
        "properties": {
          "addressPrefix": "[parameters('RT02Route01AddressPrefix')]",
          "nextHopType": "[parameters('RT02Route01NextHopType')]"
        }
      },
          {
        "name": "[parameters('RT02Route02Name')]",
        "properties": {
          "addressPrefix": "[parameters('RT02Route02AddressPrefix')]",
          "nextHopType": "[parameters('RT02Route02NextHopType')]",
          "nextHopIpAddress": "[parameters('RT02Route02NextHopIPAddress')]"
          }
        }
      ]
    }
  },
//* create teh Network Security Group */
    {
    "apiVersion": "2019-02-01",
    "type": "Microsoft.Network/networkSecurityGroups",
    "name": "[parameters('networkSecurityGroup01Name')]",
    "location": "[resourceGroup().location]",
    "properties": {
      "securityRules": [
        {
          "name": "HTTPS",
          "properties": {
            "description": "Open HTTPS to Public",
            "protocol": "Tcp",
            "sourcePortRange": "443",
            "destinationPortRange": "443",
            "sourceAddressPrefix": "*",
            "destinationAddressPrefix": "*",
            "access": "Allow",
            "priority": 101,
            "direction": "Inbound"
            }
          }
        ]
      }
    },
//* create the Virtual Network */
    {
      "apiVersion": "2018-10-01",
      "type": "Microsoft.Network/virtualNetworks",
      "name": "[parameters('vnetName')]",
      "location": "[resourceGroup().location]",
//*add a dependency in order to ensure that the NSG is created before the VNET, in order to be able to attach it*/
      "dependsOn": [
        "[parameters('networkSecurityGroup01Name')]"
      ],
      "properties": {
        "AddressSpace": {
          "AddressPrefixes": [
            "[parameters('vnetAddressPrefix')]"
          ]
        }
      },
      "resources": [
//* create the first subnet */
        {
        "apiVersion": "2018-10-01",
        "type": "subnets",
        "location": "[resourceGroup().location]",
        "name": "[parameters('subnet1Name')]",
//* add dependencies to create the resources with an order, because you need to ensure that the VNET is ready before creating the Subnet and also the Route Table*/
        "dependsOn": [
          "[parameters('vnetName')]",
          "[resourceId('Microsoft.Network/routeTables', parameters('RouteTable01Name'))]"
        ],
        "properties": {
        "AddressPrefix": "[parameters('subnet1Prefix')]",
//*attach the Newtork Securoty Group to the Subnet*/
        "networkSecurityGroup": {
        "id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroup01Name'))]"},
//*attacht the First route table to the Subnet*/
        "routeTable": {
        "id": "[resourceId('Microsoft.Network/routeTables', parameters('RouteTable01Name'))]"
          }
         }
        },
//*create the second subnet*/
        {
        "apiVersion": "2018-10-01",
        "type": "subnets",
        "location": "[resourceGroup().location]",
        "name": "[parameters('subnet2Name')]",
        "dependsOn": [
          "[parameters('vnetName')]",
          "[parameters('subnet1Name')]",
          "[parameters('RouteTable02Name')]"
        ],
        "properties": {
          "AddressPrefix": "[parameters('subnet2Prefix')]",
//*attach the Newtork Securoty Group to the Subnet*/
          "networkSecurityGroup": {
          "id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroup01Name'))]"},
//*attacht the second route table to the Subnet*/
          "routeTable": {
          "id": "[resourceId('Microsoft.Network/routeTables', parameters('RouteTable02Name'))]"
            }
          }
        }
      ]
    }
  ]
}</pre>
<p>&nbsp;</p>
<h3>Deploy the template</h3>
<p><strong>Deploy the template directly from here:</strong></p>
<p><a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fproximagr%2FARMTemplates%2Fmaster%2FVNET-2sub-NSG-UDR%2Fazuredeploy.json" target="_blank" rel="noopener noreferrer"> <img decoding="async" src="https://aka.ms/deploytoazurebutton" /> </a></p>
<p>&nbsp;</p>
<p>More Azure Resource Manager Templates: <a href="https://www.e-apostolidis.gr/microsoft/create-azure-file-shares-using-arm-template-powershell/">https://www.e-apostolidis.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/</a></p>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author">
<div class="saboxplugin-tab">
<div class="saboxplugin-gravatar"><img loading="lazy" decoding="async" src="https://www.e-apostolidis.gr/wp-content/uploads/2019/05/mvpsummit2019.jpg" width="100"  height="100" alt="Pantelis Apostolidis" itemprop="image"></div>
<div class="saboxplugin-authorname"><a href="https://www.cloudcorner.gr/author/admin/" class="vcard author" rel="author"><span class="fn">Pantelis Apostolidis</span></a></div>
<div class="saboxplugin-desc">
<div itemprop="description">
<p>Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.</p>
</div>
</div>
<div class="saboxplugin-web "><a href="https://www.cloudcorner.gr" target="_self" >www.cloudcorner.gr</a></div>
<div class="clearfix"></div>
<div class="saboxplugin-socials "><a title="Facebook" target="_blank" href="https://www.facebook.com/pantelis.apostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_blank" href="https://www.linkedin.com/in/papostolidis/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Instagram" target="_blank" href="https://www.instagram.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Rss" target="_blank" href="https://wwwcloudcorner.gr/feed/rdf/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-rss" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041 64.04 28.673 64.04 64.041zm175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018 111.832 7.284 201.473 96.702 208.772 208.772.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79zm144.249.288C439.596 229.677 251.465 40.445 16.503 32.01 7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999 191.179 7.839 344.627 161.316 352.465 352.465.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504z"></path></svg></span></a><a title="Twitter" target="_blank" href="https://twitter.com/papostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Github" target="_blank" href="https://github.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-github" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></span></a><a title="User email" target="_self" href="mailto:p&#114;oxim&#097;g&#114;&#064;&#104;otm&#097;&#105;l.c&#111;m" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-user_email" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"></path></svg></span></a></div>
</div>
</div>
<p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Finfrastructure-as-code-deploy-a-vnet-nsg-udr%2F&amp;linkname=Infrastructure%20as%20Code%20%7C%20Deploy%20a%20VNET%20%26%20NSG%20%26%20UDR" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_print" href="https://www.addtoany.com/add_to/print?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Finfrastructure-as-code-deploy-a-vnet-nsg-udr%2F&amp;linkname=Infrastructure%20as%20Code%20%7C%20Deploy%20a%20VNET%20%26%20NSG%20%26%20UDR" title="Print" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Finfrastructure-as-code-deploy-a-vnet-nsg-udr%2F&#038;title=Infrastructure%20as%20Code%20%7C%20Deploy%20a%20VNET%20%26%20NSG%20%26%20UDR" data-a2a-url="https://www.cloudcorner.gr/microsoft/azure/infrastructure-as-code-deploy-a-vnet-nsg-udr/" data-a2a-title="Infrastructure as Code | Deploy a VNET &amp; NSG &amp; UDR"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" alt="Share"></a></p><p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/infrastructure-as-code-deploy-a-vnet-nsg-udr/">Infrastructure as Code | Deploy a VNET &#038; NSG &#038; UDR</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cloudcorner.gr/microsoft/azure/infrastructure-as-code-deploy-a-vnet-nsg-udr/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Create Azure File Shares at your ARM template using PowerShell</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/</link>
					<comments>https://www.cloudcorner.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Pantelis Apostolidis]]></dc:creator>
		<pubDate>Thu, 28 Sep 2017 13:51:43 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[IaC]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[azure file storage]]></category>
		<category><![CDATA[azurerm]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[template]]></category>
		<guid isPermaLink="false">https://www.e-apostolidis.gr/?p=1499</guid>

					<description><![CDATA[<p>Create Azure File Shares at your ARM template using PowerShell Using Azure Resource Manage template deployment, you can create a</p>
<p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/">Create Azure File Shares at your ARM template using PowerShell</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Create Azure File Shares at your ARM template using PowerShell</h2>
<p style="text-align: justify;">Using Azure Resource Manage template deployment, you can create a Storage account but you cannot create File Shares. Azure File Shares can be created using the Azure Portal, the Azure PowerShell or the Azure Cli.</p>
<p style="text-align: justify;">Mainly, the idea is to run a PowerShell script that will create the File Shares. This script will be invoked inside the ARM Template. In order to use a PowerShell script from a template, the script must be called from a URL. A good way to provide this is using the Git repository.  One major thing to consider is the Storage Account key must be provided to the PowerShell script securely, since the PowerShell script is at a public URL.</p>
<p style="text-align: justify;">The PowerShell script will run inside a Virtual Machine and we will use a CustomScriptExtension Extension to provide it. To use this, at the Virtual Machine Resource of the JSON file add a resources section.</p>
<p style="text-align: justify;">The Custom Script Exception is located at the Virtual Machine resource. Lets assume that the last part of the Virtual Machine resource is the &#8220;diagnosticsProfile&#8221; so after the closure of the &#8220;diagnosticsProfile&#8221; we can add the &#8220;resources&#8221;. Inside the &#8220;resources&#8221; add the &#8220;extensions&#8221; resource that will add the &#8220;CustomScriptExtension&#8221;, like below.</p>
<h3>The Template Part</h3>
<p>This will be the addition at the Virtual Machine resource:</p>
<pre class="theme:vs2012 lang:asp decode:true"> "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": true,
            "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('diagnosticStorageAccountName')), '2016-01-01').primaryEndpoints.blob)]"
          }
        }
        },
        "resources": [
          {
            "name": "AzureFileShares",
            "type": "extensions",
            "location": "[variables('location')]",
            "apiVersion": "2016-03-30",
            "dependsOn": [
              "[resourceId('Microsoft.Compute/virtualMachines', parameters('VMName'))]",
              "[variables('AzureFilesStorageId')]"
            ],
            "tags": {
              "displayName": "AzureFileShares"
            },
            "properties": {
              "publisher": "Microsoft.Compute",
              "type": "CustomScriptExtension",
              "typeHandlerVersion": "1.4",
              "autoUpgradeMinorVersion": true,
              "settings": {
                "fileUris": [
                  "https://raw.githubusercontent.com/######/#####/master/azurefiles.ps1"
                ]
              },
              "protectedSettings": {
               "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ','azurefiles.ps1 -SAName ',parameters('AzureFilesStorageName'),'  -SAKey ', listKeys(resourceId(variables('AzureFilesStorageAccountResourceGroup'),'Microsoft.Storage/storageAccounts', parameters('AzureFilesStorageName')), '2015-06-15').key1)]" 
             }
            }
          }
        ]
    },</pre>
<p style="text-align: justify;">The extension must be depended from the Virtual Machine that will run the script and the Storage Account that will bu used for the file shares.</p>
<p style="text-align: justify;">At the custom script properties add the public RAW url of the PowerShell script.</p>
<p style="text-align: justify;">Next lets see the Storage Account key and execution part. At the connandToExecute section, we will provide a variable that will pass the Storage Account key &amp; Name inside the script for execution. The variable will get the Storage Account key from the Storage Account using the permissions of the Account  running the Template Deployment.</p>
<p style="text-align: justify;">Of course to make the template more flexible I have added a variable for the Resource Group and a parameter for the AzureFilesStorageName, so the template will ask for the Storage Account name at the parameters.</p>
<h3>The PowerShell</h3>
<p>The PowerShell script is tested at Windows Server 2016 VM. You can find it below:</p>
<pre class="lang:ps decode:true ">Param (
  [Parameter()]
  [String]$SAKey,
  [String]$SAName
)
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module Azure -Confirm:$False
Import-Module Azure
$storageContext = New-AzureStorageContext -StorageAccountName $SAName -StorageAccountKey $SourceSAKey
$storageContext |  New-AzureStorageShare -Name #####</pre>
<p>&nbsp;</p>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author">
<div class="saboxplugin-tab">
<div class="saboxplugin-gravatar"><img loading="lazy" decoding="async" src="https://www.e-apostolidis.gr/wp-content/uploads/2019/05/mvpsummit2019.jpg" width="100"  height="100" alt="Pantelis Apostolidis" itemprop="image"></div>
<div class="saboxplugin-authorname"><a href="https://www.cloudcorner.gr/author/admin/" class="vcard author" rel="author"><span class="fn">Pantelis Apostolidis</span></a></div>
<div class="saboxplugin-desc">
<div itemprop="description">
<p>Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.</p>
</div>
</div>
<div class="saboxplugin-web "><a href="https://www.cloudcorner.gr" target="_self" >www.cloudcorner.gr</a></div>
<div class="clearfix"></div>
<div class="saboxplugin-socials "><a title="Facebook" target="_blank" href="https://www.facebook.com/pantelis.apostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_blank" href="https://www.linkedin.com/in/papostolidis/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Instagram" target="_blank" href="https://www.instagram.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Rss" target="_blank" href="https://wwwcloudcorner.gr/feed/rdf/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-rss" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041 64.04 28.673 64.04 64.041zm175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018 111.832 7.284 201.473 96.702 208.772 208.772.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79zm144.249.288C439.596 229.677 251.465 40.445 16.503 32.01 7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999 191.179 7.839 344.627 161.316 352.465 352.465.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504z"></path></svg></span></a><a title="Twitter" target="_blank" href="https://twitter.com/papostolidis" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Github" target="_blank" href="https://github.com/proximagr" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-github" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></span></a><a title="User email" target="_self" href="mailto:&#112;rox&#105;ma&#103;r&#064;hot&#109;&#097;&#105;l&#046;&#099;&#111;m" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-user_email" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"></path></svg></span></a></div>
</div>
</div>
<p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fcreate-azure-file-shares-using-arm-template-powershell%2F&amp;linkname=Create%20Azure%20File%20Shares%20at%20your%20ARM%20template%20using%20PowerShell" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_print" href="https://www.addtoany.com/add_to/print?linkurl=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fcreate-azure-file-shares-using-arm-template-powershell%2F&amp;linkname=Create%20Azure%20File%20Shares%20at%20your%20ARM%20template%20using%20PowerShell" title="Print" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.cloudcorner.gr%2Fmicrosoft%2Fazure%2Fcreate-azure-file-shares-using-arm-template-powershell%2F&#038;title=Create%20Azure%20File%20Shares%20at%20your%20ARM%20template%20using%20PowerShell" data-a2a-url="https://www.cloudcorner.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/" data-a2a-title="Create Azure File Shares at your ARM template using PowerShell"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" alt="Share"></a></p><p>The post <a href="https://www.cloudcorner.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/">Create Azure File Shares at your ARM template using PowerShell</a> appeared first on <a href="https://www.cloudcorner.gr">Apostolidis Cloud Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cloudcorner.gr/microsoft/azure/create-azure-file-shares-using-arm-template-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
