<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Rumors about Azure, SQL Server &amp; Data in the Cloud....</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/igorpag/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/igorpag/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 13 Nov 2018 18:17:34 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Azure Availability Zones Quick Tour and Guide</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/azure-availability-zones-quick-tour-and-guide</link>
      <pubDate>Thu, 03 May 2018 09:07:26 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=2125</guid>
      <description><![CDATA[Three years ago, I started working with a big Microsoft partner on moving infrastructure and...]]></description>
      <content:encoded><![CDATA[Three years ago, I started working with a big Microsoft partner on moving infrastructure and services into Azure. At that time, it was not possible to implement all the required functionalities and requirements, due to some missing features, one of these was Availability Zones (AZ). Not a hard blocker initially, we slightly modified the architecture to achieve what the partner requested, and then we post-poned the AZ discussion until few months back. First lesson we learned: do you really need AZ? Is it a critical feature you cannot avoid using? Is it a real hard blocker for customers that are already using it with other Cloud providers? At least in my specific case, the answer to all these questions is NO, but nice to have. Azure Availability Zones (AZ) is a great feature that is aiming to augment Azure capabilities and raise high-availability bar. First step is understand what it is, capabilities and limitations, why should be eventually used and which problems is aiming to solve. What I’m going to describe here, are the core concepts and discussion points I used talking with my partner, then what I used to modify that specific architecture to include AZ design. Where not differently stated, I will talk in the context of Virtual Machines (VM) since my project was IaaS scoped.
<h2><strong>Where Availability Zones are sitting? </strong></h2>
For you that are not aware of what AZ is, let me include a good single sentence definition: Availability Zones (AZ) are unique physical locations with independent power, network, and cooling. Each Availability Zone is comprised of one or more datacenters and houses infrastructure to support highly available, mission critical applications. AZ are tolerant to datacenter failures through redundancy and logical isolation of services. I already authored an article introducing this feature, then you may want to read it before going forward with the current one:
<p style="padding-left: 30px"><strong><em>Why Azure Availability Zones</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/igorpag/2017/10/08/why-azure-availability-zones">https://blogs.msdn.microsoft.com/igorpag/2017/10/08/why-azure-availability-zones</a></p>
Azure today is available in 50 regions worldwide, as you can see in the map below. In the same picture (live link <a href="https://azure.microsoft.com/en-us/global-infrastructure/regions/">here</a>) you can see both announced and already available regions. You can also find out in which regions AZ feature is already available (France Central and Central US, at the time of writing this article), and where is currently in preview (East US 2, West Europe, Southeast Asia), reaching <a href="https://docs.microsoft.com/en-us/azure/availability-zones/az-overview">this</a> page.

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/11.jpg"><img width="1031" height="585" class="aligncenter wp-image-2135" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/11.jpg" /></a>

But in the general Azure hierarchy, where AZ is exactly sitting? Using the map above and the page from where I pulled it down, we can describe the following hierarchy:
<ul>
 	<li><strong>Geographies</strong>: Azure regions are organized into 4 geographies actually (Americas, Europe, Asia Pacific, Middle East and Africa). An Azure geography ensures that data residency, sovereignty, compliance, and resiliency requirements are honored within geographical boundaries.</li>
 	<li><strong>Regions</strong>: A region is a set of datacenters deployed within a latency-defined perimeter and connected through a dedicated regional low-latency network. Inside each geography, there are at least two regions to provide geo disaster recovery inside the same geopolitical boundary (Brazil South is an exception).</li>
 	<li><strong>Availability Zones</strong>: AZ are physically separate locations within an Azure region. Each Availability Zone is made up of one or more datacenters equipped with independent power, cooling, and networking. For each region enabled for AZ, there are three Availability Zones.</li>
 	<li><strong>Datacenters</strong>: physical buildings where compute, network and storage resources are hosted, and service operated. Inside each AZ, where present, there is at least one Azure datacenter.</li>
 	<li><strong>Clusters</strong>: group of racks used to organize compute, storage and network resources inside each datacenter.</li>
 	<li><strong>Racks</strong>: physical steel and electronic framework that is designed to house servers, networking devices, cables. Each rack includes several physical blade servers.</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2018/05/2.jpg"><img width="710" height="352" class="aligncenter wp-image-2145" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/2.jpg" /></a>

I often heard this nice question from my customers and partners: why Azure provides <u>three</u> zones? Should be enough <u>two</u> zones instead? Reason is pretty simple: for any kind of software or service that requires a quorum mechanism, for example SQL Server or Cassandra, two zones are not enough to always guarantee a majority when a single one is down. Think about three nodes: if you have three zones, you can deploy one node in each zone, and still have majority if a single zone/node is down. But what happens if you have only two zones? You will have to place two nodes into the same zone, and this specific zone will be down, you will lose majority and your service will stop. A nice example for SQL Server, deployed using AlwaysOn Availability Group across AZ, is reported below:
<p style="padding-left: 30px"><strong><em>SQL Server 2016 AlwaysOn with Managed Disks in Availability Zones</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/resources/templates/sql-alwayson-md-mult-subnets-zones">https://azure.microsoft.com/en-us/resources/templates/sql-alwayson-md-mult-subnets-zones</a></p>

<h2><strong>Why should I use Availability Zones? </strong></h2>
AZ has been built to make Azure resiliency strategy better and more comprehensive. Let me re-use a perfect summarizing sentence from <a href="https://azure.microsoft.com/en-us/blog/azure-availability-zones-now-available-for-the-most-comprehensive-resiliency-strategy/">this</a> blog post:
<p style="padding-left: 30px"><em>Azure now offers the most comprehensive resiliency strategy in the industry from mitigating rack level failures with availability sets to protecting against large scale events with failover to separate regions. Within a region, Availability Zones increase fault tolerance with physically separated locations, each with independent power, network, and cooling....</em><em>  </em></p>
While regions are 100s of miles distant and provide protection from wide natural disasters, AZs are much closer and then not suitable for protecting from this kind of events. If you want to build your geo-DR story, you should still use different Azure regions. On the other hand, this relative proximity should permit you to replicate <strong><u>synchronously</u></strong> (RPO = 0) your data across different physical and isolated, <strong><u>independent</u></strong> locations, protecting your application or service from datacenter wide failures. With AZ, what Azure can provide now in terms of High-Availability SLA, is slightly changed, let me recap the full spectrum using the <a href="https://azurecomcdn.azureedge.net/mediahandler/files/resourcefiles/azure-resiliency-infographic/Azure_resiliency_infographic.pdf">graphic</a> below:

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/3.jpg"><img width="667" height="542" class="aligncenter wp-image-2155" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/3.jpg" /></a>

As you can see, now for your VMs you can have <strong>99.99% HA SLA</strong>, compared to the lower 99.95% provided by the traditional <strong>Availability Set (AS)</strong> mechanism. AS is still supported, but cannot be used in conjunction with AZ, you have to decide which option you want to use: at VM creation time, you need to place your VM into an AZ or into an AS, and you will not allowed to move it later, at least as the technology works today. For an overview of mechanisms that you can use to manage availability of your VMs, you can read the article below:
<p style="padding-left: 30px"><strong><em>Manage the availability of Windows virtual machines in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/manage-availability">https://docs.microsoft.com/en-us/azure/virtual-machines/windows/manage-availability</a></p>
If you decide to use AZ, you will <em><u>*not*</u></em> formally have the concepts of <em>Update Domains</em> (UDs) and <em>Fault Domains</em> (FDs). In this case, AZ will be now your UDs an FDs, remember that these are different and independent Azure locations, from a physical and logical perspective. If you try to put your VM into both AS and AZ, you will get an error. You can realize it looking into the PowerShell cmdlet "<strong><em>New-AzureRmVMConfig</em></strong>": as you can see below, it is here that you can specify values for either "<strong>-Zone</strong>" or "<strong><em>-AvailabilitySetId</em></strong>" parameters, but not both at the same time. You will not get an error for this cmdlet execution, but later when you will try to instantiate a VM object with “<strong><em>New-AzureRmVM</em></strong>”:

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/4.jpg"><img width="845" height="316" class="aligncenter wp-image-2165" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/4.jpg" /></a>

In the print screen above you can read the error message below:
<p style="padding-left: 30px"><em><span style="color: #0000ff">Virtual Machine cannot be created because both Availability Zone and Availability Set were specified.</span> <span style="color: #ff0000">Deploying an Availability Set to an Availability Zone isn’t supported.</span></em></p>
&nbsp;
<h2><strong>Availability Zones are only for VM? </strong></h2>
Short answer is “NO”, long answer is starting now. As I stated at the beginning, in this article I’m mainly talking about the Virtual Machine (IaaS) context but let me shortly describe where AZ is also expanding its coverage. I would be not surprised at all to learn about upcoming new Azure resources and services. This is only my opinion, but AZ is a great mechanism to improve resiliency of distributed services, and I can imagine Azure will make more of them AZ enabled.
<h3><strong>Azure SQL Database (SQLDB)</strong></h3>
It is still in preview, even if AZ is generally available in some regions, main article is reported below and the section interesting for us is “<em>Zone redundant configuration</em>”:
<p style="padding-left: 30px"><strong><em>High-availability and Azure SQL Database</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-high-availability">https://docs.microsoft.com/en-us/azure/sql-database/sql-database-high-availability</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2018/05/5.jpg"><img width="716" height="524" class="aligncenter wp-image-2175" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/5.jpg" /></a>

Important thing to keep in mind is that SQLDB with AZ is only available with the “<em>Premium</em>” tier. Why this? If you are interested in the details, I would recommend you read the article above. If not, let me shortly recap here: only with “<em>Premium</em>” SQLDB tier you have three different active SQLDB instances, deployed across all the 3 zones, database storage is local ephemeral SSD storage, and synchronously replicated. HA SLA is the same as without AZ, that is 99.99%, with RPO = 0, RTO = 30s. For automatic backups, ZRS storage is used. NOTE: You don’t have control on how many and which zones your SQLDB nodes will be placed.
<h3><strong>Virtual Machine Scale Set (VMSS)</strong></h3>
VMSS has nice and deep relation with AZ, let me explain why. First, with VMSS you can use AZ and at the same time you can still use Availability Set (AS). Once again, this is <em><u>*not*</u></em> possible with standard Azure VMs.
<p style="padding-left: 30px"><strong><em>Create a virtual machine scale set that uses Availability Zones</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-availability-zones">https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-availability-zones</a></p>
As explained in the article above, you have the option to deploy VMSS with "<em>Max Spreading</em>" or "<em>Static 5 fault domain spreading</em>". With first option, the scale set spreads your VMs across as many fault domains as possible within each zone. This spreading could be across greater or fewer than five fault domains per zone. With the second option, the scale set spreads your VMs across exactly five fault domains per zone. Another cool VMSS feature that can be used in conjunction with AZ is “<em>Placement Group</em>”. A placement group is a construct similar to an Azure AS, with its own fault domains and upgrade domains. By default, a scale set consists of a single placement group with a maximum size of 100 VMs. If a scale set is composed of a single placement group, it has a range of 0-100 VMs only, with multiple you can arrive to 1000.

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/6.jpg"><img width="872" height="457" class="aligncenter wp-image-2185" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/6.jpg" /></a>

Last evidence of good integration between VMSS and AZ is the “load balancing” options you have. For VMSS deployed across multiple zones, you also have the option of choosing "<em>Best effort zone balance</em>" or "<em>Strict zone balance</em>". A scale set is considered "balanced" if the number of VMs in each zone is within one of the number of VMs in all other zones for the scale set. With best-effort zone balance, the scale set attempts to scale in and out while maintaining balance.
<h2><strong>Where am I placing my resources? </strong></h2>
I decided to group here a series of questions related to AZ selection and placement. I felt some confusion here from customers and partners, then I hope that what I’m writing will be useful.
<ul>
 	<li><strong>Usage of AZ is mandatory</strong>? NO, you can continue deploying your VMs as usual. Then, where will my resource will be deployed? You should not be worried about this, you will only indicate the “region” in your request, and Azure will place your VM in a datacenter inside that region. NOTE: AZ related parameters in ARM templates, PowerShell cmdlets and AZ CLI are all optional.</li>
 	<li><strong>Is there a default AZ if not specified</strong>? NO, apparently there is no way to set a subscription wide default AZ. If you want to use it, you must specify which one.</li>
 	<li><strong>Can I specify the physical AZ? </strong>NO, you can specify only logical AZ as “1”, “2” or “3”. How logical is translated to physical zones, and datacenters, is managed automatically by Azure platform.</li>
 	<li><strong>Is logical to physical mapping constant across Azure subscription?</strong> NO, I didn’t find any official statement or SLA about providing same mapping for different subscriptions even under the same Azure Active Directory tenant.</li>
 	<li><strong>Which is the distance (and then the latency) between AZ?</strong> Officially, there is no indication of distance between different AZs, nor network latency SLA, only a general indication of “less than 2ms” boundary inside the same region.</li>
 	<li><strong>Is it possible to check in which AZ my VM is deployed?</strong> YES, you can check in which zone your VM is deployed looking into the VM properties using the Azure Portal, PowerShell and <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service">Azure Instance Metadata Service</a> (<em>see JSON fragment example below</em>, more details later in this article).</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2018/05/7.jpg"><img width="450" height="334" class="aligncenter wp-image-2195" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/7.jpg" /></a>
<h2><strong>What I need to create my VM into Availability Zone? </strong></h2>
If you want to create and access a VM in Azure, you would normally need to define first dependent “<em>core</em>” resources: a public IP (<strong>VIP</strong>), maybe a Load Balancer (<strong>LB</strong>) tied to this public IP, a network interface card object (<strong>NIC</strong>), a Virtual Network and subnet (<strong>VNET, Subnet</strong>) and a disk (<strong>Managed Disk</strong>). This remains the same also with AZ. In addition to these resources, you may also need an <strong>Image</strong> to deploy your custom OS, and a <strong>Snapshot</strong> taken from your VM disk for backup/recovery purposes.  With the advent of AZ, Azure team applied several underlying changes to all these core resources to make possible and efficient running Azure VMs, and other services, into AZ. Before shortly describing each of them, let me clarify a new terminology that you may find around in Azure documentation: with “<strong><em>zone redundant</em></strong>” is intended a resource that is deployed across at least two AZs and then able to survive the loss of a single zone. Instead, with “<strong>zonal</strong>” is intended a resource that is deployed into a single and specific AZ, and will not survive to zone loss. Keep in mind that this distinction is only for resources that are “<em>AZ-aware</em>”. There are resources that are not deployed, or deployable, into Availability Zone. For example, an Azure VM per se is a “zonal” resource because is a monolithic object that can be deployed only into a single AZ. But can be also created without mentioning AZ at all, as you have always done before this feature. Instead, Azure Load Balancer can be created either as “<strong>zonal</strong>” resource or “<strong><em>zone redundant</em></strong>”.

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/8.jpg"><img width="535" height="460" class="aligncenter size-full wp-image-2205" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/8.jpg" /></a>

&nbsp;
<h3><strong>Load Balancer </strong></h3>
Azure recently introduced a new type/SKU of load balancer (LB) called <a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-overview">Azure Standard Load Balancer</a> that has lots of new nice features, one of these is the <u>support</u> for Availability Zones (AZ). Pay attention to what I have just written: I said “<u>support</u>” because a LB resource itself is <em>regional</em>. Imagine it as zone-redundant already, even without leveraging AZ capability. What is correct to say is that LB can support <strong><em>zonal </em></strong>or <strong><em>zone-redundant</em></strong> scenarios, depending on your needs and configuration. Both public and internal LB supports both scenarios, with internal and external frontend IP configurations, can direct traffic across zones as needed (cross-zone load balancing). These two scenarios are reported below as examples:
<p style="padding-left: 30px"><strong><em>Create a public Load Balancer Standard with zonal frontend using Azure CLI</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-public-zonal-cli">https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-public-zonal-cli</a></p>
&nbsp;
<p style="padding-left: 30px"><strong><em>Load balance VMs across all availability zones using Azure CLI</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-public-zone-redundant-cli">https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-public-zone-redundant-cli</a></p>
&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/9.jpg"></a>

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/10.jpg"><img width="487" height="409" class="aligncenter wp-image-2225" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/10.jpg" /></a>
<h3><strong>Public IP</strong></h3>
Along with the Load Balancer described above, also for Public IP (VIP) we have a <a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-public-ip-address#create-a-public-ip-address">Standard</a> SKU. If you want/need to work with a Standard LB for AZ, you also need to use a Standard Public IP, you cannot mix the SKUs here. With Standard LB and VIP you can now enable zone redundancy on your public and internal frontends using a single IP address, or tie their frontend IP addresses to a specific zone. This type of cross-zone load balancing can address any VM or VMSS in a region. A zone-redundant IP address is served (advertised) by the load balancer in every zone, since the data path is <strong>anycast </strong>within the region. In the unlikely chance that a zone goes down completely, the load balancer is able to serve the traffic from instances in another zone, very quickly.
<h3><strong>Virtual Network, Subnet, NIC, NSG and UDR</strong></h3>
You may be surprised if you are not familiar with Azure, and coming from other Cloud providers with AZ feature available. Azure VNET and related subnets are regional by design, and do not require any AZ specification when creating them. Additionally, there is no requirement on subnet placing: both VNET and subnet can include IP addresses for resources across AZs. Azure supports region wide VNETs since 2014 as originally announced <a href="https://azure.microsoft.com/en-us/blog/regional-virtual-networks/">here</a>. Based on this, there is no specific impact on definition and behavior for Network Security Groups (NSGs) and User Defined Routes (UDRs) when AZ design is applied. Same for the Network Interface Card (NIC) object.
<h3><strong>Managed Disk &amp; Storage </strong></h3>
A VM needs at least an OS disk to boot from, additional data disks are possible but not required. There are several types of disks available in Azure, but if you want to attach to a “<em>zonal</em>” VM, you need to use the <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/managed-disks-overview">Managed Disk</a> (MD) type, either Premium or Standard, you cannot use the <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/standard-storage">unmanaged</a> legacy version. If using the Azure Portal, the “<em>Storage</em>” option will be immediately grayed out as soon as you will select a zone for your VM placement. Once again, Availability Zones feature requires Managed Disks for VMs.

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/111.jpg"><img width="269" height="367" class="aligncenter wp-image-2235" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/111.jpg" /></a>

&nbsp;

Please remember that MD feature only supports Locally Redundant Storage (LRS) as the replication option. When you create a VM from the Azure Portal, or for example using PowerShell, a MD for OS will be implicitly created and co-located in the same AZ chosen for the placement of compute resources. MD can be also created as standalone object, syntax for creation commands/scripts has been augmented to allow AZ specification. MD is always a “zonal” object and cannot be directly moved/migrated. Be aware that you cannot attach a MD created in AZ(1) to a VM created in AZ(2).
<h3><strong>Images &amp; Snapshots</strong></h3>
Images and Snapshots (for Managed Disks) are not strictly required, but you may need to use these objects. If you want to use a different image from the ones available in the Azure Gallery, you need to build your own one, store in the Azure storage as an image object, and then deploy new VMs sourcing from this new template. For Snapshots, the usage and purpose are a bit less evident: whenever you will take a snapshot on your VM Managed Disk, it will be created on ZRS storage and synchronously replicated across all storage zones. This is useful because MD storage cannot be neither ZRS nor GRS, more details in the next section. Now these two objects are “<strong><em>zone-redundant</em></strong>”.
<p style="padding-left: 30px"><strong><em>General availability: Azure zone-redundant snapshots and images for managed disks</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/updates/azure-managed-snapshots-images-ga">https://azure.microsoft.com/en-us/updates/azure-managed-snapshots-images-ga</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2018/05/12.jpg"><img width="754" height="424" class="aligncenter wp-image-2245" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/12.jpg" /></a>
<h2><strong>Which kind of storage should I use for my zoned VM? </strong></h2>
I decided to dedicate a specific section to this topic because there are some key aspects that need to be clarified. I’m not going to disclose any internal information, everything is in the Azure public documentation, but you may find difficult to connect all the dots and obtain a unique clear picture. First, let me clarify about <strong>ZRS: Zone Replicated Storage</strong> has been released in <strong>v1</strong> long time ago. This is different from what, instead, we recently released as v2 on <em>March 30<sup>th</sup>, 2018</em>:
<p style="padding-left: 30px"><strong><em>General availability: Zone-redundant storage</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/updates/azure-zrs">https://azure.microsoft.com/en-us/updates/azure-zrs</a></p>
Now <strong>v1</strong>, renamed as “<strong><em>ZRS Classic</em></strong>”, is officially deprecated and <em><u>will be retired on March 31, 2021</u></em>. Original intent was to be used only for block blobs in general-purpose V1 (GPv1) storage accounts. ZRS Classic <strong><u>asynchronously</u></strong> replicates data across data centers within one to two regions. The new <strong>v2</strong> instead, uses <strong><u>synchronous</u></strong> replication between all AZs in the region. Zone Redundant Storage (ZRS) synchronously replicates your data across three storage clusters in a single region. Each storage cluster is physically separated from the others and resides in its own availability zone (AZ). Each availability zone, and the ZRS cluster within it, is autonomous, with separate utilities and networking capabilities. Now that you are fully aware of the goodness of ZRS <strong>v2</strong>, you may be tempted to use it to host VM OS and/or Data disks. Since data replication is synchronous, then no data loss, in case of a zone disaster, you may want to mount the disks to another VM in another AZ. Unfortunately, ZRS <strong>v2</strong> does <em><u>*not*</u></em> support disk page blobs, as stated in the article below:
<p style="padding-left: 30px"><em><span style="color: #3366ff">ZRS currently supports standard, general-purpose v2 (GPv2) account types. ZRS is available for block blobs,</span> <span style="color: #ff0000">non-disk page blobs</span><span style="color: #3366ff">, files, tables, and queues.</span> </em></p>
<p style="padding-left: 30px"><strong><em>Zone-redundant storage (ZRS): Highly available Azure Storage applications</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy-zrs">https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy-zrs</a></p>
At this point, you may ask yourself which storage/disk options you should use for your zoned VMs. As I briefly introduced in the previous section, you need to use <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/managed-disks-overview"><strong>Managed Disks</strong></a> (MD).

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/13.jpg"><img width="494" height="278" class="aligncenter wp-image-2255" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/13.jpg" /></a>

Premium will give you higher performance with SSD based storage, guaranteed IOPS and bandwidth, while Standard will be a cheaper choice. If you create a MD in AZ(1), you will have the benefit of the three local copies, but always remember that MD does not replicate data beyond the local AZ(1). Once MD will be created in a certain zone, it will be <em><u>*not*</u></em> possible to mount to a VM located in another zone, compute and storage here must be aligned (<em>see error message below</em>):

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/14.jpg"><img width="716" height="197" class="aligncenter wp-image-2265" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/14.jpg" /></a>
<p style="padding-left: 390px"><span style="color: #3366ff">“<em>EmptyManagedDiskMD4 cannot be attached to the VM because it is not in the same zone as the VM</em>”</span></p>
Since you are going to use VMs in each zone with local disks, how would you replicate data? Since we are in the IaaS context, it is all dependent on the application that you will install inside the VMs. Once again, Azure does not replicate the VM data in this context (i.e. data stored in disks) across zones. The customer can have benefits from AZ if their application replicates data to different zones. For example, they can use <a href="https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server?view=sql-server-2017">SQL Server Always-On</a> Availability Group (AG) to host the primary replica (VM where data is written) in AZ(1) and then host secondary replicas in AZ(2), and a third one in AZ(3). SQL Always-On replicates the data from primary replica to the secondary replicas. If AZ(1) goes down, then SQL Server AG will automatically fail over to either AZ(2) or AZ(3). However, Azure automatically replicates the zone-redundant snapshots of Managed Disks. It ensures that snapshots are not affected by zone failure in a region. For example, if a snapshot is created on a disk in AZ(1) and it goes down, then the snapshot can be used to restore the VM in AZ(2) or AZ(3). Below are a couple of excellent articles to understand storage performances and replication strategies.
<p style="padding-left: 30px"><strong><em>Azure Storage replication</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy">https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy</a></p>
<p style="padding-left: 30px"><strong><em>Azure Storage Scalability and Performance Targets</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-scalability-targets">https://docs.microsoft.com/en-us/azure/storage/common/storage-scalability-targets</a></p>

<h2><strong>Where is my VM SKU in AZ? </strong></h2>
Not all the VM SKUs are available now for AZ zonal VM deployment, but this gap will be reduced over time and more options will be progressively available. I tried to find a central unique link, to list all SKUs availability per region and per zone, but did not find it at the moment, probably it would be too hard to manage. What you can use instead, is the Azure Portal page when creating a VM and specifying the SKU/size, or you can use the nice PowerShell cmdlet “<strong><em>Get-AzureRmComputeResourceSku</em></strong>” as shown below:
<p style="padding-left: 120px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Get-AzureRmComputeResourceSku</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>|</span><span style="color: #000000"> </span><span>where</span><span style="color: #000000"> {</span><span>$_</span><span>.</span><span style="color: #000000">Locations</span><span>.</span><span style="color: #000000">Contains(</span><span>"FranceCentral"</span><span style="color: #000000">) `</span></span></p>
<p style="padding-left: 120px"><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span><span style="color: #000000">                                 </span></span><span>-and</span><span style="color: #000000"> </span><span>$_</span><span>.</span><span style="color: #000000">ResourceType</span><span>.</span><span style="color: #000000">Equals(</span><span>"virtualMachines"</span><span style="color: #000000">) `</span></span></p>
<p style="padding-left: 120px"><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span><span style="color: #000000">                                 </span></span><span>-and</span><span style="color: #000000"> </span><span>$_</span><span>.</span><span style="color: #000000">LocationInfo</span><span>[</span><span>0</span><span>].</span><span style="color: #000000">Zones </span><span>-ne</span><span style="color: #000000"> </span><span>$null</span><span style="color: #000000"> } </span></span></p>
<a href="https://msdnshared.blob.core.windows.net/media/2018/05/15.jpg"><img width="1014" height="373" class="aligncenter wp-image-2275" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/15.jpg" /></a>

Pay attention to the column “<strong><em>Restriction</em></strong>”: as you can see in the print screen above, currently I don’t have provisioned capacity in that zone, in that region, for my subscription. If you want to list all regions and zones where your subscription can deploy VMs in AZ, you can use a slightly modified command:
<p style="padding-left: 120px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Get-AzureRmComputeResourceSku</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>|</span><span style="color: #000000"> </span><span>where</span><span style="color: #000000"> {</span><span>$_</span><span>.</span><span style="color: #000000">ResourceType</span><span>.</span><span style="color: #000000">Equals(</span><span>"virtualMachines"</span><span style="color: #000000">) `</span></span></p>
<p style="padding-left: 120px"><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span><span style="color: #000000">                                 </span></span><span>-and</span><span style="color: #000000"> </span><span>$_</span><span>.</span><span style="color: #000000">LocationInfo</span><span>[</span><span>0</span><span>].</span><span style="color: #000000">Zones </span><span>-ne</span><span style="color: #000000"> </span><span>$null</span><span style="color: #000000"> `</span></span></p>
<p style="padding-left: 120px"><span style="margin: 0px;line-height: 107%;font-family: 'Lucida Console';font-size: 9pt"><span><span style="color: #000000">                                 </span></span><span>-and</span><span style="color: #000000"> </span><span>$_</span><span>.</span><span style="color: #000000">Restrictions</span><span>.</span><span style="color: #000000">Count </span><span>-eq</span><span style="color: #000000"> </span><span>0</span><span style="color: #000000">}</span></span></p>
<span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px">If you encounter the same, you should open a Support Ticket through the Azure Portal and ask for a quota increase. Be sure to specify that you want this capacity in the AZ.  Using the Azure Portal is easy because based on your selection, available SKUs and zones will be specified for your convenience:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/16.jpg"><img width="756" height="514" class="aligncenter wp-image-2285" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/16.jpg" /></a>

It is worth noting that some SKUs maybe not available in all the zones, as you can see for GS SKU, available only in zones “2” and “3” but not in “1”, in the print screen above. If you scroll down the list, you will also find two additional sections: the first one will tell you for which SKUs your subscription is enabled but you don’t have enough quota, and the second one will provide information on SKU not available at all in the specific region and zone.
<h2><strong>How can I check Zone property for my VM? </strong></h2>
Azure Portal properties in the “<strong><em>Overview</em></strong>” pane:

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/17.jpg"><img width="506" height="239" class="aligncenter wp-image-2295" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/17.jpg" /></a>

In PowerShell is easy to find the zone property for the VM object and all the Managed Disks in a Resource Group, look at the examples below. For now, I don’t see any PowerShell cmdlet dedicated to Availability Zones.

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/18.jpg"><img width="938" height="114" class="aligncenter wp-image-2305" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/18.jpg" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/19.jpg"><img width="936" height="114" class="aligncenter wp-image-2315" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/19.jpg" /></a>

<strong><u>IMPORTANT</u></strong>: At the time of authoring this article, it seems that there is no way to change the zone where a VM is deployed or migrate a VM to make it “<em>zonal</em>”.
<h2><strong>How much AZ will cost? </strong></h2>
There is no direct cost associated to Availability Zones, but you will pay for network traffic as specified in the article below. There is a fee associated with data going into VM deployed in an AZ and data going out of VM deployed in an AZ.
<p style="padding-left: 30px"><strong><em>Bandwidth Pricing Details </em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/pricing/details/bandwidth">https://azure.microsoft.com/en-us/pricing/details/bandwidth</a></p>
NOTE: Availability Zones are generally available, but data transfer billing will start on July 1, 2018. Usage prior to July 1, 2018 will not be billed.
<h2><strong>Thank You!</strong></h2>
Simple Azure Portal guide, and step-by-step code sample in PowerShell are available at the links below:
<p style="padding-left: 30px"><strong><em>Create a Windows virtual machine in an availability zone with PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-powershell-availability-zone">https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-powershell-availability-zone</a></p>
<p style="padding-left: 30px"><strong><em>Create a Windows virtual machine in an availability zone with the Azure portal</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-portal-availability-zone">https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-portal-availability-zone</a></p>
Hope this content has been useful and interesting for you, let me know your feedbacks. You can always follow me on Twitter (<strong>@igorpag</strong>), enjoy with new Azure Availability Zones (AZ) feature!

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Why Azure Availability Zones</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/why-azure-availability-zones</link>
      <pubDate>Sun, 08 Oct 2017 04:49:11 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=1786</guid>
      <description><![CDATA[Working with several Microsoft ISVs around the world, I heard loud and clear about an important...]]></description>
      <content:encoded><![CDATA[Working with several Microsoft ISVs around the world, I heard loud and clear about an important missing capability from Azure: there was no way to be protected by an entire datacenter failure, and maintaining at the same time synchronous state replication for an application or service. The only option was to deploy in a different region, 100s of miles apart, with obviously no way to have zero RPO and synchronous data alignment. Before introducing new concepts, let me recap with this simple picture what are regions and geographies in the Azure infrastructure hierarchy:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/12.jpg"><img width="678" height="336" class="aligncenter wp-image-1795" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/12.jpg" /></a>

To fill this gap, Microsoft recently announced public preview of Azure<strong> Availability Zones (AZ)</strong>:
<p style="padding-left: 30px"><strong><em>Introducing Azure Availability Zones for resiliency and high availability</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/blog/introducing-azure-availability-zones-for-resiliency-and-high-availability">https://azure.microsoft.com/en-us/blog/introducing-azure-availability-zones-for-resiliency-and-high-availability</a></p>
<strong>Availability Zones (AZ)</strong> are fault-isolated locations, within an Azure region, providing redundant power, cooling, and networking. AZs allow your customers to run mission critical applications with high availability and fault tolerance to datacenter failures. Customers can now deploy VMs and single-zone or multi-zone <em>VMSS</em>, <em>Managed Disks</em>, <em>Public IPs</em>, and <em>Load Balancers,</em> initially in <em>East US 2</em> and <em>West Europe</em>, with 3 AZs each. More regions with 3 AZ support will come soon. It is worth noting that some other cloud providers with similar functionality, are not offering such high number of zones. With the addition of AZ, Microsoft is now able to present a unique combination of high-availability scenarios and HA SLAs:
<ul>
 	<li><strong>99,90%</strong> on <u>single instance</u> VMs with premium storage for an easier lift and shift; no other cloud provider so far provides this.</li>
 	<li><strong>99,95%</strong> VM uptime SLA for Availability Sets (AS) to protect for failures <u>within a datacenter</u>.</li>
 	<li><strong>99,99%</strong> VM uptime SLA <u>through Availability Zones </u>with loss protection from fire, power, cooling disruption.</li>
</ul>
Availability Zones and Availability Sets cannot be used together: when creating a Virtual Machine (VM), you will have to specify an AS, or AZ assignment, you cannot do both.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/211.png"><img width="359" height="247" class="aligncenter wp-image-1797" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/211.png" /></a>

The Azure Virtual Machine official HA SLA is available <a href="https://azure.microsoft.com/en-us/support/legal/sla/virtual-machines/v1_6/">here</a>, and will be updated with AZ once the feature will be finally released for general availability. Additionally, Azure paired regions within data residency boundaries, but hundreds of miles apart, can protect from larger scale events that may impact an entire region. In order to participate in the Availability Zones public preview, self-service enablement is available, per subscription, using this <a href="https://ms.portal.azure.com/#blade/Microsoft_Azure_Compute/EnableAvailabilityZonesBlade">link</a>.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/33.png"><img width="885" height="234" class="aligncenter wp-image-1805" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/33.png" /></a>

&nbsp;
<h2><strong>Available Services and Resources</strong></h2>
During this initial phase of the public preview, these resources are available to be pinned to specific AZs: <em>Virtual Machine (VM), VM Scale Sets (VMSS), Managed disks (MD), Virtual IP (VIP)</em>. In addition, there is also a new enhanced version of the Azure Load Balancer that is now zone-resilient. Since there is no Azure Service Management (ASM) API support planned, AZs cannot be used for legacy Cloud Services (Worker and Web roles). From a user perspective, Availability Zones are visible at IaaS level. It is here that you can choose to have control over your basic VM resources (compute, storage, networking). Regarding PaaS, Microsoft will progressively move main services to AZ, but this will be transparent for customers. One of the first service to be moved will be Azure SQLDB, and it makes perfect sense. Azure SQLDB is already architected to have a primary instance and two secondary instances (replicas), all participating into synchronous database replication with quorum voting, zero data loss and automatic failover. Imaging this architecture in 3 Availability Zones is immediate and intuitive.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/61.png"><img width="437" height="191" class="aligncenter wp-image-1826" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/61.png" /></a>

Regarding storage, Azure already has ZRS (<em>Zone Replicated Storage</em>), but is limited to block blob and does not fit in the actual AZ design and implementation. For this reason, it is going under redesign, and once available, will support page Blobs, Tables, Queues and Files. Additionally, each write to the storage, through a single logical endpoint, will be replicated synchronously across all the zones. This would mean zero data loss in case of a zone failure (RPO = 0) and automatic failover of reads towards the other zones.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/71.png"><img width="428" height="207" class="aligncenter wp-image-1836" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/71.png" /></a>

Going back to fundamental IaaS resources, here is the list of changes introduced to adapt to AZ:
<ul>
 	<li><strong>Virtual Machines (VM)</strong> - For a VM object, will be possible to specify a logical "<em>Zone"</em> property value, thus locating the VM in a datacenter supporting that specific AZ.</li>
 	<li><strong>Load Balancer (LB)</strong> - Azure Load Balancer now offers two SKUs, <em>Basic</em> and <em>Standard</em>. The Basic SKU is what you have always seen so far in Azure. The Standard SKU is a new enhancement and provides zone redundancy for even higher availability. You can now deploy a Standard Load Balancer that can distribute traffic <u>across</u> all VMs in <u>any AZ</u> in the region, actual scale limit is 1000 VMs. There are many additional advantages on using the new Standard SKU, see <a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-overview#why-use-load-balancer-standard">here</a> for more details.</li>
 	<li><strong>Virtual IP (VIP)</strong> - As for LB, now in Azure you can create Public IP using two SKUs, <em>Basic</em> and <em>Standard. </em>Basic is what you have used so far in Azure, while the new Standard SKU IP enables you to build highly scalable and reliable architectures, in conjunction with Standard SKU LB. This can be zone-redundant, or zonal. You can see below the differences (in order) in how to deploy using ARM templates:</li>
</ul>
<div style="padding-left: 60px">"apiVersion": "2017-08-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "public_ip_standard",
"location": "<span style="color: #ff0000">region</span>",
<span style="color: #ff0000"> "sku":</span>
<span style="color: #ff0000">            {  "name": "Standard" }</span></div>
<div style="padding-left: 60px"></div>
<div style="padding-left: 60px">"apiVersion": "2017-08-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "public_ip_standard",
"location": "<span style="color: #ff0000">region</span>",
<em><strong>      <span style="color: #339966">"zones": [ "1" ],</span></strong></em>
<span style="color: #ff0000">    "sku":</span>
<span style="color: #ff0000">            { "name": "Standard" }</span></div>
<ul>
 	<li><strong>VM Scale Set (VMSS)</strong> - Can be now deployed in two different flavors (<em>see picture below</em>). First one consists in 3 different Scale Sets deployed 1 in each zone as zonal resources, then load-balanced by a cross-zone resilient Load Balancer (Standard SKU). The second possibility (bottom part of the picture), instead, requires the creation of a single ScaleSet that is cross-region deployed and then resilient. This option will be soon available in preview, you can subscribe <a href="https://aka.ms/xzonevmss">here</a> if not already publicly available.</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/10/81.png"><img width="431" height="418" class="aligncenter wp-image-1846" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/81.png" /></a>
<ul>
 	<li><strong>Custom Images and Snapshots</strong> - You can now create VMs in AZ from a custom VM image, previously there was a limitation applied and only Azure Gallery images were permitted. Additionally, you can now take snapshots of VMs in an AZ. Snapshots are also global objects across all the zones in a region, now they are not "<em>zone-resilient</em>", work is in progress to fix it.</li>
</ul>
<em><strong><span style="color: #ff0000"><u>IMPORTANT</u>:</span></strong></em> Azure Virtual Networks (VNETs) and Subnets, are and will remain "<em>regional"</em> entities. Once you will define in a region, they will be visible and usable across all the AZ since Network Resource Manager in Azure is region-wide. There is no AZ specification for these objects, VNETs and Subnets can cross AZ.
<h2><strong>Tools and API</strong></h2>
At both the API and Portal levels, changes applied to include AZ are really minimal. In the <strong>Azure Portal</strong>, there is only one place where you will find AZ, that is <em>Step [3]</em> in the standard creation workflow:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/91.png"><img width="262" height="266" class="aligncenter wp-image-1855" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/91.png" /></a>

Be sure to select a Region <u>and</u> a VM SKU enabled for AZ, otherwise you will not see the edit-box above. See <a href="https://docs.microsoft.com/en-us/azure/availability-zones/az-overview">here</a> to check what and where is available. Before proceeding, give a look to the settings for the "<em>Public IP Address"</em>, it is interesting: there is a new IP SKU called "<em>Standard"</em>, as explained previously. The "<em>Basic</em>" type is the one used so far in Azure. For the Standard, you can see it has "<em>Availability Zone"</em> property but value is fixed, you cannot change, must be in the same zone as the compute resource. This type of IP is zoned (or zonal) and will not survive its home zone failure, not that bad since the VM will behave in the same way. On the other hand, if you want to, for example, unbind this VIP from a VM in Zone [1], and bind to a VM in a different zone, then you must use Standard SKU for the VIP. This kind of IP is zone resilient and valid across all zones, allocation method can be only static. Be careful since for the same VM you cannot mix different IP SKUs, must be same in case of additional IPs assigned.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/101.png"><img width="319" height="292" class="aligncenter wp-image-1865" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/101.png" /></a>

If you want to check details of the subnet and VNET that will be used or created, you will see that there is no "<em>Zone"</em> property: once again, these objects are region-wide, valid across all the zones and can include VMs from all the zones. There is no need, for example, to create separate subnets for different AZs. In the <strong>ARM template</strong> definitions, pay attention to the additional "<strong>zones"</strong> property: it is an array of strings, because potentially more than one AZ can be specified for a VMSS.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/115.png"><img width="687" height="369" class="aligncenter wp-image-1875" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/115.png" /></a>

For <strong>REST API</strong> usage, pay attention to the API version used when creating the VM, the Managed Disks, and the Public IP Address:
<ul>
 	<li><em>"type": "Microsoft.Compute/disks", "computeResouresApiVersion" : "<strong>2017-03-30</strong>"</em></li>
 	<li><em>"type": "Microsoft.Compute/virtualMachines", "computeResouresApiVersion" : "<strong>2017-03-30</strong>"</em></li>
 	<li><em>"type": "Microsoft.Network/publicIPAddresses", "apiVersion": "<strong>2017-08-01</strong>"</em></li>
</ul>
List of all the necessary REST APIs for ARM are reported below:
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/rest/api/virtualnetwork/PublicIPAddresses/CreateOrUpdate">Public IP Addresses - Create Or Update</a></li>
 	<li><a href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update">Create or update a virtual machine</a></li>
 	<li><a href="https://docs.microsoft.com/en-us/rest/api/compute/manageddisks/disks/disks-create-or-update">Create a Managed Disk</a></li>
</ul>
<p style="padding-left: 30px"><strong><u>NOTE</u></strong>: At the time of writing this post, REST documentation for VM and Managed Disks must still be fixed to include some details. This should be fixed soon.</p>
Availability Zones (AZ) are already available also in version 1.3 of the <strong><em>Azure Management Libraries for Java</em></strong>, you can find it <a href="https://azure.microsoft.com/en-us/blog/java-manage-availability-zones-and-more/">here</a> on GitHub.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/121.png"><img width="801" height="378" class="aligncenter wp-image-1885" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/121.png" /></a>

Availability Zones management has been included also in the v1.3 release of <strong><em>Azure Management Libraries for .NET</em></strong> that you can find at this <a href="https://azure.microsoft.com/en-us/blog/net-manage-availability-zones-and-more/">link</a>.

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/191.png"><img width="784" height="290" class="aligncenter wp-image-1945" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/191.png" /></a>

AZs support is also available using the <strong>Azure CLI tool</strong>: if you use Cloud Shell, no worry... you are already good to go. Instead, if you install Azure CLI tool locally, be sure to use version 2.0.17 or greater.
<p style="padding-left: 30px"><span style="color: #0000ff">az vm create --resource-group myResourceGroupVM --name myVM --image UbuntuLTS --generate-ssh-keys --zone 1</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">az network public-ip create --resource-group myResourceGroup --name myPublicIp --zone 1 --location westeurope</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">az vm disk attach -g myResourceGroup --vm-name myVM --disk myDataDisk --new --size-gb 50</span></p>
Please note that in the last command above, where a new Managed Disk is created, there is no possibility to specify any "<em>Zone"</em>: the disk is automatically created in the same zone as the VM.
<h2><strong>Step-by-Step Example using PowerShell</strong></h2>
<a href="https://github.com/igorpag/AzureAvailabilityZones">Here</a> on GitHub, you can find an easy example, using PowerShell, of how to deploy a Virtual Machine as "zonal" resource, along with a Public IP and a Managed Disk. Additionally, I will show you where the "Zones" attribute will show up, and how to use Snapshots to create/copy and attach Managed Disks in a different AZ. Finally, I will highlight some of the errors and mistakes that you could face trying your first approach. Do not run the entire script at once, it is structured in sections to drive you through the creation process, do it in steps and read before executing.

For PowerShell, AZ support is included starting with version 4.4.0. Make sure that you have installed the latest Azure PowerShell module. If you need to install or upgrade, see <a href="https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps">Install Azure PowerShell module</a>. These are the specific modules versions that you need to have:
<ul>
 	<li>3.4.0   AzureRM.Compute  Microsoft Corporation 3.0</li>
 	<li>4.4.0   AzureRM.Network  Microsoft Corporation 3.0</li>
 	<li>3.4.0   AzureRM.Storage  Microsoft Corporation 3.0</li>
</ul>
I tried to explore all my well-known cmdlets, but I was not able to find any one to check if a region is enabled for Availability Zone, and if yes, which are the available zones. I will keep searching, please let me know if you will find it before me. If you will select an Azure region where AZ are not enabled, or you will use an incorrect value, PowerShell commands will return error messages like the one below:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/131.png"><img width="693" height="242" class="aligncenter wp-image-1895" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/131.png" /></a>

To show the "<em>Zones"</em> property of a Managed Disk, let's try to resize the disk. This is the output you will obtain at the end (<em>truncated</em>):

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/141.png"><img width="653" height="138" class="aligncenter wp-image-1905" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/141.png" /></a>

In the code sample used, if you look at the section where a Snapshot of the Managed Disk is created, you will see that there is no way, in the used cmdlets, to specify any value for "<em>Zones"</em> attribute: Snapshots are region-wide objects, then valid across all regions. In the main VM object creation step, please note the absence of Availability Set (AS): if you want to use AZ, you cannot include that VM into AS at the same time. If the "<em>Zones"</em> property value will be <strong>*not*</strong> aligned for VM, Managed Disk and IP, then you will receive a similar error:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/151.png"><img width="719" height="273" class="aligncenter wp-image-1915" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/151.png" /></a>

If the VM SKU used is not one in the supported list for the AZ, you will receive an error like the one below:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/161.png"><img width="789" height="128" class="aligncenter wp-image-1916" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/161.png" /></a>

&nbsp;

If you try to attach a Managed Disk located in a zone different from the one where the VM resides, you will have this error:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/171.png"><img width="698" height="188" class="aligncenter wp-image-1926" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/171.png" /></a>

Finally, with cmdlet "<em><strong>Get-AzureRmVM</strong></em>" you can now see the "<em>Zone"</em> attribute value listed along with the other VM properties:

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/181.png"><img width="718" height="65" class="aligncenter wp-image-1927" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/181.png" /></a>
<h2><strong>Thank You!</strong></h2>
Hope this content has been useful and interesting for you, let me know your feedbacks.

You can always follow me on Twitter <span style="color: #0000ff">(<strong>@igorpag</strong></span>), enjoy with new Azure Availability Zones (AZ) feature!
<h2><strong>Resources</strong></h2>
<strong><em>Overview of Availability Zones in Azure (Preview)</em></strong>

<a href="https://docs.microsoft.com/en-us/azure/availability-zones/az-overview">https://docs.microsoft.com/en-us/azure/availability-zones/az-overview</a>

&nbsp;

<strong><em>Regions and availability for virtual machines in Azure</em></strong>

<a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/regions-and-availability">https://docs.microsoft.com/en-us/azure/virtual-machines/windows/regions-and-availability</a>

&nbsp;

<strong><em>Azure Load Balancer Standard overview (Preview)</em></strong>

<a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-overview#why-use-load-balancer-standard">https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-overview#why-use-load-balancer-standard</a>

&nbsp;

<strong>Very simple deployment of a VM in an Availability Zone</strong>

<a href="https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-simple-zones">https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-simple-zones</a>

&nbsp;

<strong>Create Multiple Virtual Machines in Different Availability Zones and Configure NAT Rules through the Standard Load balancer</strong>

<a href="https://github.com/wkasdorp/azure-quickstart-templates/tree/master/201-multi-vm-lb-zones">https://github.com/wkasdorp/azure-quickstart-templates/tree/master/201-multi-vm-lb-zones</a>

&nbsp;

<strong>Simple deployment of a VM Scale Set of Linux VMs within an Availability Zone behind a load balancer with NAT rules</strong>

<a href="https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-linux-nat-zones">https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-linux-nat-zones</a>

&nbsp;

<strong>Virtual Machine ScaleSet distributed across Availability Zones with Load Balancer</strong>

<a href="https://github.com/Azure/azure-quickstart-templates/tree/master/301-multi-vmss-linux-lb-zones">https://github.com/Azure/azure-quickstart-templates/tree/master/301-multi-vmss-linux-lb-zones</a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Azure SQL Data Sync Test Drive and First Impressions</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/azure-sql-data-sync-test-drive-and-first-impressions</link>
      <pubDate>Thu, 06 Jul 2017 13:23:48 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=1555</guid>
      <description><![CDATA[Azure SQL Data Sync is a service of Azure SQL Database that enables you to synchronize relational...]]></description>
      <content:encoded><![CDATA[<strong><em>Azure SQL Data Sync</em></strong> is a service of Azure SQL Database that enables you to synchronize relational data you select across multiple cloud databases and SQL Server instances, in uni-directional or bi-directional way. This service is already in public preview, then you don't need to enable, it is already here but you will pay for the databases you will create. Version covered in this post is 2.0, last important refresh of previous long incubated V1 version. The reason I decided to test this feature, and that's why is attractive for me, is that in the Microsoft SQL Server universe, both on-premises and cloud, there is no multi-master concept: doesn't matter how many SQL Server database cluster nodes, replicas, Availability Group instances you have, you still have to write data to a single instance that is your master. There is only one exception using SQL Server box product, that is Data Replication feature, using <a href="https://technet.microsoft.com/en-us/library/ms151329(v=sql.105).aspx">Merge</a> or <a href="https://docs.microsoft.com/en-us/sql/relational-databases/replication/transactional/peer-to-peer-transactional-replication">Peer-to-Peer</a> topologies. In these limited cases, you can submit your transactions to different multiple writable masters that will (slowly) replicate data each other. It is important to understand that all these technologies, including <strong>Azure SQL Data Sync</strong>, <strong><em><u>do not</u></em></strong> provide strong consistency, they <strong><em><u>do not</u></em></strong> provide distributed synchronous transactions between multiple writable masters. Instead, data replication is asynchronous, will have some latency, it does not follow original transaction order, conflicts may happen, and application must be able to tolerate this or designed to work with it.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/11.png"><img width="883" height="436" class="aligncenter size-full wp-image-1556" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/11.png" /></a>

Then, in which scenarios <strong>Azure SQL Data Sync</strong> would be useful? Whenever you need to replicate or synchronize data between different Azure SQL databases and SQL Server data sources, requiring multiple writable masters, where application does not rely on strong consistency and synchronous replication, you may want to consider this feature. Distributing data across regions and/or environments, for example in different Azure datacenters, or between on-premises and the cloud, are also valid scenarios. Reference data like list of customers, product catalogs and object directories are good real examples. Conversely, <strong>Azure SQL Data Sync</strong> is not appropriate if your application requires strong data consistency, is not appropriate to replicate a multi-terabyte OLTP database with millions of transactions per second, is not appropriate to build disaster recovery architectures, or to support migrations.
<h1><strong><u>Limitations</u></strong></h1>
Currently, this feature comes with some limitations you need to be aware, full details are reported in the article below, I reported here the main ones for your convenience:
<p style="padding-left: 30px"><strong><em>Sync data across multiple cloud and on-premises databases with SQL Data Sync</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-sync-data">https://docs.microsoft.com/en-us/azure/sql-database/sql-database-sync-data</a></p>
&nbsp;
<ul>
 	<li><strong><em>Replication time</em></strong>: there is no SLA on replication latency.</li>
 	<li><strong>Limitations on service and database dimensions</strong>: max number of endpoints in a single sync group is 30, max 500 tables in a Sync Group, max 100 columns per table, max row size is 24MB, maximum replication frequency is 5 minutes.</li>
 	<li><strong><em>Performance Impact</em></strong>: Data Sync uses insert, update, and delete triggers to track changes. It creates side tables in the user database. These activities have an impact on your database workload, so assess your service tier and upgrade if needed.</li>
 	<li><strong><em>Eventual Consistency</em></strong>: since Data Sync is async, transactional consistency is not guaranteed. Microsoft guarantees that all changes are made eventually, and that Data Sync does not cause data loss.</li>
 	<li><strong><em>Unsupported data types</em></strong>: FileStream, SQL/CLR UDT, XMLSchemaCollection (XML supported), Cursor, Timestamp, HierarchyID.</li>
</ul>
Since this feature is still under development, additional capabilities will be available in the near future, top desired ones from my test are:
<ul>
 	<li>Higher sync frequency, less than actual 5 minutes.</li>
 	<li>Automatic management of table schema changes.</li>
 	<li>Custom script (or procedures) to manage data synchronization conflicts.</li>
 	<li>Include a graphical map, in the "<strong><em>Sync to other databases"</em></strong> page in the Azure Portal, reporting the Members and Hub in the "<strong><em>Sync Group"</em></strong>, healthy status and some replication performance numbers.</li>
</ul>
<h1><strong><u>Overview </u></strong></h1>
Before starting my drive test, we first need to introduce the basic concept of "<strong><em>Sync Group"</em></strong>, better to start with a nice picture:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/21.png"><img width="624" height="308" class="aligncenter size-full wp-image-1565" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/21.png" /></a>

"<strong><em>Sync Group"</em></strong> is a logical object that describe your synchronization topology, then including the list of your databases and tables, and common settings that are shared across all members in the group. Replication path follow a "<em>Hub &amp; Spoke"</em> model where each "S<em>poke"</em> (Member) synchronize separately with the "<em>Hub"</em>. Now let's go through a complete end-to-end provisioning experience, explaining details in each step.

First artifact you need to create is a kind of configuration database called "<strong><em>Sync Metadata Database"</em></strong>: it will contain all necessary metadata to maintain your "<strong><em>Sync Group</em></strong>" (can be used for more than one), for a specific subscription, in a specific region. When enabling database sync, if not existing, you will be asked to create a new one. Microsoft recommends that you create a new, empty database to use: setup creates tables in this database and runs a frequent workload, there is no minimum recommendation for the service tier and size, but you need to be careful especially if you will use the same one for many databases and "<strong><em>Sync Group</em></strong>".

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/31.png"><img width="894" height="501" class="aligncenter wp-image-1566" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/31.png" /></a>

<u>NOTE</u>: As you can see, support in the old Azure Portal has been just retired from<em> July 1<sup>st,</sup> 2017</em>. If you have older version of Azure SQL Data Sync, please refer to the article below for migration as soon possible.
<p style="padding-left: 30px"><strong><em>Migrating to Azure SQL Data Sync 2.0</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/blog/migrating-to-azure-data-sync-2-0">https://azure.microsoft.com/en-us/blog/migrating-to-azure-data-sync-2-0</a></p>
The way you access this feature is clearly telling you that Azure SQLDB is the central hub, you can also have "<i>S</i><em>poke"</em> from on-premises, SQL Server installed in Azure VMs (or from other Cloud providers) or other Azure SQL DB databases. Then, to start you need to open the new Azure Portal and point to one of your Azure SQL DB database, then click on "<strong><em>Sync to other databases</em></strong>": as you can see in the picture above, if there is no existing "<strong><em>Sync Group</em></strong>", you will be asked to create a new one.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/41.png"><img width="874" height="379" class="aligncenter wp-image-1575" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/41.png" /></a>

In the first blade of the procedure, there are the most important settings for your new "<strong><em>Sync Group"</em></strong>:
<ul>
 	<li>"<strong><em>Sync Metadata Database</em></strong>": as explained before, you can create brand new or re-use an existing one in the same region. For convenience, and since this is a test, I will use the same Azure SQL DB database also for the "<em>Hub</em>" These are the requirements for the Sync database:
<ul>
 	<li>Azure SQL Database of any service tier</li>
 	<li>Same region as the "<em>Hub"</em> database of a "<strong><em>Sync Group</em></strong>"</li>
 	<li>Same subscription as "<strong><em>Sync Group</em></strong>"</li>
 	<li><u>One per region</u> in which you have a "<strong><em>Sync Group</em></strong>" ("<em>Hub"</em> Database)</li>
</ul>
</li>
 	<li>"<strong>Automatic Sync</strong>": you can decide here if you want automatic system initiated data sync activity, or if you prefer manual triggering instead. In the former case, you will need to select a schedule, and then a frequency; in the latter case instead, you will need to use API to start the synchronization on-demand. It is worth noting that the maximum frequency you can set is <u>5 minutes</u>, but the UI is showing you the possibility to select "<strong><em>Seconds</em></strong>" unit measure. I can only guess here that in the future more frequent syncs will be possible.</li>
 	<li>"<strong>Conflict Resolution</strong>": this is very important because will determine which data update your application can afford to lose in case of conflict: which update you want to discard if, <u>inside the same sync cycle</u>, the same record (determined by table Primary Key) is updated on both the "<em>Hub</em>" and the "<em>Member</em>"? Please note that this parameter is at the entire "<strong><em>Sync Group</em></strong>" level and cannot be changed without destroying and re-creating the entire structure.</li>
</ul>
If you are asking about custom script, or stored procedure, to resolve replication conflict, as happens in SQL Server Replication feature, then the answer is NO: at the moment, this is not possible, but it has been asked already to the owning Product Group, then stay tuned.

Now, let us move to the second step, as you can see in the picture below. First, you can add "<em>Members</em>" database from other subscriptions (and logical servers) but must be under the same Azure Active Directory (AAD) tenant, then also from other regions if you want. Second, the interface here does not allow you to create new empty databases on the fly, you have to have already created them.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/41.png"><img width="830" height="360" class="aligncenter wp-image-1575" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/41.png" /></a>

Third, and probably most important, what here is called "<strong>Sync Directions</strong>": remember, the data synchronization architecture and scheme here is "<em>Hub &amp; Spokes</em>", and is directional, then you need to decide how data will spread inside the "<strong><em>Sync Group</em></strong>". It is important to keep in mind that synchronization tasks happen separately, and in parallel, for each pair formed by "<em>Hub</em>" and "<em>Member</em>" databases. Direct consequence is that you cannot assume the order by which each "<em>Member"</em> will be updated. In case of bi-directional replication, first data is downloaded from the Hub, then data is uploaded from the member to the hub.

<strong><u>IMPORTANT</u></strong>: A single database can be a "<em>Member"</em> in different "<strong><em>Sync Group</em></strong>", but in this case, you need to pay attention and avoid creating circular references as shown in the picture below. Currently Azure SQL Data Sync does <strong>*not* </strong>automatically manage this, and then you may end up in an infinite replication loop that will never terminate.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/61.png"><img width="281" height="206" class="aligncenter wp-image-1576" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/61.png" /></a>
<h1><strong><u>Adding On-Premises Members</u></strong></h1>
Procedure to add a SQL Server instance and databases, from on-premises or from a VM in Azure, is almost identical from an Azure SQL Data Sync perspective: you have to download an agent, called "<strong><em>Sync Agent Gateway"</em></strong>, and install inside the network environment. While is possible to install the agent locally on the SQL Server box, it is not recommended for two reasons: first, you may not want to install something directly on the production machine: secondly, the agent is not cluster-aware then if using SQL Server Failover Cluster Instance (FCI), it is not supported nor will work in case of node failure. SQL Server 2005 SP2 and higher versions are supported.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/8.png"><img width="757" height="416" class="aligncenter wp-image-1595" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/8.png" /></a>

Regarding the connectivity and security, <u>is the agent</u> that will initiate the <u>outbound</u> connection to the Azure SQLDB "Hub" and "<em>Metadata Sync"</em> databases, then there is no need to open firewall port <u>TCP 1433</u> to allow inbound traffic to your protected network. Now, you can copy the URL to download the agent and use it to download and install locally to your network (or Azure Virtual Network). It is worth remembering that inside Azure VNET, by default a Virtual Machine has full open outbound connectivity to the Internet: if you plan to use <em>Network Security Groups (NSG)</em> to restrict, please be aware of this port requirement.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/91.png"><img width="676" height="248" class="aligncenter wp-image-1605" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/91.png" /></a>
<p style="padding-left: 180px"><strong><em>SQL Azure Data Sync Agent </em></strong></p>
<p style="padding-left: 180px"><a href="https://www.microsoft.com/en-us/download/details.aspx?id=27693">https://www.microsoft.com/en-us/download/details.aspx?id=27693</a></p>
<p style="padding-left: 180px"><a href="https://msdnshared.blob.core.windows.net/media/2017/07/10.png"><img width="526" height="103" class="wp-image-1606 alignleft" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/10.png" /></a></p>
&nbsp;

&nbsp;

&nbsp;

Be aware of the following pre-requisites before installing the agent, and please note that the 32bit version is explicitly required. In this case, installation order matters also.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/111.png"><img width="458" height="226" class="aligncenter wp-image-1615" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/111.png" /></a>

Once installed you must run the configuration tool before being able to use it: provide the key generated in the Azure Portal, then supply the credentials to access the <strong>Sync Metadata Database</strong>.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/12.png"><img width="395" height="321" class="aligncenter wp-image-1625" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/12.png" /></a>

Once registered the SQL Server instance and database, using either SQL Authentication or Windows Integrated, you should see something like the picture below. You can test the connection to the Azure SQLDB hub, to the local SQL Server instance, you can change the Agent Key and upgrade eventually the agent version. You can use the same agent to sync multiple SQL Server local instances.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/13.png"><img width="406" height="322" class="aligncenter wp-image-1626" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/13.png" /></a>

Finally, you can go back to the Azure Portal and complete the member database configuration.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/14.png"><img width="622" height="213" class="aligncenter wp-image-1635" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/14.png" /></a>
<h1><strong><u>My Test Configuration</u></strong></h1>
At the end, the <strong><em>Sync Group</em></strong> configuration I created is reported below:
<ul>
 	<li><strong>Hub</strong>
<ul>
 	<li>Logical Azure SQLDB server <strong><em>igor-sqlsrv1</em></strong> in West Europe, hub database name is <strong><em>igor-synchub-we</em></strong>, created in <strong><em>Subscription1</em></strong>.</li>
</ul>
</li>
 	<li><strong>Members </strong>
<ul>
 	<li>Logical Azure SQLDB server <strong><em>igor-sqlsrv1</em></strong> is in West Europe, member database name <strong><em>igor-sqldb1</em></strong>, created in <strong><em>Subscription1</em></strong>.</li>
 	<li>Logical Azure SQLDB server <strong><em>igor-sqlsrv2</em></strong> is in North Europe, member database name <strong><em>igor-sqldb2</em></strong>, created in <strong><em>Subscription1</em></strong></li>
 	<li>Logical Azure SQLDB server <strong><em>igor-sqlsrv3</em></strong> is in West Europe, member database name <strong><em>igor-sqldb3</em></strong>, created in <strong><em>Subscription2</em></strong></li>
 	<li><strong><em>igor-sql2016vm1</em></strong> is a VM with SQL Server 2016 installed in West Europe, member database name is <strong><em>igor-sqldb4</em></strong>, created in <strong><em>Subscription1</em></strong></li>
</ul>
</li>
 	<li><strong>Conflict Detection</strong>: <em>Hub wins</em></li>
 	<li><strong>Data Directions &amp; Conflict Detection</strong>
<ul>
 	<li><em>Bi-directional Sync</em> for member database <strong><em>igor-sqldb1</em></strong></li>
 	<li><em>From the Hub</em> for member database <strong><em>igor-sqldb2</em></strong></li>
 	<li><em>To the he Hub</em> for member database <strong><em>igor-sqldb3</em></strong></li>
 	<li><em>From the Hub</em> for member database <strong><em>igor-sqldb4</em></strong></li>
</ul>
</li>
</ul>
Here is the picture from the Azure Portal related to the member list:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/15.png"><img width="248" height="378" class="aligncenter wp-image-1646" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/15.png" /></a>

<strong><u>Enable Data Replication</u></strong>

Now is finally arrived the time to select which tables to include in our <strong><em>Sync Group</em></strong> replication topology. You can start clicking on the big <strong><em>Tables</em></strong> icon in the Azure Portal:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/16.png"><img width="585" height="175" class="aligncenter wp-image-1655" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/16.png" /></a>

Depending on the replication direction, initial database to choose for selecting table may vary, in this case let us proceed from the <strong><em>Hub Database</em></strong> where I created a simple table called <strong><em>Table1</em></strong>. In order to be considered as a valid selection, a table <strong>*must* </strong>have a <strong><em>Primary Key</em></strong> (PK), this is required to locate changed items and manage conflicts. I also created another table called <strong><em>Table2</em></strong> but as you can see, is not suitable for Azure SQL Data Sync replica since does not contain a PK. You are allowed to select specific columns you want to replicate, by default everything is selected, PK <strong>*must*</strong> be included.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/17.png"><img width="444" height="238" class="aligncenter wp-image-1657" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/17.png" /></a>

<u>NOTE</u>: I tried to find a way to horizontally select the rows to sync, but apparently there is no way to include a WHERE filter or insert a custom SELECT to specify which rows to include in the mechanism. I also tried to create a VIEW with a WHERE clause on the base table, but the GUI interface did not allow me to select.

Finally, with at least one table added into the <strong><em>Sync Group</em></strong>, data flow is now active.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/18.png"><img width="567" height="329" class="aligncenter wp-image-1666" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/18.png" /></a>

Once confirmed the tables that you want to include, <strong><em>Azure SQL Data Sync</em></strong> will do immediately create the database tables in <strong>*all*</strong> database <strong><em>Members</em></strong>, <u>if not existing already</u> (<em>see later for more details</em>) despite the replication direction you selected. For example, for member database <strong>igor-sqldb3</strong>, as you can read in the configuration section above, I selected <strong><em>To the he Hub</em></strong>, then from the <strong><em>Member</em></strong> upward, but the table has been created also here. What is important noting is that only the schema has been replicated, no data has been pulled down from the <strong><em>Hub</em></strong> database.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/19.png"><img width="440" height="290" class="aligncenter wp-image-1676" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/19.png" /></a>

Once schema is applied to all <strong><em>Member</em></strong> databases, you will see that the button <strong><em>Sync</em></strong> is enabled: data replication will happen based on the frequency you specified, and that can be changed in the <strong><em>Sync Group</em></strong> properties, but you can always force manual start if desired. This operation can be obviously also invoked using REST API and future PowerShell module.
<h1><strong><u>Schema Changes</u></strong></h1>
At this point, would be interesting to understand if this mechanism is tolerant to schema changes of the tables included in the <strong><em>Sync Group</em></strong>. Let us try to add, for example, a new (<em>NULL-able</em>) column named <strong><em>Value2</em></strong> to <strong><em>Table1</em></strong>, insert a new row, fix (<em>NULL</em>) values with new default:
<p style="padding-left: 30px"><span style="color: #0000ff">USE [igor-synchub-we]</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">GO</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">ALTER TABLE [dbo].[Table1] ADD [Value2] BIGINT DEFAULT (0)</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">GO</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">INSERT [dbo].[Table1] VALUES (2,'Added Column 2',0)</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">GO</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">UPDATE [dbo].[Table1] SET [Value2] = 0 WHERE [Value2] IS NULL</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">GO</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">SELECT * FROM [dbo].[Table1]</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">GO</span></p>
Looking to the logs in the Azure Portal, this modification has been safely processed, two changes in rows have been detected:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/20.png"><img width="610" height="162" class="aligncenter wp-image-1685" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/20.png" /></a>

Looking to all Member databases, row changes are replicated (<em>Download: 2 changes applied</em>) but now the schema change, all the existing rows <strong><u>do not have</u></strong> the additional column we introduced, but the mechanism continue to work without errors. My experiment is not finished yet, let us try to introduce the schema change using the Azure Portal interface and see what will happen:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/211.png"><img width="554" height="200" class="aligncenter wp-image-1695" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/211.png" /></a>

Apparently, the operation is succeeded, but looking at the error log, several error messages raised:
<p style="padding-left: 30px"><span style="color: #0000ff"><em>Database re-provisioning failed with the exception SqlException Error Code: -2146232060 - SqlError Number:207, Message: Invalid column name 'Value2'. SqlError Number:207, Message: Invalid column name 'Value2'. For more information, provide tracing ID </em><em>â€˜d94e2fcf-eed2-4f92-8ae3-88721d956cc1</em><em>â€™ to customer support.</em></span></p>
Ok, schema modification will not be <em>propagated</em> by the <strong><em>Azure SQL Data Sync</em></strong>, then the only remaining option is to remove the table from the <strong><em>Sync Group</em></strong>, apply the schema change to all <strong><em>Members</em></strong>, then adding back the table, including the additional new column. Please remember that this feature is still in preview.

Regarding error log, in the main blade for <strong><em>Data Sync Group</em></strong>, there is no way to select or download error messages, you should use general Azure Activity Log to achieve this task:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/221.png"><img width="594" height="254" class="aligncenter wp-image-1706" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/221.png" /></a>

Finally, what happens if a table with the same name exists already, in the <strong><em>Member</em></strong> target database, when included in the sync set? In this case, synchronization mechanism will <strong>*not*</strong> overwrite it, but will apply necessary changes, for example will create TRIGGERS to manage data replication. This is powerful since you may want to customize the table structure with additional columns, constraints, indexes or triggers: be careful because you have this flexibility, but these changes must not interfere with the synchronization logic. During my tests, I verified that TRIGGER, FOREIGN KEY and CHECK constraints are not replicated downstream to the other databases in the <strong><em>Sync Group</em></strong>, then if you want or need them, you have to modify the target DBs manually.
<h1><strong><u>Database Internals</u></strong></h1>
<strong><em>Azure SQL Data Sync</em></strong> modifies the schema of your database adding object schemas, tables, triggers and stored procedures. This is very important to consider before enabling this mechanism because will alter your database structure and may conflict with your application. Let us take a small journey inside these modifications.

If you have minimal SQL Server experience, you can look very easily at the tables created by <strong><em>Azure SQL Data Sync</em></strong> setup inside the <strong><em>Hub Database</em></strong>, under the new <strong><em>dss</em></strong> and <strong><em>TaskHosting</em></strong> objects schemas. Obviously, you can look and do your read-only queries, but you should not alter in any way any content of these tables, otherwise you may destroy your <strong><em>Sync Group</em></strong>.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/23.png"><img width="748" height="278" class="aligncenter wp-image-1715" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/23.png" /></a>

If you try to do the same inspection on the <strong><em>Member</em></strong> databases, you will see similar tables added to support data synchronization, but a different smaller set under <strong><em>DataSync</em></strong> schema, you can observe in the red rectangle below.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/24.png"><img width="255" height="234" class="aligncenter wp-image-1725" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/24.png" /></a>

Those tables are always present, but the <strong><em>DataSync.Table1_dss_tracking</em></strong> is special: this kind of <em>shadow</em> table is created for every user table (in this case <strong><em>Table1</em></strong>) enabled for data sync, purpose is to accumulate changes in the rows of the original table. How this table is populated with data? If you give a look to the structure of <strong><em>Table1</em></strong> and dependencies, you will discover this:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/25.png"><img width="458" height="329" class="aligncenter wp-image-1735" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/25.png" /></a>

There are <strong><em>stored procedures</em></strong> defined for DELETE, INSERT and UPDATE and bulk-logged versions, and there are <strong><em>triggers</em></strong> (<em>after-trigger type</em>) defined for DELETE, INSERT and UPDATE operations. If you examine the code for INSERT trigger <strong><em>Table1_dss_insert_trigger</em></strong> you will see that the core is a T-SQL MERGE statement that will detect inserted row, then will <em>upsert</em> data in the shadow table <strong><em>[DataSync].[Table1_dss_tracking]</em></strong>:

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/26.png"><img width="554" height="220" class="aligncenter wp-image-1745" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/26.png" /></a>

The INSERT clause is very interesting: as you can see above, the shadow table is <strong><em>*not* </em></strong>accumulating the entire row (all column values), but only the Primary Key (PK) along with some metadata information, including timestamp of the last modification. If you are a DBA, you will recognize here something similar to <strong><em>Change Tracking</em></strong>, not really <strong><em>Change Data Capture</em></strong>, well known SQL Server box product features. The tracking records will not be deleted immediately. Tracking records for deleted rows will be removed after a retention period of 45 days. There are optimizations that can avoid using the tracking tables during initial sync, after the initial sync all the changes are going to be tracked in the tracking tables. Index fragmentation may happen, you can refer to <a href="https://docs.microsoft.com/en-us/sql/relational-databases/indexes/reorganize-and-rebuild-indexes">this</a> article to reorganize the index. It is worth noting that in case of multiple updates to the same row, there will be only one record in the shadow table including the PK and timestamp of the latest update.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/27.png"><img width="259" height="194" class="aligncenter wp-image-1755" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/27.png" /></a>

Finally, table <strong><em>[dss].[configuration]</em></strong> is very interesting since it contains main configuration parameters for the current <strong><em>Data Sync Group</em></strong>. I found very interesting, in the <strong>Hub Database</strong>, the table <strong><em>[dss].[configuration]</em></strong>, specifically parameter <strong><em>SqlSyncProviderBatchSizeInMB</em></strong> with value (24): it seems that <strong><em>Azure SQL Data Sync</em></strong> max batch size is 24MB and max 50,000 rows per batch, when applying data modifications to synched tables.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/28.png"><img width="616" height="298" class="aligncenter wp-image-1765" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/28.png" /></a>

What I expected to find here is something indicating how long a database can be <em>disconnected</em> before being marked ad <em>offline</em>, that is not synchronized anymore. I do not see in the list above, but downloading the full documentation in PDF format from <a href="https://docs.microsoft.com/pdfstore/en-us/Azure.azure-documents/live/sql-database.pdf">here</a>, I found that the limit is <strong>45 days</strong>:
<p style="padding-left: 30px"><span style="color: #0000ff"><em>SQL Data Sync (Preview) removes databases that have been offline 45 days or more (as counted from the time the database went offline) from the service. If a database is offline for 45 days or more and then comes back online its status is set to Out-of-Date. </em></span></p>
What is totally missing also from the online documentation, at the moment, is more details on the retry mechanism and how long it will last.
<h1><strong><u>Programmability</u></strong></h1>
Today, you can play with <strong><em>Azure SQL Data Sync </em></strong>using the new Azure Portal interface. You can find the REST API specifications at the link below; PowerShell support is coming soon and will be available for the general availability of this feature.

<strong><em>Download the SQL Data Sync REST API documentation</em></strong>
<p style="padding-left: 30px"><a href="https://github.com/Microsoft/sql-server-samples/raw/master/samples/features/sql-data-sync/Data_Sync_Preview_full_documentation.pdf?raw=true">https://github.com/Microsoft/sql-server-samples/raw/master/samples/features/sql-data-sync/Data_Sync_Preview_full_documentation.pdf?raw=true</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/07/29.png"><img width="513" height="371" class="aligncenter wp-image-1775" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/07/29.png" /></a>
<h1><strong><u>Final Remarks</u></strong></h1>
For the latest announcement on <strong><em>Azure SQL Data Sync</em></strong>, see the blog post below, more will come when Product Group team will announce general availability:
<p style="padding-left: 30px"><strong><em>Azure SQL Data Sync Refresh</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/blog/azure-sql-data-sync-refresh">https://azure.microsoft.com/en-us/blog/azure-sql-data-sync-refresh</a></p>
Regarding pricing, it has not disclosed yet, but you will pay for sure for all your databases, including <strong><em>Sync Metadata Database</em></strong> and <strong><em>Hub Database</em></strong>, depending on the service tier you selected. If replicating data across Azure regions, you will be charged for this traffic. If you have also on-premises members, only egress traffic exiting from Azure will be counted, igress traffic will not.

Full <strong><em>Azure SQL Data Sync</em></strong> documentation can be downloaded from <a href="https://github.com/Microsoft/sql-server-samples/raw/master/samples/features/sql-data-sync/Data_Sync_Preview_full_documentation.pdf?raw=true">here</a> in PDF format.

If you want to post feedbacks and ideas for this feature, you can use the link below, Product Group will look at it and post a response.
<p style="padding-left: 30px"><strong><em>How can we improve SQL Data Sync?</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217535-sql-data-sync">https://feedback.azure.com/forums/217535-sql-data-sync</a></p>
Thanks for your patience, hope you appreciated this content.

You can follow me on Twitter using <strong><em>@igorpag</em></strong>.

Regards.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Using PowerShell as an Azure ARM REST API Client</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/using-powershell-as-an-azure-arm-rest-api-client</link>
      <pubDate>Wed, 28 Jun 2017 14:14:37 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=1255</guid>
      <description><![CDATA[Yes, this is probably another post explaining how to use Azure ARM REST API using PowerShell, I am...]]></description>
      <content:encoded><![CDATA[Yes, this is probably another post explaining how to use Azure ARM REST API using PowerShell, I am aware of this, but what I would like to show you is something deeper in the Azure platform that you may not have noticed or seen before. Fortunately, Microsoft provides many SDKs for almost all your favorite languages, then how the platform works at the lower level, from an API perspective at least, is almost entirely managed for you and then invisible. I am assuming here you are using Azure Resource Manager (ARM) API, Azure Service Management (ASM) API are not recommended today since obsolete and not interested by platform new features development.
<h1><strong><u>Introduction and Goals</u></strong></h1>
Just mentioned above that there are already several tools available on the Internet that will permit you to use ARM REST API directly and making web requests, let me list here first the most popular and my favorites:
<ul>
 	<li><strong>Postman</strong>: you can download from <a href="https://www.getpostman.com">here</a> versions for Windows, Linux, MacOS and as a Chrome extension. Nice tool, available in free basic version and pro paid. powerful GUI platform to make your API development faster &amp; easier, from building API requests through testing, documentation and sharing.</li>
 	<li><strong>HTTP Master</strong>: grab your free basic or professional paid version from <a href="https://httpmaster.net/">here</a>. in addition to basic features, it provides almost complete coverage for development and testing of API applications and services, including HTTP tool to simulate client acitivity.</li>
 	<li><strong>ARM Client</strong>: it is not an official Microsoft tool, instead is an OSS Project you can find on <a href="https://github.com/projectkudu/ARMClient">GitHub</a> or can install via Chocolatey. Nice article from <a href="https://blog.davidebbo.com/2015/01/azure-resource-manager-client.html">David Ebbo</a> if you want to know more.</li>
</ul>
There are also many articles that will explain you how to use Azure ARM REST API, then why I decided to publish this post focused on PowerShell? Long story short, I recently worked on two different projects aiming the same kind of final result: write everything necessary to create and manage a series of Azure resources, using plain ARM REST API calls. In the first case, my partner wanted then to include these REST calls in their Java application. In the second case, my other partner wanted to include REST API in their deployment engines using different components written in different languages (Python, .NET, PowerShell), then requiring a common denominator to avoid re-writing code. Another important aspect for the first project was the requirement to have access to new Azure features immediately, or at least as soon as possible once something new feature is announced.
<h1><strong><u>How new Azure API are published?</u></strong></h1>
This is an important first detail to be aware of: practically, there is no new Azure feature if there is no REST API available to use it, and obviously you need to have API reference and documentation to use. What happen normally, when Microsoft release a new feature, is that REST API are built at the very first, and described  <a href="https://github.com/Azure/azure-rest-api-specs">here</a> on GitHub:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/138.png"><img width="836" height="410" class="aligncenter wp-image-1265" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/138.png" /></a>

What you will find in that repository are the REST API full details for all Azure things, <em>decorated</em> with <strong>Swagger</strong> specs. If you don't know what is Swagger and want to know more, you can go <a href="https://swagger.io/">here</a>, or take my short and trivial scholastic definition: <em>Swagger is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful Web services</em>.

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/229.png"><img width="717" height="406" class="aligncenter wp-image-1266" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/229.png" /></a>

Finally, what Microsoft internally does is using a tool called <strong>AUTOREST</strong> (and something more called <strong><em>extensions</em></strong>) to automatically generate client SDKs and make available to you for consume. You can find it <a href="https://github.com/Azure/autorest">here</a> on GitHub:
<p style="padding-left: 30px"><em>Swagger (OpenAPI) Specification code generator featuring C# and Razor templates. </em></p>
<p style="padding-left: 30px"><em>Supports C#, Java, Node.js, TypeScript, Python and Ruby.</em></p>
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/2017/06/317.png"><img width="716" height="153" class="aligncenter wp-image-1275" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/317.png" /></a></p>
Let me emphasize this: official ARM REST API documentation should be updated to reflect the change soon, but it is worth nothing that this would require some time since human intervention is necessary to write, review and publish content:
<p style="padding-left: 30px"><strong><em>Azure Resource Manager</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/rest/api/resources">https://docs.microsoft.com/en-us/rest/api/resources</a></p>
Then, if you want to know as quickly as possible about how to use a new Azure feature, you should go to GitHub and look at REST API specs. Documentation will follow soon.

<u>NOTE</u>: At the time of writing, there are no Swagger specs for Azure Storage API.

If you are a Visual Studio 2017 user, and interested in building Web API using Swagger, you may want to review the article below:
<p style="padding-left: 30px"><strong><em>Visual Studio 2017 and Swagger: Building and Documenting Web APIs</em></strong></p>
<p style="padding-left: 30px"><a href="https://www.simple-talk.com/dotnet/net-development/visual-studio-2017-swagger-building-documenting-web-apis">https://www.simple-talk.com/dotnet/net-development/visual-studio-2017-swagger-building-documenting-web-apis</a></p>

<h1><strong><u>PowerShell Pre-Requisites</u></strong></h1>
Now that you are a bit familiar with Azure REST API and how they are published, and heard why I used PowerShell to consume these APIs, let me start showing you a practical example on how to build REST API calls, invoke them and manage the results. But before going into details, you need something to prepare at the beginning of your PowerShell script, here is the list of logical steps:
<ul>
 	<li>Initialize your script with common variables values you will use all over the script. This will eventually include Subscriptions details (ID and Name), Azure region, create common objects like a default Resource Group, you Azure Active Directory (AAD) tenant.</li>
 	<li>Authenticate to your Azure subscription using Azure Active Directory (AAD) account: this step will use interactive authentication (<strong><em>Login-AzureRmAccount</em></strong>) just to create <em><strong>Application</strong></em> and <strong><em>Service Principal</em></strong> objects in AAD. This is required only one time: once created the necessary objects for application logon (<em>see later</em>), your application/script will be able to logon to AAD programmatically without any user intervention.</li>
 	<li>Create an <strong><em>Application</em></strong> object in AAD (<strong><em>New-AzureRmADApplication</em></strong>). Azure offer developers the possibility to build applications that can be integrated with Azure Active Directory (AAD) to provide secure sign in and authorization for their services. To integrate an application or service with AAD, a developer must first register the details about their application with Azure AD. This can be done using the Azure Portal or using PowerShell script as in my code sample below. The important piece of information you will need to obtain from this step is <strong><em>ApplicationID</em></strong> that you will use as a surrogate <em>User Name</em> for creating logon credentials.</li>
</ul>
<p style="padding-left: 60px"><strong><em>Use portal to create an Azure Active Directory application and service principal that can access resources</em></strong></p>
<p style="padding-left: 60px"><a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/415.png"><img width="632" height="188" class="aligncenter size-full wp-image-1285" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/415.png" /></a>

&nbsp;
<ul>
 	<li>Once created the <strong>Application</strong> object in AAD, and obtained its <strong><em>ApplicationID</em></strong>, you need to create a <strong><em>Service Principal</em></strong> object using  <strong><em>New-AzureRmADServicePrincipal</em></strong> cmdlet, associated to the <strong><em>ApplicationID</em></strong>. Why you need this object? It is important to understand the difference between <strong><em>Application</em></strong> and <strong>Service Principal</strong>. You can read more at the link below, but in short, you can consider the application object as the global representation of your application for use across all tenants, and the service principal as the local representation for use in a specific tenant.</li>
</ul>
<p style="padding-left: 60px"><strong><em>Application and service principal objects in Azure Active Directory (Azure AD)</em></strong></p>
<p style="padding-left: 60px"><a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects">https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/511.png"><img width="494" height="375" class="aligncenter wp-image-1286" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/511.png" /></a>

&nbsp;
<ul>
 	<li>With the <strong><em>Service Principal</em></strong> object in your hands, you can use now use to assign permissions in the current AAD tenant. In the example below you can see both scopes supported: at the entire Azure subscription level, or scoped to a particular Resource Group (<em>recommended</em>). You can use both default built-in AAD roles or create new custom ones, depending on your requirements.</li>
 	<li>Next step consists in creating a new <strong><em>Key</em></strong> in AAD, associated to your just created <strong><em>Application</em></strong>, and then store for later use in your script. You can read <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal">here</a> instructions to do this using the Azure Portal (key chars scrambled).</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/612.png"><img width="650" height="253" class="aligncenter size-full wp-image-1305" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/612.png" /></a>
<ul>
 	<li>Using nice PowerShell mechanism, as you can see in the example below, you can now create encrypted credential set (user name and password) to pass to your subsequent cmdlets. Be aware that "<strong><em>ApplicationID</em></strong>" is your username and must be used in the form of "<em>username@domain-name"</em>, where the domain-name looks like "<em>&lt;something&gt;.onmicrosoft.com</em>". Last piece of information you need to retrieve is AAD <strong>Tenant Name</strong> for your subscription, you can easily retrieve using last PowerShell script line shown below.</li>
 	<li>From now and going forward, you can logon using just created Application identity and secret, you don't need interactive logon anymore. After execution of the new instance of <strong><em>Login-AzureRmAccount</em></strong> with application parameters, you will be now authenticated as an application in the script.</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/711.png"><img width="580" height="142" class="aligncenter wp-image-1315" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/711.png" /></a>

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/810.png"><img width="653" height="107" class="aligncenter wp-image-1325" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/810.png" /></a>

We are now at the final preparation step, probably the most important one, that is getting a <strong><em>Bearer</em></strong> authentication token from AAD endpoint (<em>https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/token)</em> using <em><strong>Oauth2</strong></em> (<i>k</i><em>ey chars scrambled</em>):

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/917.png"><img width="531" height="283" class="aligncenter wp-image-1335" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/917.png" /></a>

As you can see above, I used "<a href="https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Utility/Invoke-RestMethod">Invoke-RestMethod</a>" PowerShell cmdlet to send HTTPS requests to Representational State Transfer (<em><strong>REST</strong></em>) web services, in this case a PUT to Azure AAD <em><strong>Oauth2</strong></em> passing ApplicationID and Key, for the ARM resource endpoint (https://management.core.windows.net) . Token as a form similar to the one below (<em>text is scrambled</em>). Be aware that the default life time for the token is 60 minutes (3600 seconds), after that you will need to generate another request and acquire a new one.

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/106.png"><img width="556" height="215" class="aligncenter wp-image-1345" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/106.png" /></a>

&nbsp;

Azure recently introduced the possibility to change the default lifetime of an AAD token feature is still in preview and I did not personally use it yet, but you may want to read the article below:
<p style="padding-left: 30px"><strong><em>Configurable token lifetimes in Azure Active Directory (Public Preview)</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes">https://docs.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes</a></p>

<h1><strong><u>Building and Executing REST calls</u></strong></h1>
Now we have a valid AAD token and we can finally do something interesting with Azure ARM REST API. It is important to highlight that every REST call must include authentication token in the header, but I am sure will be clear once you will see below the first trivial example, that is how to retrieve details about your Azure subscription with a simple GET verb:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/1115.png"><img width="607" height="209" class="aligncenter wp-image-1355" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/1115.png" /></a>

Please be aware that the result is not JSON formatted by default, you need to explicitly convert, then you will see a similar output as the one in the picture below. It is also worth mentioning that specifying the API version is mandatory. Finally, you can see there is no <em><strong>Body</strong> part</em> defined in this simple GET request.

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/1210.png"><img width="603" height="165" class="aligncenter wp-image-1365" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/1210.png" /></a>

The sample above is pretty simple, at the end is a GET request getting synchronous answer. But what happen if I want to write (PUT for example) something? Look at the example below used to create a storage account:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/147.png"><img width="558" height="300" class="aligncenter wp-image-1385" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/147.png" /></a>

<u>NOTE</u>: in the code snippet above, I started using <strong><em>Invoke-WebRequest</em></strong> instead of <strong><em>Invoke-RestMethod</em></strong> because I had problems in correctly parsing and processing the response header, I normally prefer the former.

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/157.png"><img width="980" height="132" class="aligncenter wp-image-1395" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/157.png" /></a>

In the response content above there are several interesting things: first, the status code returned in <strong><em>StatusCode</em></strong> is (<strong>202</strong>), that is <strong><em>Accepted</em></strong> (<strong><em>StatusDescription</em></strong>) in HTTP response code vocabulary. It is indicating that the request you submitted is a <em>long running</em> asynchronous operation, then the system returned your code a result, but the backend operation is still running in the Azure ARM infrastructure. For synchronous operations like typical GET methods to read objects and resources, you normally receive <strong>200 (OK)</strong>.
<p style="padding-left: 30px"><strong><em>Microsoft REST API Guidelines</em></strong></p>
<p style="padding-left: 30px"><a href="https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md">https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md</a></p>
According the excellent documentation above, "<strong><em>Retry-After</em></strong>" HTTP header indicating the minimum number of seconds that clients SHOULD wait before attempting the operation again. Why this is important? Azure REST API infrastructure tends to protect itself from being overloaded, then this value is returned in all async responses. But, if you do not  want to obey to this hint, there is another safe limit that Azure enforces, you can guess looking to <strong><em>x-ms-ratelimit-remaining-subscription-writes</em></strong> element. For each subscription and tenant, Azure Resource Manager limits read requests to 15,000 per hour and write requests to 1,200 per hour. When you reach the limit, you receive the HTTP status code (<strong>429</strong>), that is "<strong><em>Too many requests</em></strong>". You can see all the limits in the article below along with additional details.
<p style="padding-left: 30px"><strong><em>Throttling Resource Manager requests</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits</a></p>
Now, if you want to check the status of your running async operation, you need to execute some code like the example below:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/166.png"><img width="583" height="154" class="aligncenter wp-image-1415" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/166.png" /></a>

&nbsp;

And here is the content of the variable <strong><em>$URIAsyncCheck</em></strong> (<em>single line scrambled</em>):

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/176.png"><img width="792" height="68" class="aligncenter wp-image-1425" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/176.png" /></a>

General rule to track async operation, for Azure ARM REST API, requires you to check a specific dynamically crafted URL for the status: this URL is generated depending on the ARM Resource Provider (RP) you previously sent the async request to, in this case the <strong>Microsoft.Storage</strong> RP, and the OperationID of that request. You can see these elements highlighted in red in the above text. Unfortunately, there is no single place you can retrieve that OperationID: as you can see in the code snippet above, you have first to check for the existence of value for <strong><em>Location</em></strong> attribute in the response header, then if nothing is in there, you need to check <strong><em>Azure-AsyncOperation</em></strong>. Â With this knowledge in mind, let us check the long running operation using the code snippet below:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/184.png"><img width="965" height="243" class="aligncenter wp-image-1435" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/184.png" /></a>

This is the output you should see:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/193.png"><img width="726" height="235" class="aligncenter wp-image-1445" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/193.png" /></a>

As you can see, this is a long running async operation (<strong><em>Response Code = 202 Accepted</em></strong>). You can also note that until the <strong><em>Response Code</em></strong> will not change to <strong>200 - OK</strong>, there is no body content returned <em>(<strong>Content Length = 0</strong></em>). You should then wait in a loop and check periodically for this condition, once happened, you should check for <strong><em>provisioningState</em></strong> attribute value returned: if, <u>and only if</u>, the operation is completed, then possible values are "<strong><em>Succeeded</em></strong>", "<strong><em>Failed</em></strong>" or "<strong><em>Canceled</em></strong>". Different values could be returned, depending on the Resource Provider you may see different values, but this indicates that the request is not completed yet. Some operations that you could think as being asynchronous, in reality they are not, as in the example below related to the deletion of a storage account (<em>Sample[5] in the sample code</em>):

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/202.png"><img width="682" height="279" class="aligncenter wp-image-1446" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/202.png" /></a>

Here the only difference is the <strong><em>Method = 'Delete'</em></strong> part, and result HTTP code will be <strong>200 - OK</strong> (if the storage account exists and you have permissions). No attribute "<strong><em>Location</em></strong>" or "<strong><em>Azure-AsyncOperation</em></strong>" will be generated to check for async operation. You can see details for this particular REST API at the location below:
<p style="padding-left: 30px"><strong>Storage Accounts ARM REST API</strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/rest/api/storagerp/storageaccounts">https://docs.microsoft.com/en-us/rest/api/storagerp/storageaccounts</a></p>
Going through the examples, I refined and sometimes modified the logic to track async long-running operations, a sample (extracted from the GitHub code) is below:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/2110.png"><img width="1515" height="873" class="aligncenter size-full wp-image-1455" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/2110.png" /></a>

Building REST API request Header and Body can become difficult for very large objects as Virtual Machine. You can see an example below, please note that only the minimum required parameters are used, there are many more optional that I did not include. If you want to work using this approach, you need to keep in your hands the Azure ARM REST API reference pages below, and the <strong>-Debug</strong> switch in PowerShell, you can read more details on the latter in the next section.
<p style="padding-left: 30px"><strong><em>Azure REST API Reference</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/rest/api">https://docs.microsoft.com/en-us/rest/api</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/2210.png"><img width="382" height="591" class="aligncenter wp-image-1465" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/2210.png" /></a>

&nbsp;
<h1><strong><u>Code Samples on GitHub</u></strong></h1>
<a href="https://github.com/igorpag/PSasRESTclientAzure">Here</a> on GitHub, you can find the code and how to deploy, end- to-end, an Azure Virtual Machine, including NSG, VNET and IPs, in a new Resource Group all using REST API direct call in PowerShell. Code for Application and Service Principal creations in Azure Active Directory is also provided. Here is the sample list divided in PowerShell <strong>regions</strong>:

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/233.png"><img width="847" height="354" class="aligncenter wp-image-1495" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/233.png" /></a>

Purpose of this work is to show how to work directly with Azure ARM REST API using PowerShell as an ARM client. Code is highly de-normalized to make each section pretty autonomous and self-contained to facilitate reuse. At the end, what you should be able to obtain is the following list of resources, all of them built using plain REST API built and executed in PowerShell.

<a href="https://msdnshared.blob.core.windows.net/media/2017/06/243.png"><img width="432" height="294" class="aligncenter wp-image-1505" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/243.png" /></a>
<h1><strong><u>PowerShell Hidden Gems</u></strong></h1>
I have been surprised many times why most people don't know the power of Azure cmdlets when adding <strong>-Debug</strong> switch at the end of the command string. Azure PowerShell module is a wrapper built on top of Azure ARM (in this case) REST API, but if you add it, you will see the raw underlying REST API request built for you, and the correspondent result:
<p style="padding-left: 30px"><strong>Get-AzureRmStorageAccount -ResourceGroupName $rgname <span style="color: #ff0000"><em>-Debug</em></span></strong></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/252.png"><img width="921" height="144" class="aligncenter wp-image-1515" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/252.png" /></a>

Then, if you want to work at the pure REST API level, but want your life a bit easier, you could use higher-level PowerShell cmdlets and then reverse-engineer them using the <strong>-Debug</strong> switch. Another very useful feature you can use in PowerShell is <strong>Stop Watch</strong>. Starting Sample[6] in my GitHub code example, I used it extensively to monitor execution time of my REST API: below you can find a very simple general structure of its usage.
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/2017/06/262.png"><img width="480" height="106" class="aligncenter wp-image-1525" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/262.png" /></a></p>

<h1><strong><u>Java Sample</u></strong></h1>
If you want a Java version of something similar I have shown you here, I would encourage you to look at <em><strong>Silvano Coriani</strong></em> (from AzureCAT) sample work on GitHub here, very nice if this is your favorite development language.
<p style="padding-left: 30px"><a href="https://github.com/scoriani/ServiceBuilder/blob/master/src/com/microsoft/azure/provisioningengine/ProvisioningEngine.java">https://github.com/scoriani/ServiceBuilder/blob/master/src/com/microsoft/azure/provisioningengine/ProvisioningEngine.java</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/06/271.png"><img width="746" height="256" class="aligncenter wp-image-1535" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/06/271.png" /></a>
<h1><strong>References</strong></h1>
GitHub Code Sample Repository: <a href="https://github.com/igorpag/PSasRESTclientAzure">https://github.com/igorpag/PSasRESTclientAzure</a>

Azure REST API specs: <a href="https://github.com/Azure/azure-rest-api-specs">https://github.com/Azure/azure-rest-api-specs</a>

Azure Resource Manager: <a href="https://docs.microsoft.com/en-us/rest/api/resources">https://docs.microsoft.com/en-us/rest/api/resources</a>

Azure REST API Reference: <a href="https://docs.microsoft.com/en-us/rest/api">https://docs.microsoft.com/en-us/rest/api</a>

Track asynchronous Azure operations: <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-async-operations">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-async-operations</a>

Throttling Resource Manager requests: <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits</a>

Resource providers and types: <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services</a>

Use portal to create an Azure Active Directory application and service principal that can access resources: <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal</a>

Use Azure PowerShell to create a service principal to access resources: <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authenticate-service-principal">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authenticate-service-principal</a>

Use Resource Manager authentication API to access subscriptions

<a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-api-authentication">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-api-authentication</a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>My personal Azure FAQ on Azure Networking (v3)</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/my-personal-azure-faq-on-azure-networking-v3</link>
      <pubDate>Thu, 06 Apr 2017 08:00:52 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=875</guid>
      <description><![CDATA[Last updated: April 6th, 2017.

IMPORTANT: The information I reported in this post is time...]]></description>
      <content:encoded><![CDATA[<span style="color: #000000"><strong><em><u>Last updated</u></em></strong>: April 6th, 2017.</span>

<span style="color: #ff0000"><strong><em><u>IMPORTANT</u></em></strong></span><em>: The information I reported in this post is time sensitive since may change in the future. I will try to maintain the content updated, but you should double-check with official Azure documentation sources. This is v3 of my previously published blog posts below, I will maintain previous versions for historical reasons:</em>
<p style="text-align: left;padding-left: 30px"><strong><em>My personal Azure FAQ on Azure Networking SLAs, bandwidth, latency, performance, SLB, DNS, DMZ, VNET, IPv6 and much more (ARM)</em></strong></p>
<p style="text-align: left;padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/igorpag/2014/09/28/my-personal-azure-faq-on-azure-networking-slas-bandwidth-latency-performance-slb-dns-dmz-vnet-ipv6-and-much-more">https://blogs.msdn.microsoft.com/igorpag/2014/09/28/my-personal-azure-faq-on-azure-networking-slas-bandwidth-latency-performance-slb-dns-dmz-vnet-ipv6-and-much-more</a></p>
<p style="text-align: left;padding-left: 30px"><strong><em>My personal Azure FAQ on Azure Networking SLAs, bandwidth, latency, performance, SLB, DNS, DMZ, VNET, IPv6 and much more (ASM)</em></strong></p>
<p style="text-align: left;padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/igorpag/2014/09/28/my-personal-azure-faq-on-azure-networking-slas-bandwidth-latency-performance-slb-dns-dmz-vnet-ipv6-and-much-more">https://blogs.msdn.microsoft.com/igorpag/2014/09/28/my-personal-azure-faq-on-azure-networking-slas-bandwidth-latency-performance-slb-dns-dmz-vnet-ipv6-and-much-more</a></p>
In the last five years, I worked extensively on Azure core IaaS, during engagements with my partners I have been asked many questions on Azure networking in general, and more specifically on Virtual Network (VNET) and VMs in new Azure Resource Manager (ARM) world. Providing adequate answers is not always easy, sometime the documentation is not clear or missing in details, while other times you can deduct yourselves but requires pretty good knowledge. Since I detected some recurring patterns in these questions, I decided to write my personal FAQ list in this blog post. Just to be clear: even if I’m a MSFT and have inner knowledge of Azure, I’m not going to unveil you any reserved or secret information. Everything you will read here can be found playing directly with Azure or retrieved by using official and public documentation. If you have additional “nice” questions requiring a non-trivial or non-easy-to-retrieve answer, fill free to insert a comment below this post. Additionally, if you have proposals or feedbacks regarding new feature that Azure networking should have, please use the link below to submit your ideas or vote existing ones:
<p style="padding-left: 30px"><strong><em>FEEDBACK FORUM: Networking (DNS, Traffic Manager, VPN, VNET)</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/category/77469-virtual-networks-vnet">https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/category/77469-virtual-networks-vnet</a></p>
As usual, you can also follow me on Twitter at <strong><em>@igorpag</em></strong>. Regards.

&nbsp;
<h2><strong>Can I take a network trace inside my Azure Virtual Network? </strong></h2>
YES. This cool and useful feature has been recently released under the Azure “<em>Network Watcher</em>” service. You can now capture packet data in and out of a virtual machine. Advanced filtering options and fine-tuned controls such as being able to set time and size limitations can be applied as well. The packet data can be stored in a blob store or on the local disk in <strong>.cap</strong> format, then use tools like <a href="https://www.wireshark.org/">WireShark</a> to analyze and display.
<p style="padding-left: 30px"><strong><em>Introduction to variable packet capture in Azure Network Watcher</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/network-watcher/network-watcher-packet-capture-overview">https://docs.microsoft.com/en-us/azure/network-watcher/network-watcher-packet-capture-overview</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/1.jpg"><img width="492" height="788" class="aligncenter wp-image-885" alt="1" src="https://msdnshared.blob.core.windows.net/media/2017/04/1.jpg" /></a>

Additionally, packet capture provides the capability of running proactive captures based on defined network anomalies, thus triggering actions to react to network conditions. More details in the article below:
<p style="padding-left: 30px"><strong><em>Use packet capture to do proactive network monitoring with Azure Functions</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/network-watcher/network-watcher-alert-triggered-packet-capture">https://docs.microsoft.com/en-us/azure/network-watcher/network-watcher-alert-triggered-packet-capture</a></p>
Be aware that packet capture requires a virtual machine extension to be installed inside the VM (<em>AzureNetworkWatcherExtension</em>). It is available for both Windows and Linux Operating Systems. This feature can be managed from the Azure Portal and PowerShell.
<h2><strong>How can I check my network resources usage against my assigned limits?</strong></h2>
One of the nice features of new Azure “<em>Network Watcher</em>”, is the possibility to check all networking related resources currently used in a specific region for a certain subscription. All Azure resource limits, including networking ones, are listed in the article below. Hard limits cannot be increased, for Soft Limits, instead, you can open an incident to Azure Support and ask to increase.
<p style="padding-left: 30px"><strong><em>Azure subscription and service limits, quotas, and constraints (Networking)</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits?toc=%2fazure%2fvirtual-network%2ftoc.json#networking-limits">https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits?toc=%2fazure%2fvirtual-network%2ftoc.json#networking-limits</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/2.jpg"><img width="438" height="281" class="aligncenter wp-image-895" alt="2" src="https://msdnshared.blob.core.windows.net/media/2017/04/2.jpg" /></a>
<h2><strong>Can I persist my VM MAC address?</strong></h2>
YES. Azure now provides persistent MAC addresses generated at NIC creation time. This ID will not change over the entire NIC lifecycle, even if the VM will be stopped, crashed and recovered to a different Azure Host, resized, deallocated or unbound. Be aware that Azure assigns a MAC address to the NIC only after the NIC is attached to a VM and the VM is started the first time. You cannot specify the MAC address that Azure assigns to the NIC. The MAC address remains assigned to the NIC until the NIC is deleted or the private IP address assigned to the primary IP configuration of the primary NIC is changed.
<p style="padding-left: 30px"><strong><em>Network interfaces</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-network-interface">https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-network-interface</a></p>

<h2><strong>Is there any limit on VNET and subnet sizing?</strong></h2>
YES. Inside a VNET you can create a maximum of 1000 subnets. This is a “soft” limit that can be eventually increased. The smallest subnet we support is a /29 and the largest is a /8 (using CIDR subnet definitions). Inside each subnet, Azure reserves some IP addresses within each subnet. The first and last IP addresses of the subnets are reserved for protocol conformance, along with 3 more addresses used for Azure services. Regarding IP addresses, currently Azure VNET supports 4096 IP addresses, independently from the number of NICs and VMs and from their state, stopped VM will still count toward the limit.
<p style="padding-left: 30px"><strong><em>Azure Subscription limits for Networking </em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#networking-limits">https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#networking-limits</a></p>
<strong> </strong>
<h2><strong>Can I create a Storage Account or Azure SQLDB with restricted access from a VNET only?</strong></h2>
While is possible to create a Virtual Machine not exposed to the Internet, for Azure Storage Accounts and Azure SQLDB logical servers there is a mandatory DNS name created that need to be exposed. During creation of these resources, a FQDN records is created and exposure cannot be avoided since this resource locator is required to access the resource. Both these resources are protected by Microsoft DDoS and Azure SQLDB can be also configured with its own firewall mechanism.
<p style="padding-left: 30px"><strong><em>Configure an Azure SQL Database server-level firewall rule using the Azure Portal</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings">https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings</a></p>
Currently there is a feature request to provide an internal-only endpoint for storage and Azure SQLDB to VMs inside a VNET: they will be able to access these services even without Internet connectivity. This functionality should be available in the second half of calendar year 2017.
<p style="padding-left: 30px"><strong><em>Create predefined NSG for Azure Datacenters IP Range</em></strong>
<a href="https://feedback.azure.com/forums/217313-networking/suggestions/11093742-create-predefined-nsg-for-azure-datacenters-ip-ran">https://feedback.azure.com/forums/217313-networking/suggestions/11093742-create-predefined-nsg-for-azure-datacenters-ip-ran </a></p>
&nbsp;
<h2><strong>What is IP address “169.254.169.254”?</strong></h2>
If you monitored in some way network traffic and connections for your Azure VMs, you may have been noticed IP address “<em>169.254.169.254</em>”: what is this? Don’t worry, it is not a malicious attempt to hack or attack your VM. This is a non-routable IP address that is accessible only from inside an Azure VM and is used to communicate with the Azure Host for some very specific scenarios and information retrieval.

&nbsp;
<p style="padding-left: 30px"><strong><em>Preview: “What is about to happen to my VM?” In-VM Notification Service</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/blog/what-just-happened-to-my-vm-in-vm-metadata-service">https://azure.microsoft.com/en-us/blog/what-just-happened-to-my-vm-in-vm-metadata-service</a></p>
Today, this special IP is used to retrieve the planned maintenance events that will touch the VM, as described in the article above, but soon will be used also to retrieve metadata information related to the VM itself. Figure below describes the high level overview of today’s communication framework. The REST Server is the only place the VM can communicate. For the metadata instance server, we use the standard Link-Local addresses i.e. 169.254/16 which is aligned with RFC3927.

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/3.jpg"><img width="331" height="199" class="wp-image-905 aligncenter" alt="3" src="https://msdnshared.blob.core.windows.net/media/2017/04/3.jpg" /></a>
<h2><strong>Does Azure support IPv6?</strong></h2>
YES. Azure now provides support for IPv6 public facing IPs, both static and dynamic. Please note that you cannot use IPv6 inside a VNET for VM-to-VM communications: using an IPv6 address as an internal VM IP (DIP) or for ILB is *not* supported. The public IPv6 addresses cannot be assigned to a VM as an instance level IP (ILPIP or PIP). They can only be assigned to the external Azure Load Balancer. It is worth mentioning that currently is not possible to use NSG with IPV6, but access can be restricted using load balancing rules.
<p style="padding-left: 30px"><strong><em>Overview of IPv6 for Azure Load Balancer</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-ipv6-overview">https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-ipv6-overview</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/4.jpg"><img width="552" height="307" class="aligncenter wp-image-915" alt="4" src="https://msdnshared.blob.core.windows.net/media/2017/04/4.jpg" /></a>
<h2><strong>Can I connect Azure Virtual Networks without any Gateway?</strong></h2>
YES, this features is called “<em>VNET Peering</em>“ and can connect two VNETs without any gateway. Only VNETs in the same region can be peered, mixing ASM and ARM is supported, gateways in the peered VNET can be used by the peering VNET.

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/51.jpg"><img width="504" height="374" class="aligncenter wp-image-917" alt="5" src="https://msdnshared.blob.core.windows.net/media/2017/04/51.jpg" /></a>
<h2><strong>Is it possible to have multiple NICs for an Azure VM? </strong></h2>
YES, this feature has been available since 2014 but with some limitations. What has been recently changed here is that you are now able to add (or remove) additional NICs even after VM creation, the only restriction is that VM must be stopped and deallocated. Additionally, you can mix single and multiple NIC VMs in the same Availability Set (AS), you can assign public IPs and NSGs also to the secondary NICs. Each NIC can support up to 250 IP addresses.  Be aware that adding more NICs will not give you more bandwidth, all will share the same limit granted to the VM level. Maximum number of NICs is depending on the VM SKU and size as documented in the article below:
<p style="padding-left: 30px"><strong><em>Sizes for Windows virtual machines in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/61.jpg"><img width="636" height="272" class="aligncenter size-full wp-image-925" alt="6" src="https://msdnshared.blob.core.windows.net/media/2017/04/61.jpg" /></a>
<h2><strong>Can I assign multiple IPs to my single Network Interface Card (NIC)?</strong></h2>
YES. An Azure Virtual Machine (VM) has one or more network interfaces (NIC) attached to it. Any NIC can have one or more static or dynamic public and private IP addresses assigned to it. Every NIC attached to a VM has one or more IP configurations associated to it. Each configuration is assigned one static or dynamic private IP address. Each configuration may also have one public IP address resource associated to it. A public IP address resource has either a dynamic or static public IP address assigned to it. The actual limit for assigned IP per NIC is 250, there is also a limit to the subscription level, you can check the article below:
<p style="padding-left: 30px"><strong><em>Sizes for Windows virtual machines in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes</a></p>
Be aware that maximum number of NICs is dependent on the VM SKU and size. Finally, network throughput will not increase adding more NICs since they are logical constructs.
<h2 style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/2017/04/71.jpg"><img width="390" height="345" class="aligncenter size-full wp-image-926" alt="7" src="https://msdnshared.blob.core.windows.net/media/2017/04/71.jpg" /></a></h2>
<h2><strong>Is it possible to create custom TAGs for NSG?</strong></h2>
Today, you can create a NSG containing “<em>rules</em>” and then assign to subnets (or single NIC). You are limited to one NSG per subnet, and you cannot create nested or linked NSG. Additionally, it is not possible to create custom TAGs containing predefined sets of VMs or IP addresses, and you cannot leverage “<em>system</em>” TAGs to refer to Azure services, like storage or Azure SQLDB, to restrict access. Azure Networking team heard feedbacks around these functionalities and is considering exposing system tags for STORAGE and SQL in the near term. System TAGs are also on the roadmap for future improvements.
<p style="padding-left: 30px"><strong><em>Azure Networking Feedbacks Forum</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking/category/77468-security-acls-firewalls-intrusion-detection">https://feedback.azure.com/forums/217313-networking/category/77468-security-acls-firewalls-intrusion-detection</a></p>
<strong> </strong>
<h2><strong>Which is the Public IP what a VM will use to send out network packets to Internet?</strong></h2>
In older ASM API Azure days, a VM was always contained in a Cloud Service logical container, and a VIP has been always associated to it. In this scenario, network packets originated from the VM exited Azure network using the Cloud Service VIP as source IP. Making this VIP “reserved”, permitted users to know that IP and configure, for example, VIP white-listing on their on-premises perimeter firewalls. In ARM, there is no more mandatory Cloud Service (and related VIP). When you create a VM inside a VNET, there is no default VIP associated if you don’t specifically ask it. The net result is that if network packets originated from that VM exited Azure network, the VIP used was one from a pool of Azure managed VIPs with no possibility to predict which one and no guarantee that would remain the same. If you want your VM to send packets out to the Internet using a fixed/reserved IP, you need to assign a VIP to the VM, through the Azure Load Balancer, or assign a VIP directly to the VM (PIP or ILPIP). All scenarios are well explained in the article below:

&nbsp;
<p style="padding-left: 30px"><strong><em>Understanding outbound connections in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-outbound-connections">https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-outbound-connections</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/81.jpg"><img width="764" height="152" class="aligncenter wp-image-935" alt="8" src="https://msdnshared.blob.core.windows.net/media/2017/04/81.jpg" /></a>
<h2><strong>Should I care about Azure Load Balancer capacity for VM outgoing traffic?</strong></h2>
While Azure Load Balancer “filter” <strong><u>incoming</u></strong> connections and flows to VNET contained VMs, for <strong><u>outgoing</u></strong> traffic the load balancer is bypassed and network packets reach directly the Internet. This is true independently from the type of VIP, if any, assigned to the VM. If you want to have strict control on outgoing traffic, you need use a NVA and use User Defined Routing (UDR) to force the traffic through it.

<strong> </strong>
<h2><strong>Do Azure VPN or ExpressRoute provide traffic encryption?</strong></h2>
Azure VPN tunnels, for Site-to-Site connectivity (S2S), are by design/default encrypted using IPSEC. Encryption is also provided for Point-to-Site (P2S) using SSTP (Secure Socket Tunneling Protocol). ExpressRoute does not provide network traffic encryption for its circuits.
<p style="padding-left: 30px"><strong><em>VPN Gateway FAQ</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-vpn-faq">https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-vpn-faq</a></p>
&nbsp;

For Azure VPN Gateways, is not possible to customize IPSEC parameters, this is something that should be possible in the future.

&nbsp;
<h2><strong>Is it possible to obtain ExpressRoute usage statistics?</strong></h2>
YES, it is possible. Azure Portal provides only two simple counters as in the example below, but as you can see they are cumulative and it is difficult to monitor usage over time.

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/91.jpg"><img width="204" height="158" class="aligncenter size-full wp-image-945" alt="9" src="https://msdnshared.blob.core.windows.net/media/2017/04/91.jpg" /></a>

To obtain more granular Azure ExpressRoute statistics, you can use the PowerShell script below from GitHub:
<p style="padding-left: 30px"><strong><em>Visualize Azure Express Route Statistics</em></strong></p>
<p style="padding-left: 30px"><a href="https://github.com/tvuylsteke/azure-ea-powerbi/tree/master/Express%20Route%20Stats%20-%20V1">https://github.com/tvuylsteke/azure-ea-powerbi/tree/master/Express%20Route%20Stats%20-%20V1</a></p>
<strong> </strong>
<h2><strong>Does Azure Load Balancer support multiple IPs? </strong></h2>
YES, Azure Load Balancer supports multiple IPs both in the public facing VIP scenario (SLB) and internal only scenario (ILB). In the first case, it is possible to have multiple public IP (VIPs) assigned to the same external load balancer, and then traffic forwarded to the same set of Virtual Machines included in one single Availability Set. It is also possible to combine this feature with multiple NICs per VM, as described in the article below:
<p style="padding-left: 30px"><strong><em>Load balancing on multiple IP configurations using PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-multiple-ip-powershell#steps-to-load-balance-on-multiple-ip-configurations">https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-multiple-ip-powershell#steps-to-load-balance-on-multiple-ip-configurations</a></p>
&nbsp;

The configuration described above is possible since last year, what has been introduced only recently is the multiple IP support for Azure Internal Load Balancer (ILB) using internal IPs (DIPs). After initially creating an ILB with a single internal DIP, you can add more using the steps outlined in section “<em>Example script: Add an IP address to an existing load balancer with PowerShell</em>” in the article below. In short, each IP address requires its own load balancing rule, probe port, and front port. It is worth mentioning that thanks to this feature, it is now possible to deploy multiple SQL Server AlwaysOn Availability Groups (AG) using the same set of Azure VMs.
<p style="padding-left: 30px"><strong><em>Configure one or more Always On Availability Group Listeners - Resource Manager</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/virtual-machines-windows-portal-sql-ps-alwayson-int-listener">https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/virtual-machines-windows-portal-sql-ps-alwayson-int-listener</a></p>
<strong> </strong>

<u>NOTE</u>: Today, you can have a load balancer with multiple VIPs backed by a single VM “Backend Pool”, but you cannot use multiple Availability Sets for a single load balancer.
<h2><strong>Does ICMP work in Azure?</strong></h2>
It depends from where you want to use ICMP tools and which targets you want to reach. ICMP works inside an Azure Virtual Network, between different Azure Virtual Networks connected via VPN or ExpressRoute or hybrid connections between on-premise and Azure VNET. It will *not* work if you have to cross the Azure Load Balancer (SLB). If you need ICMP for diagnostic and troubleshooting, there are valid alternatives to PING and TRACERT not based on ICMP but TCP. My favorite ones, among many others available in Internet, are PSPING from Mark Russinovich SysInternals tools and NMAP:
<p style="padding-left: 30px"><strong><em>PsPing v2.01</em></strong></p>
<p style="padding-left: 30px"><a href="https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx">https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx</a></p>
<p style="padding-left: 30px"><strong><em>NMAP</em></strong></p>
<p style="padding-left: 30px"><a href="https://nmap.org/download.html">https://nmap.org/download.html</a></p>
Inside an Azure VNET, you can use TCP, UDP, and ICMP TCP/IP protocols. Multicast, broadcast, IP-in-IP encapsulated packets, and Generic Routing Encapsulation (GRE) packets are blocked within VNets. Remember: Azure VNET is a Layer-3 virtual network.

&nbsp;
<h2><strong>What is Direct Server Return (DSR) for Azure Load Balancer? Should I use it?</strong></h2>
“<em>Direct Server Return</em>” (DSR) is probably one of the most unknown and mis-understood parameter in all Azure networking objects configurations, probably because is seldom used and documentation is not good enough. In short, it is a parameter used to enable a special behavior when configuring Azure Load Balancer load-balanced rules, both external and internal ones: when enabled, Load Balancer does <em><u>not</u></em> perform any Network Address Translation (NAT) of the request and will pass the incoming packet to the destination VM using the Load Balancer VIP as the destination IP, instead of the VM internal IP (DIP).

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/101.jpg"><img width="486" height="187" class="aligncenter wp-image-946" alt="10" src="https://msdnshared.blob.core.windows.net/media/2017/04/101.jpg" /></a>

In the above picture, please note on the right the “<strong><em>Dst: service VIP</em></strong>” label. Conversely, when DSR is disabled (default behavior), “<strong><em>Dst: service VIP</em></strong>” will be replaced by VM internal IP. It is also worth noting that the target VM will respond to the Client directly, bypassing the Load Balancer. Now the second question: should I use it? The answer is NO, if you don’t need it for specific application or service. For sure, you will need if you want to use SQL Server AlwaysOn Availability Group feature, as described in the article below:

&nbsp;
<p style="padding-left: 30px"><strong><em>Configure an ILB listener for SQL Server AlwaysOn Availability Groups in Azure ARM</em></strong></p>
<p style="padding-left: 30px"><strong><a href="https://blogs.msdn.microsoft.com/igorpag/2016/01/25/configure-an-ilb-listener-for-sql-server-alwayson-availability-groups-in-azure-arm">https://blogs.msdn.microsoft.com/igorpag/2016/01/25/configure-an-ilb-listener-for-sql-server-alwayson-availability-groups-in-azure-arm</a></strong></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/11.jpg"><img width="858" height="262" class="aligncenter wp-image-955" alt="11" src="https://msdnshared.blob.core.windows.net/media/2017/04/11.jpg" /></a>

In the last PowerShell command above, DSR is enabled using “<strong><em>-EnabledFloatingIP</em></strong>” parameter. If you want to use DSR for other applications, be careful because the VM will need to receive network packets where the destination IP is not the VM IP but the load balancer VIP. If you don’t have application or service specific support to enable this, as in the SQL Server case, you will need to add a loopback adapter to the VM and manually add the load balancer VIP to it.

&nbsp;
<h2><strong>Does Azure support SR-IOV for accelerated networking?</strong></h2>
Azure feature currently in preview, and soon broadly available, called “<em>Accelerated Networking</em>” enables “<em>Single Root I/O Virtualization</em>” (SR-IOV) to a virtual machine (VM), greatly improving its networking performance. This high-performance path bypasses the host from the datapath reducing latency, jitter, and CPU utilization for use with the most demanding network workloads on supported VM types.

&nbsp;
<p style="padding-left: 30px"><strong><em>Accelerated networking for a virtual machine using the Azure portal</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-accelerated-networking-portal">https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-accelerated-networking-portal</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/12.jpg"><img width="630" height="265" class="aligncenter wp-image-965" alt="12" src="https://msdnshared.blob.core.windows.net/media/2017/04/12.jpg" /></a>
<h2><strong>Can I use Receive Side Scaling (RSS) optimization in Azure VM?</strong></h2>
YES. Azure Host hypervisor can support “<em>Receive Side Scaling</em>” (RSS) at the VM level. Azure Virtual Machines have default network settings that can be further optimized for network throughput. Following the instructions in the article below, you can optimize network throughput for both Windows and Linux Guest OS, including major distributions such as Ubuntu, CentOS and Red Hat.
<p style="padding-left: 30px"><strong><em>Optimize network throughput for Azure virtual machines</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-optimize-network-bandwidth">https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-optimize-network-bandwidth</a></p>
&nbsp;

A VM using Receive Side Scaling (RSS) can reach higher maximal throughput than a VM without RSS. RSS may be disabled by default in a Windows VM, you can easily check following the previous article. For Linux, starting January 2017 this optimization is enabled by default, but you need to use a <em>Linux Integration Services (LIS)</em> version equal or higher than <a href="https://www.microsoft.com/en-us/download/details.aspx?id=51612">4.1.3</a>.
<h2>Can I manually change protocol and NIC settings at the Guest OS level?</h2>
If not explicitly stated in any Microsoft official documentation, manual overriding of network interface or TCP settings at the Guest OS level is not recommended. This may cause loss of connectivity, or severe VM malfunctions. Some settings at the NIC level, like MTU, should be left at default values, in this case 1500. For DNS settings at the TCP level, changing are supported but from external Azure API/Portal/PowerShell/CLI-tool. Changing OS Firewall configuration is safe and supported, as long as you will not close out your remote connection.

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/21.jpg"><img width="1003" height="166" class="aligncenter size-full wp-image-1056" alt="21" src="https://msdnshared.blob.core.windows.net/media/2017/04/21.jpg" /></a>
<h2><strong>Does Azure provide SLA for VM network bandwidth?</strong></h2>
I tested VM bandwidth limits on almost all VM sizes and found the results pretty consistent over time, then in theory there is nothing preventing you from generating your measure. What Azure documentation provide is a relative measure of network capacity for each VM SKU/SIZE as you can see in the table below:
<p style="padding-left: 30px"><strong><em>Sizes for virtual machines in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-sizes">https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-sizes</a></p>
If you look at column “<em>Max Network Bandwidth</em>”, you can find tags as LOW, MODERATE, HIGH, VERY HIGH, EXTREMELY HIGH. If you found in Internet, some old tables and information related to maximum network bandwidth for various VM SKUs, you should not trust them since outdated and Azure infrastructure evolved in the meanwhile. The only exceptions are Azure HPC instances where it is exactly specified the type of network adapter provided, that is 1 NIC 32Gbit/s and 1 NIC 10Gbit/s for A8/A9, and 1 NIC 10Gbit/s for A10/A11. See at the link below for more information:
<p style="padding-left: 30px"><strong><em>About H-series and compute-intensive A-series VMs for Windows </em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-a8-a9-a10-a11-specs">https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-a8-a9-a10-a11-specs</a></p>
&nbsp;

If you want to run performance tests on network throughput, be sure to use a tool able to provide multi-threaded connections. For both Windows and Linux, I recommend using <strong>NTttcp</strong> tool mentioned in the next paragraph and <strong>iPerf3</strong> for Linux only.
<h2><strong>Does Azure provide SLA on VM-to-VM network latency?</strong></h2>
During my tests and projects, Azure network Always provided excellent performances in terms of latency. At least at my knowledge, there is no Public Cloud vendor able to guarantee a maximum network latency, backed up by a formal SLA, between two different VMs. Since you don’t have much control over the Azure network infrastructure, there are few things you can try to optimize not only the latency but networking performances in general:
<ul>
 	<li>Chose the appropriate VM SKU since different ones have different networking equipment and then different underlying performances. As explained in the previous section, each VM SKU has a classification for networking capabilities, bandwidth is highlighted but also latency is different.</li>
 	<li>Place VMs that need to communicate frequently in the same Azure VNET: be aware that this will not guarantee single hop between all your VMs, with the introduction of regional VNETs, your virtual network can span multiple Azure Host Clusters in the same datacenter.</li>
 	<li>If you want to provide maximum proximity, and ensure VMs will be in the same Azure Host Cluster, you should put relevant VMs in the same Availability Set (AS): be aware that this is not what AS is intended for, this may have impacts on planned maintenance and availability of your VMs.</li>
 	<li>Even if still in preview, the best thing you can test is Azure “<em>Accelerated Networking</em>”, see previous section "<em>Does Azure support SR-IOV for accelerated networking</em>?" to discover how to do that.</li>
 	<li>Even if main improvement is for network throughput, enabling RSS at the Guest OS level, both Linux and Windows, can provide latency improvements, see previous section “<em>Can I use Receive Side Scaling (RSS) optimization in Azure VM?</em>” for more details.</li>
 	<li>For Linux, be sure to use the latest LIS driver: starting version <a href="https://www.microsoft.com/en-us/download/details.aspx?id=51612">4.1.3</a>, Microsoft introduced lots of performance improvements and some bug fixing, it’s highly recommended to upgrade this component.</li>
 	<li>If your VMs are in different VNETs connected using VPN or ExpressRoute, and are in the same region, consider using “<a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview">Virtual network peering</a>” instead.</li>
</ul>
It’s very easy to test yourself and have a good understanding of average latencies, but you need to be very careful on your test criteria. First of all, you need to test over various hours during the day including peak and non-peak hours, various days over the week including weekends and working days, then finally you should use calculate the average and consider a good percentile sampling near the 95% to eliminate peaks and occasional strange values. Additionally, don’t assume latencies will be the same in all Azure datacenters. If you want to do your own tests, for Windows, I would recommend you PSPING tool from SYSINTERNAL suite that you can find here: <a href="https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx">https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx</a>. What is nice regarding this tool, is that it will not use ICMP then no problem to traverse firewalls and load-balancers, you can decide which TCP port to use and, very important, you can test for throughput, not only for latency. If you want to do your networking tests using Linux, I would recommend also this tool, highly recommended if you want to test network throughput and performances:
<p style="padding-left: 30px"><strong><em>NTttcp Utility: Profile and Measure Windows Networking Performance</em></strong></p>
<p style="padding-left: 30px"><a href="https://gallery.technet.microsoft.com/NTttcp-Version-528-Now-f8b12769">https://gallery.technet.microsoft.com/NTttcp-Version-528-Now-f8b12769</a></p>
<p style="padding-left: 30px"><strong><em>NTTTCP-for-Linux</em></strong></p>
<p style="padding-left: 30px"><a href="https://github.com/Microsoft/ntttcp-for-linux">https://github.com/Microsoft/ntttcp-for-linux</a></p>

<h2><strong>Azure backend traffic will go through public Internet?</strong></h2>
Azure traffic between our datacenters stays on our network and does not flow over the Internet. This includes <em><u>all</u></em> traffic between Microsoft services anywhere in the world. For example, within Azure, traffic between virtual machines, storage, and SQL communication traverses only the Microsoft network, regardless of the source and destination region. <u>Intra-region</u> VNet-to-VNet traffic, as well as <u>cross-region</u> VNet-to-VNet traffic, stays on the Microsoft network., see the article below, authored by <strong>Yousef Khalidi </strong>(CVP, Azure Networking) for great and comprehensive details:
<p style="padding-left: 30px"> <strong><em>How Microsoft builds its fast and reliable global network</em></strong></p>
<p style="padding-left: 30px"> <a href="https://azure.microsoft.com/en-us/blog/how-microsoft-builds-its-fast-and-reliable-global-network">https://azure.microsoft.com/en-us/blog/how-microsoft-builds-its-fast-and-reliable-global-network</a></p>
Microsoft owns and operates its dark fibers to support WAN network connecting 38 Azure regions (at the time of writing this article) and 100s of datacenters. Customer traffic enters our global network through strategically placed Microsoft edge nodes, our points of presence (PoP). These edge nodes are directly interconnected to more than 2,500 unique Internet partners through thousands of connections in more than 130 locations.

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/13.jpg"><img width="748" height="378" class="aligncenter size-full wp-image-975" alt="13" src="https://msdnshared.blob.core.windows.net/media/2017/04/13.jpg" /></a>
<h2><strong>Can I white-list Azure public IP addresses? </strong></h2>
YES, all Azure public IP ranges are published at the link below. If you want to white-list, for security reasons, on your on-premise network you can do that selectively by region but not by service.
<p style="padding-left: 30px"><strong><em>Microsoft Azure Datacenter IP Ranges </em></strong></p>
<p style="padding-left: 30px"><a href="https://www.microsoft.com/en-us/download/details.aspx?id=41653">https://www.microsoft.com/en-us/download/details.aspx?id=41653</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/14.jpg"><img width="537" height="286" class="aligncenter wp-image-985" alt="14" src="https://msdnshared.blob.core.windows.net/media/2017/04/14.jpg" /></a>

From the link above you can download an XML file, divided in sections per regions but there is no way currently to retrieve the same information using an API. Azure Networking team is working to address this issue:
<p style="padding-left: 30px"><strong><em>Provide a rest api to access the list of Azure IP Addresses</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking/suggestions/7438096-provide-a-rest-api-to-access-the-list-of-azure-ip">https://feedback.azure.com/forums/217313-networking/suggestions/7438096-provide-a-rest-api-to-access-the-list-of-azure-ip</a></p>
If you rely on specific Azure resources, for example an Azure SQLDB instance or blob storage account, be aware that the assigned IP you will see, resolving their specific DNS names, may change without notice. <span style="color: #ff0000"><strong><u>IMPORTANT</u></strong></span>: don’t rely on any geo-location service for Internet IP used by Azure since may report incorrect information, for more details see the blog post below:
<p style="padding-left: 30px"><strong><em>Microsoft Azure’s use of non-US IPv4 address space in US regions</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/06/11/windows-azures-use-of-non-us-ipv4-address-space-in-us-regions">https://azure.microsoft.com/blog/2014/06/11/windows-azures-use-of-non-us-ipv4-address-space-in-us-regions</a></p>
Be aware that the internet facing public IP (VIP) associated to your resources may change under some conditions, if you need to be sure it will never happen, you need to enable "<em>Reserved IP</em>" feature as described at the blog post below:
<p style="padding-left: 30px"><strong><em>IP address types and allocation methods in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-ip-addresses-overview-arm">https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-ip-addresses-overview-arm</a></p>
If you still need to use legacy Cloud Services, see the article below on how to use Reserved IP using ASM API:
<p style="padding-left: 30px"><strong><em>Reserved IP addresses for Cloud Services &amp; Virtual Machines</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/05/14/reserved-ip-addresses">https://azure.microsoft.com/blog/2014/05/14/reserved-ip-addresses</a></p>

<h2><b><span>What is “*.internal.cloudapp.net” DNS suffix in Azure VM?</span></b></h2>
<span style="margin: 0px;color: black;line-height: 107%;font-family: 'Calibri',sans-serif;font-size: 11pt">If you build an Azure VM and join to an Azure Virtual Network and try to ping it using the VM host name (legacy Netbios name to be clear), this is what you will see:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/15.jpg"><img width="645" height="109" class="aligncenter wp-image-995" alt="15" src="https://msdnshared.blob.core.windows.net/media/2017/04/15.jpg" /></a>

As you can see in the picture, there are two strange parts in the FQDN: nothing strange in “<strong>cloudapp.net</strong>”, but what are “<strong>internal</strong>” and “<strong>a3</strong>”? You can easily guess that “<strong>internal</strong>” is the default DNS sub-zone that Azure internal DNS (iDNS) will use to host records for VMs and resolve to internal VM IP (DIP). “<strong>a3</strong>” instead is a little bit complex: in short, it’s describing the network zone, inside the specific Azure datacenter, where the VM is allocated. There is no official documentation or list of these zones, then don’t ask more, but please note that it will change not only between Azure datacenters, but also inside a single datacenter. You can programmatically retrieve internal DNS setting using the simple PowerShell command below:
<p style="padding-left: 30px"><span style="color: #0000ff">(Get-AzureRmNetworkInterface -Name "mynicname" -ResourceGroupName $rgname).DnsSettings.InternalFqdn</span></p>
Output will be something like the string below:

<span style="color: #0000ff">InternalDomainNameSuffix : 0fcdtenvgl4urm0sv5aj1xkcrc.fx.internal.cloudapp.net</span>
<h2> <strong>Which protocols Azure Load Balancer supports?</strong></h2>
Azure Load Balancer, for both external and internal connections, can support only TCP (Protocol ID “6”) or UDP (Protocol ID “17”). It cannot support protocols like ICMP (Protocol ID “1”). As an example, also IPSec (and VPN using it) is not supported since you should open UDP port 500 (that is fine) <em><u>and</u></em> permit IP protocol numbers 50 and 51. UDP Port 500 should be opened to allow Internet Security Association and Key Management Protocol (ISAKMP) traffic to be forwarded through Azure Load Balancer. IP protocol ID 50 should be set to allow IPSec Encapsulating Security Protocol (ESP) traffic to be forwarded. Finally, IP protocol ID 51 should be set to allow Authentication Header (AH) traffic to be forwarded. As additional note, since this would be interesting for some scenarios, Azure internal load balancer (ILB) does <strong><em>*not*</em></strong> support today “any-protocol/any-traffic”
<p style="padding-left: 30px"><strong><em>Protocol Numbers</em></strong></p>
<p style="padding-left: 30px"><a href="https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml">https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml</a></p>

<h2><strong>How many connections a VM can support?</strong></h2>
For Windows Server, a VM can support about 500k TCP connections but you need to be careful about other potential limits that may come into the game before this threshold: if you expose your VM to Internet traffic through an Azure Load Balancer endpoint, you may be limited by SLB capacity or DDOS security mechanisms. Actually, there is no public documentation on SLB or Endpoint limits, neither on the number of connection nor network bandwidth, then you should conduct your own performance tests to ensure everything will work correctly.

&nbsp;
<h2><strong>Can I have multiple VNET Gateways? </strong></h2>
Currently you can only have one virtual network Gateway per single VNET per single type, that is one for VPN and one for ExpressRoute. With VPN, if you configure multiple tunnels, they will share the same maximum network bandwidth. If you need more throughput for a VPN connection, you may want to consider using Network Virtual Appliances (NVA) or 3<sup>rd</sup>-party VPN software like OpenSwan and StrongSwan with big enough Azure VM SKUs/sizes.

&nbsp;
<h2><strong>ExpressRoute and VPN can coexist in the same VNET?</strong></h2>
YES, it is possible to have a VNET with gateways supporting ExpressRoute and VPN at the same time. The only requirement is to enable ExpressRoute before VPN. One Gateway per VNET restriction persists.
<p style="padding-left: 30px"><strong><em>New Networking Capabilities for a Consistent, Connected and Hybrid Cloud</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud">https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/16.png"><img width="610" height="577" class="aligncenter size-full wp-image-1015" alt="16" src="https://msdnshared.blob.core.windows.net/media/2017/04/16.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2017/04/16.jpg">
</a>
<h2><strong>Do I need a Gateway to connect my VNET to ExpressRoute?</strong></h2>
YES, if you want to use ExpressRoute (ER) to connect your VNET, you need to use and configure “<em>Private Peering</em>” routing domain, then you need to deploy a Virtual Network Gateway inside your Azure Virtual Network. This implies two important facts:
<ul>
 	<li>There are several Virtual Network Gateway sizes that can be used with ER circuits: be sure to use the right size (1000, 2000, 10000 Mbps) able to support your VNET traffic requirements, otherwise you will not be able to use all the bandwidth allocated to your circuit (50 Mbps, 100 Mbps, 200 Mbps, 500 Mbps, 1 Gbps, 10 Gbps).</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/17.jpg"><img width="835" height="184" class="aligncenter wp-image-1025" alt="17" src="https://msdnshared.blob.core.windows.net/media/2017/04/17.jpg" /></a>
<ul>
 	<li>Virtual Network Gateway, depending on the type, and ER circuit have different SLA, be sure to review this based on your requirements. We guarantee a minimum of 99.95% ExpressRoute Dedicated Circuit availability, and between 99,90% and 99,95% for the Gateway:</li>
</ul>
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/2017/04/18.jpg"><img width="789" height="198" class="aligncenter wp-image-1035" alt="18" src="https://msdnshared.blob.core.windows.net/media/2017/04/18.jpg" /></a></p>
<p style="padding-left: 30px"><strong><em>SLA for ExpressRoute</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/support/legal/sla/expressroute/v1_2">https://azure.microsoft.com/en-us/support/legal/sla/expressroute/v1_2</a></p>
<p style="padding-left: 30px"><strong><em>SLA for VPN Gateway</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/support/legal/sla/vpn-gateway/v1_2">https://azure.microsoft.com/en-us/support/legal/sla/vpn-gateway/v1_2</a></p>

<h2><strong>Can I connect VNETs inside and outside a region?</strong></h2>
YES, Azure provides three ways to connect VNETs: ExpressRoute, VPN and Virtual Network Peering. The last one has been recently released and permits to connect two VNETs in the <u>same region</u> without any gateway as for the other options. For this feature, there is a nominal fee based on the amount of GB transferred between the peered VNETs.
<p style="padding-left: 30px"><strong><em>Virtual Network Peering</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview">https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/19.jpg"><img width="698" height="229" class="aligncenter wp-image-1045" alt="19" src="https://msdnshared.blob.core.windows.net/media/2017/04/19.jpg" /></a>

With VPN, there is no boundary on the region, geography or subscription, essentially the tunnel only need Gateway VIPs to see each other. In case you need more throughput and lower latency, you can eventually use ExpressRoute technology to connect up to 100 VNETs and share circuits between them, even with different subscriptions. Before Premium add-on announced in May 2015, ExpressRoute posed limitations on geographical boundaries: now it is possible not only to connect VNETs in the same geography (US, Europe, etc.) but also across different geographies. For example, you can connect a VNET in West US to a VNET in North Europe.
<p style="padding-left: 30px"><strong><em>New Networking Capabilities for a Consistent, Connected and Hybrid Cloud</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud">https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud</a></p>

<h2><strong>Does Azure provide DDoS network protection?</strong></h2>
YES, Azure infrastructure is designed to protect the network from DDOS originating from the Internet and also internally from other tenants VMs, you can read the details in the white-paper below:
<p style="padding-left: 30px"><strong><em>Microsoft Azure Network Security Whitepaper version 3 is now available</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/blog/microsoft-azure-network-security-whitepaper-version-3-is-now-available">https://azure.microsoft.com/en-us/blog/microsoft-azure-network-security-whitepaper-version-3-is-now-available</a></p>
 Please be aware of the following important points:
<ul>
 	<li>Windows Azure’s DDoS defense system is designed not only to withstand attacks from the outside, but also from within.</li>
 	<li>Windows Azure monitors and detects internally initiated DDoS attacks and removes offending VMs from the network.</li>
 	<li>Windows Azure’s DDoS protection also benefits applications. However, it is still possible for applications to be targeted individually. As a result, customers should actively monitor their Windows Azure applications.</li>
</ul>
To augment your tenant security, you can deploy 3<sup>rd</sup>-party Network Virtual Appliances (NVA) in your Virtual Network, but be aware that custom DDoS to protect Azure public IPs (VIPs) is not supported.
<h2><strong>Are Broadcast and Multicast supported within Azure Virtual Network?</strong></h2>
This type of communication is not allowed inside a VNET or even across Azure Load Balancer.
<p style="padding-left: 30px"><strong><em>Support Multicast within Virtual Networks</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/suggestions/3741233-support-multicast-within-virtual-networks">https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/suggestions/3741233-support-multicast-within-virtual-networks</a></p>
You can use TCP, UDP, and ICMP TCP/IP protocols <u>within</u> VNets. Multicast, broadcast, IP-in-IP encapsulated packets, and Generic Routing Encapsulation (GRE) packets are blocked within VNets.
<h2><strong>Is it possible to run network penetration tests against my Azure VMs?</strong></h2>
YES, you can do that but it’s highly recommended to follow the specific procedure mentioned below, before running the test, otherwise Azure monitoring and defense systems will trigger in and blacklist your connections, IPs and/or VMs. Be sure your request will be approved before starting the test, you can find the form to fill-in at the bottom of the page URL reported below:
<p style="padding-left: 30px"><strong><em>Penetration Test Notification Process</em></strong></p>
<p style="padding-left: 30px"><a href="https://security-forms.azure.com/penetration-testing/terms">https://security-forms.azure.com/penetration-testing/terms</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/04/20.jpg"><img width="473" height="343" class="aligncenter size-full wp-image-1046" alt="20" src="https://msdnshared.blob.core.windows.net/media/2017/04/20.jpg" /></a>

<span style="margin: 0px;color: #333333;line-height: 107%;font-family: 'Calibri',sans-serif;font-size: 11pt"> </span>

Microsoft conducts regular penetration testing to improve Azure security controls and processes. We understand that security assessment is also an important part of our customers' application development and deployment. Therefore, we have established a policy for customers to carry out authorized penetration testing on their applications hosted in Azure. Because such testing can be indistinguishable from a real attack, it is critical that customers conduct penetration testing only after notifying Microsoft. Penetration testing must be conducted in accordance with our terms and conditions.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Azure Managed Disks Deep Dive, Lessons Learned and Benefits</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/azure-managed-disks-deep-dive-lessons-learned-and-benefits</link>
      <pubDate>Tue, 14 Mar 2017 11:42:02 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=736</guid>
      <description><![CDATA[[bing_translator]
Introduction
Managed Disks have been recently released for production (February...]]></description>
      <content:encoded><![CDATA[<h1>[bing_translator]</h1>
<h1><b><i><span><span style="color: #000000;font-family: Calibri">Introduction</span></span></i></b></h1>
<span>Managed Disks have been recently released for production (<em>February 2017</em>), and represent an important step to make Azure VM management much easier. In short, Azure Managed Disks feature is an abstraction built on top of current Standard and Premium storage disk in Azure Storage. Customers only need to specify the type (Standard or Premium) and size of disk they need in their selected Azure region, and Azure will create and manage the Disk accordingly. To be clear, Azure Storage Accounts are *not* going away yet, simply Azure will take care of their management on your behalf. Additionally, what will *not* change with MD is the maximum number of disks you can attach to your VM: same maximums listed in the article below apply, doesn’t matter if MD or Un-Managed (UMD - for brevity), what rules the ratio here is the number of cores of your VM.</span>
<p style="padding-left: 30px"><b><i><span style="color: #000000;font-family: Calibri">Sizes for Windows virtual machines in Azure</span></i></b></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes"><span style="color: #0563c1;font-family: Calibri">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes</span></a><span style="color: #000000;font-family: Calibri"> </span></p>
Finally, just to complete the picture of what remains the same, let me include disk size in this discussion: actually, in Azure the maximum size of disks you can create for a VM is 1TB, this is a cap originating from the maximum size of “<em>Page Blobs</em>” in the Azure Storage. Bigger disk sizes should come in the future, but it’s not directly tied to the MD concept and mechanism.
<h1><b><i><span><span style="color: #000000;font-family: Calibri">Benefits</span></span></i></b></h1>
<span>Then, after the bad news related to what remains the same, what is changing and why you should care about MD? </span><span>In some of my recent engagements for Microsoft Global ISVs, I had the opportunity to test in depth this new Azure feature, as a key feature requested for this project to go in production. </span><span>Why lack of MD was a hard blocker for this partner? Well, </span><span>MD</span><span> presents some unique capabilities and important differences compared to traditional </span><span>UMD. </span><span>This is the prioritized list I built looking to my recent engagements:</span>
<ul>
 	<li><b><span style="color: #000000;font-family: Calibri">Remove or relax Azure storage limits: </span></b><span style="color: #000000;font-family: Calibri">No more space or IOPs or storage bandwidth limits. </span></li>
 	<li><b><span style="color: #000000;font-family: Calibri">Disks as first-class objects</span></b><span style="color: #000000;font-family: Calibri">: provide CRUD operations, and security management, for disk objects independently from VM life-cycle.</span></li>
 	<li><b><span style="color: #000000;font-family: Calibri">Image Sharing: </span></b><span style="color: #000000;font-family: Calibri">No more image copy to target storage accounts, reference images between different storage accounts.</span></li>
 	<li><b><span style="color: #000000;font-family: Calibri">Higher VM resiliency: </span></b><span style="color: #000000;font-family: Calibri">Align Fault Domains (FD) concept for Storage with Compute.</span></li>
 	<li><b><span style="color: #000000;font-family: Calibri">Independent Snapshots</span></b><span style="color: #000000;font-family: Calibri">: creating a disk snapshot and then delete the source disk while retaining the generated snapshot.</span></li>
 	<li><b><span style="color: #000000;font-family: Calibri">Instant copy</span></b><span style="color: #000000;font-family: Calibri">: copy inside and across storage accounts must be instantaneous in the same region.</span></li>
</ul>
<span> </span><span>I</span><span>’</span><span>m going to explain you in details the above key benefits and important details you will need to keep in mind, but let me start with two obvious things: MD is ARM (Azure Resource Manager) feature only, no plans to back-port for ASM (Azure Service Management), and NO</span><span>…</span><span> Microsoft is not retiring UMD, even if this is the default in the Azure Portal and recommended going forward.</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/18.jpg"><img width="239" height="335" class="aligncenter wp-image-745" alt="1" src="https://msdnshared.blob.core.windows.net/media/2017/03/18.jpg" /></a>

<span>Then, you don</span><span>’</span><span>t need to use UMD anymore? Well, not exactly. There are few situations where you may still need to use them for Azure VMs:</span>
<ul>
 	<li><strong><span> </span><span>VM Diagnostics</span></strong><span>: for diagnostic and boot logs, you still need to use </span><span>“</span><span>legacy</span><span>”</span><span> storage accounts, there is a plan to remove this in the future, but for the moment you have to do in the same old way. You can use MD for your VM OS and Data disks, but you will also need to specify a storage account where this information will be landed. </span></li>
 	<li><strong><span>Storage Replication</span></strong><span>: actually, MD are Locally Replicated Storage (LRS) only, if you need GRS for example, you need to use UMD.</span></li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/03/29.jpg"><img width="228" height="174" class="aligncenter wp-image-755" alt="2" src="https://msdnshared.blob.core.windows.net/media/2017/03/29.jpg" /></a>

<span>For a complete description of Storage Resiliency options, please consult the article below:</span>
<p style="padding-left: 30px"><strong><span lang="IT"><span>Azure Storage replication</span></span></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/storage/storage-redundancy"><span lang="IT"><span>https://docs.microsoft.com/en-us/azure/storage/storage-redundancy</span></span></a><span lang="IT"><span> </span></span></p>
<span style="text-decoration: underline"><strong><span>NOTE</span></strong></span><span>: I will *</span><em><span>not</span></em><span>* cover here Azure Virtual Machine Scale Set (VMSS) enhancements due to Managed Disks, but if interested you should read the article below:</span>
<p style="padding-left: 30px"><strong><em><span>Azure VM scale sets and managed disks</span></em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-managed-disks"><span>https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-managed-disks</span></a><span>  </span><span> </span></p>

<ul>
 	<li><em><span>You no longer need to pre-create and manage storage accounts to store the OS disks for the scale set VMs.</span></em></li>
 	<li><em><span>You can attach managed data disks to the scale set.</span></em></li>
 	<li><em><span>With managed disk, a scale set can have capacity as high as 1,000 VMs if based on a platform image or 100 VMs if based on a custom image.</span></em></li>
</ul>
&nbsp;
<h2><b><span><span style="color: #000000;font-family: Calibri">Remove or Relax Azure Storage limits</span></span></b></h2>
<span>Based on my partners and customer’s feedbacks, one of most annoying Azure consideration is the variety of caps we have on storage: both in ARM and ASM, we have limits on the maximum number of storage accounts, maximum size for storage accounts, IOPS and storage bandwidth limits. If you have to manage many VMs, my experience here is in the order of 1000s, you will be forced to do some calculations and build a logic in your deployment engine to keep track of disks you deployed and in which storage accounts. On Standard storage, even if you have 500TB space, you are limited to 20K IOPS, then you should not place more than 40 disks on single account, since each one will consume at the maximum 500 IOPS. This is even more difficult if you use Premium Storage since have different limits (35TBs vs. 500TBs, etc.) and recommendations on how to allocate VMs compared to Standard Storage. Here the calculation you have to do is about disk allocated size. Indeed, this complexity does not exist on some other Public Cloud providers. </span><span>With MD, now all these limits are gone.</span><span> </span><span>Something remains but I</span><span>’</span><span>m sure will be reasonable for your you:</span>
<ul>
 	<li><span>Maximum number of disks you can attach per VM doesn</span><span>’</span><span>t change, as I mentioned in the introduction, since not dependent on MD feature.</span>
<ul>
 	<li><span>Max IOPS Per VM limit is still 80,000 IOPS with GS5, max throughput per VM is still 2,000 MB/s with GS5 (<em>may change in the future</em>)</span></li>
 	<li><span>Also, maximum disk size doesn</span><span>’</span><span>t change (<em>yet</em>).</span></li>
</ul>
</li>
 	<li><span>There is a default soft-limit, that can be increased, on the maximum number of MD: it is 2000, is </span><span>per</span><span> subscription and </span><span>per</span><span> region, but can be increased opening a ticket with Azure Support. </span>
<ul>
 	<li><span>In one specific case I was able to obtain 30K disks</span><span>. </span></li>
 	<li><span>It is worth noting that this limit includes not only MD disks, but also the snapshots you create  for these.</span></li>
</ul>
</li>
</ul>
<span style="color: #000000;font-family: Calibri"> </span><span>You can create MD using either Standard or Premium storage, as with UMD, but there is an important difference: now, with MD, including using Standard storage, you have a set of fixed sizes at disk creation time. </span><span>This does not mean that you cannot create a disk of arbitrary size, it simply says that you will pay for closest rounded high tier limit for declared size: for example, if you create a </span><span>200GB</span><span> Standard MD, you will pay for </span><span>S20</span><span>, based on the table below. This may change in the future.</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/36.jpg"><img width="957" height="416" class="aligncenter wp-image-765" alt="3" src="https://msdnshared.blob.core.windows.net/media/2017/03/36.jpg" /></a>
<p style="text-align: center"><span style="text-decoration: underline"><strong><em>Table 1.1</em></strong></span></p>
<span>These are the two key articles to consult for more details for this context discussion:</span>

<span> </span>
<p style="padding-left: 30px"><strong><em><span>Azure subscription and service limits, quotas, and constraints</span></em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits"><span>https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits</span></a><span> </span></p>
<span> </span>
<p style="padding-left: 30px"><em><strong><span>Azure Storage Scalability and Performance Targets</span></strong></em></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/storage/storage-scalability-targets"><span>https://docs.microsoft.com/en-us/azure/storage/storage-scalability-targets</span></a><span> </span></p>
<span style="color: #000000;font-family: Calibri"> </span>
<h2><span>Disks as First-Class objects</span></h2>
Some of my partners never noticed in the past, but in ARM you were not able to create a disk as a standalone object: without MD, you cannot create, for example, an empty disk of 256GB and attach later to one of your VMs. You must import from a blob or create and attach as a unique operation at VM creation time. This is a simple code snippet that shows empty MD creation and, later on, check if deployment “<em>ProvisioningState</em>” is “<em>Succeeded</em>”:
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdiskconfig1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmDiskConfig</span><span style="color: #000000"> </span><span>-AccountType</span><span style="color: #000000"> </span><span>StandardLRS</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$location</span><span style="color: #000000"> </span><span>-DiskSizeGB</span><span style="color: #000000"> </span><span>256</span><span style="color: #000000"> </span><span>-CreateOption</span><span style="color: #000000"> </span><span>Empty</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdisk1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmDisk</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-Disk</span><span style="color: #000000"> </span><span>$mdiskconfig1</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>"EmptyManagedDiskMD1"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ref1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> (</span><span>Get-AzureRmDisk</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>"EmptyManagedDiskMD1"</span><span style="color: #000000">)</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Write-Host</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> (</span><span>'Disk Provisioning State -&gt; [ '</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> (</span><span>$ref1</span><span>.</span><span style="color: #000000">ProvisioningState) </span><span>+</span><span style="color: #000000"> </span><span>' ]'</span><span style="color: #000000">)</span></span></p>
<span>Note that MD PowerShell cmdlets are included in the "</span><em>AzureRM.Compute</em><span>" module, not in the "</span><em>AzureRM.Storage</em><span>". This should not be a surprise if you think carefully about what is MD, that is an abstraction on top of Azure Storage. Let me add another interesting fact: you don</span><span>’</span><span>t specify, and you don</span><span>’</span><span>t see, any VHD URL. Azure MD resource provider will manage this for you, simply specify the disk you want, in terms of size and type (Standard or Premium), and Azure will create where you want it with a specified name. If you want, you can get access to the underlying URL, sometimes maybe necessary for example for copy operations, here is the API or PowerShell cmdlet you can use, secured using SAS signature mechanism:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/46.jpg"><img width="681" height="82" class="aligncenter wp-image-766" alt="4" src="https://msdnshared.blob.core.windows.net/media/2017/03/46.jpg" /></a>
<p style="padding-left: 120px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Grant-AzureRmDiskAccess</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>'EmptyManagedDiskMD1'</span><span style="color: #000000"> </span><span>-Access</span><span style="color: #000000"> </span><span>'Read'</span><span style="color: #000000"> </span><span>-DurationInSecond</span><span style="color: #000000"> </span><span>60</span></span></p>
<p style="padding-left: 120px"><b><span style="color: #000000;font-family: Calibri">OUTPUT </span></b><i><span style="color: #000000;font-family: Calibri">(scrambled to hide real data):</span></i></p>
<p style="padding-left: 120px"><a href="https://md-grkhtgdfazmdr.blob.core.windows.net/ldc1j5nxwxzg/abcd?sv=2014-02-14&amp;sr=b&amp;si=9049d2762-524e-4911-a953-9ca72e0ed256&amp;sig=TFl2jGt8FkkC1Xi970QcfxvLmepqW3vxORPQWU12bjI%3D"><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #0563c1">https://md-grkhtgdfazmdr.blob.core.windows.net/ldc1j5nxwxzg/abcd?sv=2014-02-14&amp;sr=b&amp;si=9049d2762-524e-4911-a953-9ca72e0ed256&amp;sig=TFl2jGt8FkkC1Xi970QcfxvLmepqW3vxORPQWU12bjI%3D</span></span></a><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"> </span></p>
<span>The output is also pretty interesting: storage account, blob and container names are auto (<em>random?</em>) generated, and the URL starts with a </span><span>“</span><em>md</em><span>”</span><span> prefix. You are still not convinced, here is the REST API to create a single MD object (I included </span><span>“</span><em><span>Snapshot</span></em><span>”</span><span> for completeness), please note the </span><span>“</span><em><span>path</span></em><span>”</span><span> used in the URL:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/55.jpg"><img width="615" height="115" class="aligncenter wp-image-775" alt="5" src="https://msdnshared.blob.core.windows.net/media/2017/03/55.jpg" /></a>

<span>Then, just to summarize, you can still create a Managed Disk (MD) in </span><span>implicit</span><span> mode at VM creation time, but you can now also create it in </span><span>explicit</span><span> mode, using one of these methods:</span>
<ul>
 	<li><span>Copy of a Platform Image Repository (PIR) image disk</span></li>
 	<li><span>Import of a VHD from a public storage blob</span></li>
 	<li><span>Creation of an empty disk</span></li>
 	<li><span>Copy of an existing disk or snapshot</span></li>
</ul>
<span>At the end, Azure finally provides full CRUD operations for Managed Disks, you can also resize (<em>only up!</em>), delete and create snapshots on them:</span>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Resize of the disk: #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ref1</span><span style="margin: 0px;color: darkgray;font-family: 'Lucida Console';font-size: 9pt">.</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000">DiskSizeGB </span><span>=</span><span style="color: #000000"> </span><span>512</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Update-AzureRmDisk</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>$ref1</span><span>.</span><span style="color: #000000">Name </span><span>-Disk</span><span style="color: #000000"> </span><span>$ref1</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ref1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> (</span><span>Get-AzureRmDisk</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>"EmptyManagedDiskMD1"</span><span style="color: #000000">)</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ref3</span><span style="margin: 0px;color: darkgray;font-family: 'Lucida Console';font-size: 9pt">.</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000">DiskSizeGB</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ref3</span><span style="margin: 0px;color: darkgray;font-family: 'Lucida Console';font-size: 9pt">.</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000">ProvisioningState</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Create a snapshot on the Managed Disk: #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdisksnapshotconfig1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmSnapshotConfig</span><span style="color: #000000"> </span><span>-AccountType</span><span style="color: #000000"> </span><span>StandardLRS</span><span style="color: #000000"> </span><span>-DiskSizeGB</span><span style="color: #000000"> </span><span>512</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$location</span><span style="color: #000000"> </span><span>-SourceUri</span><span style="color: #000000"> </span><span>$ref1</span><span>.</span><span style="color: #000000">Id  </span><span>-CreateOption</span><span style="color: #000000"> </span><span>Copy</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdisksnapshot1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmSnapshot</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-SnapshotName</span><span style="color: #000000"> </span><span>"EmptyManagedDiskMD1snaphot1"</span><span style="color: #000000"> </span><span>-Snapshot</span><span style="color: #000000"> </span><span>$mdisksnapshotconfig1 </span></span></p>
<span>Finally, let me include the diagram below, I</span><span>’</span><span>m sure will definitely clarify the relationship between MD main object type and the other objects that I</span><span>’</span><span>m going to cover later in this post, that is "<em>Snapshots</em>" and "<em>Images</em>".</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/65.jpg"><img width="761" height="428" class="aligncenter wp-image-785" alt="6" src="https://msdnshared.blob.core.windows.net/media/2017/03/65.jpg" /></a>
<h2><span>Image Sharing</span></h2>
<span>This functional aspect was very important for my partners, due to the nature of how VM images are built. What I have seen pretty frequently is the requirement to build images in a central Azure subscription, then deploy VMs in other subscriptions, using several/many storage accounts. It doesn</span><span>’</span><span>t matter if you use Standard or Premium storage account, you had to copy the image in the target storage account before being able to create a VM from there. Now with Managed Disks (MD) this is not necessary anymore, you can create VMs in a subscription using an image (MD-based) that can reside in any storage account of the same subscription. But what happens if you need to copy your image across subscriptions? At the moment, Managed Disks (MD) don</span><span>’</span><span>t provide this feature, but I would be not surprised to hear important updates in the near future. In the meanwhile, a practical workaround to use includes these simple steps: get Image underlying URL/SAS, use tools (<em>AzCopy</em>) or API/PowerShell to copy the blob to a target storage account in the target subscription, then create an image in the target subscription using that blob and its URL. In the example below, I realized a slightly different scenario, that is I</span><span>’</span><span>m starting from a VM (generalized) in a source subscription to create an image in the target subscription.</span>

<span style="color: #000000;font-family: Calibri"> </span>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># This is the source VM for the Image copy and other necessary parameters: #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VMName</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>"&lt;&lt;VM Name&gt;&gt;"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$sourcergname</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>"&lt;&lt;source resource group&gt;&gt;"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$targetrgname</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>"&lt;&lt;destination resource group&gt;&gt;"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ImageName</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>"&lt;&lt;image name&gt;&gt;"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$storageacccountname</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>"&lt;&lt;storage account name&gt;&gt;"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$containername</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>"images"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmVM</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$sourcergname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$VMName</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$OSDiskName</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>$VMName</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>"-osDisk"</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$OSDisk</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmDisk</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$sourcergname</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>$OSDiskName</span></span></p>
<span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span></span>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Stop VM, Generalize and get access to OS Managed Disk's underlying blob URL: #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Stop-AzureRmVM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$sourcergname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$VMName</span><span style="color: #000000"> </span><span>-Force</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Set-AzureRmVm</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$sourcergname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$VMName</span><span style="color: #000000"> </span><span>-Generalized</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdiskURL</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Grant-AzureRmDiskAccess</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$sourcergname</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>$VM</span><span>.</span><span style="color: #000000">StorageProfile</span><span>.</span><span style="color: #000000">OsDisk</span><span>.</span><span style="color: #000000">Name </span><span>-Access</span><span style="color: #000000"> </span><span>Read</span><span style="color: #000000"> </span><span>-DurationInSecond</span><span style="color: #000000"> </span><span>3600</span></span></p>
<span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span></span>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Now copy out the Managed Disk using SAS as a "normal" VHD in a "normal" target storage account #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$storageacccountkey</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmStorageAccountKey</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$targetrgname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$storageacccountname</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$storagectx</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureStorageContext</span><span style="color: #000000"> </span><span>-StorageAccountName</span><span style="color: #000000"> </span><span>$storageacccountname</span><span style="color: #000000"> </span><span>-StorageAccountKey</span><span style="color: #000000"> </span><span>$storageacccountkey</span><span>[</span><span>0</span><span>].</span><span style="color: #000000">Value</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$targetcontainer</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureStorageContainer</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$containername</span><span style="color: #000000"> </span><span>-Context</span><span style="color: #000000"> </span><span>$storagectx</span><span style="color: #000000"> </span><span>-Permission</span><span style="color: #000000"> </span><span>Blob</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$targetcontainer</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureStorageContainer</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"images"</span><span style="color: #000000"> </span><span>-Context</span><span style="color: #000000"> </span><span>$storagectx</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$destdiskname</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>$VM</span><span>.</span><span style="color: #000000">StorageProfile</span><span>.</span><span style="color: #000000">OsDisk</span><span>.</span><span style="color: #000000">Name </span><span>+</span><span style="color: #000000"> </span><span>".vhd"</span><span style="color: #000000">;</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$sourceSASurl</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>$mdiskURL</span><span>.</span><span style="color: #000000">AccessSAS</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$ops</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Start-AzureStorageBlobCopy</span><span style="color: #000000"> </span><span>-AbsoluteUri</span><span style="color: #000000"> </span><span>$sourceSASurl</span><span style="color: #000000"> </span><span>-DestBlob</span><span style="color: #000000"> </span><span>$destdiskname</span><span style="color: #000000"> </span><span>-DestContainer</span><span style="color: #000000"> </span><span>$targetcontainer</span><span>.</span><span style="color: #000000">Name </span><span>-DestContext</span><span style="color: #000000"> </span><span>$storagectx</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Get-AzureStorageBlobCopyState</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Container</span><span style="color: #000000"> </span><span>$targetcontainer</span><span>.</span><span style="color: #000000">Name </span><span>-Blob</span><span style="color: #000000"> </span><span>$destdiskname</span><span style="color: #000000"> </span><span>-Context</span><span style="color: #000000"> </span><span>$storagectx</span><span style="color: #000000"> </span><span>-WaitForComplete</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$sourceimagediskBlob</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureStorageBlob</span><span style="color: #000000"> </span><span>-Context</span><span style="color: #000000"> </span><span>$storagectx</span><span style="color: #000000"> </span><span>-Container</span><span style="color: #000000"> </span><span>$targetcontainer</span><span>.</span><span style="color: #000000">Name </span><span>-Blob</span><span style="color: #000000"> </span><span>$destdiskname</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$sourceimagediskURL</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> (</span><span>$sourceimagediskBlob</span><span>.</span><span style="color: #000000">Context</span><span>.</span><span style="color: #000000">BlobEndPoint) </span><span>+</span><span style="color: #000000"> </span><span>$containername</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>"/"</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>$destdiskname</span><span style="color: #000000">;</span></span></p>
<span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span></span>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Finale step: create image from local copied VHD: #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$targetimagecfg</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmImageConfig</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$location</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Set-AzureRmImageOsDisk</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Image</span><span style="color: #000000"> </span><span>$targetimagecfg</span><span style="color: #000000"> </span><span>-OsType</span><span style="color: #000000"> </span><span>'Linux'</span><span style="color: #000000"> </span><span>-OsState</span><span style="color: #000000"> </span><span>'Generalized'</span><span style="color: #000000"> </span><span>-BlobUri</span><span style="color: #000000"> </span><span>$sourceimagediskURL</span><span style="color: #000000">;</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$targetimage</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmImage</span><span style="color: #000000"> </span><span>-Image</span><span style="color: #000000"> </span><span>$targetimagecfg</span><span style="color: #000000"> </span><span>-ImageName</span><span style="color: #000000"> </span><span>$ImageName</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$targetrgname</span></span></p>
Now that you have your “<em>golden</em>” image in your target subscription, and in the specific region, you can create as many VMs you want, without the need to copy into all target storage accounts. For the cross-subscription and cross-account copy, PowerShell makes available the most efficient API: “<em>Start-AzureStorageBlobCopy</em>” is extremely fast and support parallel copy by defaults using multiple threads. As an alternative, you may also use AzCopy tool, the underlying REST API is the same. One final note: In this specifc sample, be sure to follow generalization steps specific for your VM Guest OS (see below), then stop your VM.

&nbsp;
<p style="padding-left: 30px"><strong><em>Generalize a Windows virtual machine using Sysprep</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-generalize-vhd">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-generalize-vhd</a></p>
<p style="padding-left: 30px"><strong><em>How to generalize and capture a Linux virtual machine</em></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-capture-image">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-capture-image</a></p>
&nbsp;

Be careful before deciding to drop the original disk, or snapshot or VM, you used to create your image: image is a regional-scoped object, then if you want to create the image in a new region, at least today, you have to copy manually the VM, disk or snapshot to the target region, then create a new image object based on that source. Name is not mandatory to be the same, but if you want your code to run without modification, you need to use the same one. Process is pretty simple, for example using Snapshots: you need to get access to the underlying blob objects via SAS token, then copy to the target destination region <span style="text-decoration: underline">as a blob</span>, then create a new image using the same name (<em>optional</em>) using the copied snapshot. Code sample (<em>not complete</em>) is reported below:
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$TargetStorageAcccountkey</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmStorageAccountKey</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$TargetStorageAcccountName</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$TargetStorageCTX</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureStorageContext</span><span style="color: #000000"> </span><span>-StorageAccountName</span><span style="color: #000000"> </span><span>$TargetStorageAcccountName</span><span style="color: #000000"> </span><span>-StorageAccountKey</span><span style="color: #000000"> </span><span>$TargetStorageAcccountkey</span><span>[</span><span>0</span><span>].</span><span style="color: #000000">Value</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">New-AzureStorageContainer</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$TargetContainerName</span><span style="color: #000000"> </span><span>-Context</span><span style="color: #000000"> </span><span>$TargetStorageCTX</span><span style="color: #000000"> </span><span>-Permission</span><span style="color: #000000"> </span><span>Container</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$Snapshot</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmSnapshot</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-SnapshotName</span><span style="color: #000000"> </span><span>$SourceSnapshotName</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$SnapshotSASurl</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Grant-AzureRmSnapshotAccess</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-SnapshotName</span><span style="color: #000000"> </span><span>$SourceSnapshotName</span><span style="color: #000000"> </span><span>-DurationInSecond</span><span style="color: #000000"> </span><span>3600</span><span style="color: #000000"> </span><span>-Access</span><span style="color: #000000"> </span><span>Read</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Start-AzureStorageBlobCopy</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-AbsoluteUri</span><span style="color: #000000"> </span><span>$SnapshotSASurl</span><span>.</span><span style="color: #000000">AccessSAS </span><span>-DestContainer</span><span style="color: #000000"> </span><span>$TargetContainerName</span><span style="color: #000000"> </span><span>-DestContext</span><span style="color: #000000"> </span><span>$TargetStorageCTX</span><span style="color: #000000"> </span><span>-DestBlob</span><span style="color: #000000"> </span><span>$DestBlob</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$TargetImageConfig</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmImageConfig</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$TargetLocation</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$osDiskVhdUri</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> (</span><span>$TargetStorageCTX</span><span>.</span><span style="color: #000000">BlobEndPoint </span><span>+</span><span style="color: #000000"> </span><span>"</span><span>$TargetContainerName</span><span>"</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>"/"</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>$DestBlob</span><span style="color: #000000">)</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Set-AzureRmImageOsDisk</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Image</span><span style="color: #000000"> </span><span>$TargetImageConfig</span><span style="color: #000000"> </span><span>-OsType</span><span style="color: #000000"> </span><span>'Linux'</span><span style="color: #000000"> </span><span>-OsState</span><span style="color: #000000"> </span><span>'Generalized'</span><span style="color: #000000"> </span><span>-BlobUri</span><span style="color: #000000"> </span><span>$osDiskVhdUri</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">New-AzureRmImage</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Image</span><span style="color: #000000"> </span><span>$TargetImageConfig</span><span style="color: #000000"> </span><span>-ImageName</span><span style="color: #000000"> </span><span>$ImageName</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000">(</span><span>Get-AzureRmImage</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000">) </span><span>|</span><span style="color: #000000"> </span><span>select</span><span style="color: #000000"> </span><span>Name</span><span>,</span><span>Location</span><span>,</span><span>ProvisioningState</span></span></p>
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/2017/03/73.jpg"><img width="372" height="109" class="wp-image-795 aligncenter" alt="7" src="https://msdnshared.blob.core.windows.net/media/2017/03/73.jpg" /></a></p>
&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/82.jpg"><img width="474" height="107" class="wp-image-805 aligncenter" alt="8" src="https://msdnshared.blob.core.windows.net/media/2017/03/82.jpg" /></a>

&nbsp;
<h2><span>Higher VM resiliency</span></h2>
<span>This is my favorite improvement, long waited for several of my partners. To better explain this, let me start with a bit of history to set the context. In the </span><span>“</span><em><span>old</span></em><span>”</span><span> ASM days, Azure guaranteed (and do it also today) only two </span><span>“</span><em><span>Fault Domains</span></em><span>”</span><span> (FD). Only with the introduction of ARM, is possible to have guaranteed three FDs. Then, what MD provides on top of ARM? While you are reading here, I would suggest to also give a quick look at the picture below: essentially, without MD you don</span><span>’</span><span>t have control over placements of your disks. Traditional Un-Managed Disks (NMD) reside in storage accounts, even if you use different ones for different VMs, there is no guarantee that these accounts (and contained disks) will be placed in different Azure Storage </span><span>“</span><em><span>Storage Units</span></em><span>”</span><span> (or </span><span>“</span><em><span>Stamps</span></em><span>”</span><span>). MD resolves this problem for you: since you don</span><span>’</span><span>t have to care anymore about storage accounts, MD will ensure (</span><span>if requested</span><span>) that your VMs disks will be placed in different </span><span>“</span><em><span>Storage Units</span></em><span>”</span><span>, then maximizing the resiliency for your deployment. Let me be clear here: for what is concerning Azure VM High-Availability SLA, nothing is changing here, you still have 99.95% for multiple VMs (&gt;1) inside a specific Availability Set, and 99.90% for single instances using Premium Storage. This is an enhancement for resiliency, not a fix for a bug of our previous infrastructure behavior.</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/92.jpg"><img width="772" height="434" class="aligncenter wp-image-815" alt="9" src="https://msdnshared.blob.core.windows.net/media/2017/03/92.jpg" /></a>
<p style="padding-left: 90px"><strong><u>NOTE</u></strong>: <em>The number of managed disk fault domains varies by region - either two or three managed disk fault domains per region.</em></p>
Once you created Availability Set (AS)  as “<em>aligned</em>”, you will be allowed to put in there only VMs that are using MD, mixing with UMD VMs will return an error. It is also worth mentioning that, at the moment, it is not possible to change AS for a VM after creation, this is something that may change in the future, but today this is the status. Be careful with MD defaults: in order to have this alignment between Compute and Storage FDs, you have to use explicitly a special crafted AS object that requires a specific parameter in its creation, this is shown in the PowerShell cmdlet below.
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Un-Managed Availability Sets (AS): #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">New-AzureRmAvailabilitySet</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>"West Europe"</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"MyNewUnManagedAS1"</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-PlatformFaultDomainCount</span><span style="color: #000000"> </span><span>3</span><span style="color: #000000"> </span><span>-PlatformUpdateDomainCount</span><span style="color: #000000"> </span><span>20</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">New-AzureRmAvailabilitySet</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Sku</span><span style="color: #000000"> </span><span>"Classic"</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>"West Europe"</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"MyNewUnManagedAS2"</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-PlatformFaultDomainCount</span><span style="color: #000000"> </span><span>3</span><span style="color: #000000"> </span><span>-PlatformUpdateDomainCount</span><span style="color: #000000"> </span><span>20</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Managed Availability Sets (AS): #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">New-AzureRmAvailabilitySet</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Managed</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>"West Europe"</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"MyNewManagedAS3"</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-PlatformFaultDomainCount</span><span style="color: #000000"> </span><span>3</span><span style="color: #000000"> </span><span>-PlatformUpdateDomainCount</span><span style="color: #000000"> </span><span>20</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">New-AzureRmAvailabilitySet</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-Sku</span><span style="color: #000000"> </span><span>"Aligned"</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>"West Europe"</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"MyNewManagedAS4"</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-PlatformFaultDomainCount</span><span style="color: #000000"> </span><span>3</span><span style="color: #000000"> </span><span>-PlatformUpdateDomainCount</span><span style="color: #000000"> </span><span>20</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: darkgreen;font-family: 'Lucida Console';font-size: 9pt"># Check if AS is "managed" or not in two different ways: #</span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$rg1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> (</span><span>Get-AzureRmAvailabilitySet</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"MyNewUnManagedAS1"</span><span style="color: #000000">)</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Write-Host</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> (</span><span>"Is ["</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>$rg1</span><span>.</span><span style="color: #000000">Name </span><span>+</span><span style="color: #000000"> </span><span>"] Availability Set Managed? "</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>$rg1</span><span>.</span><span style="color: #000000">Managed </span><span>+</span><span>"..."</span><span style="color: #000000">)</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$rg2</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> (</span><span>Get-AzureRmAvailabilitySet</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>"MyNewManagedAS4"</span><span style="color: #000000">)</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Write-Host</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> (</span><span>"How ["</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>$rg2</span><span>.</span><span style="color: #000000">Name </span><span>+</span><span style="color: #000000"> </span><span>"] Availability Set is? "</span><span style="color: #000000"> </span><span>+</span><span style="color: #000000"> </span><span>$rg2</span><span>.</span><span style="color: #000000">Sku </span><span>+</span><span>"..."</span><span style="color: #000000">) </span></span></p>
&nbsp;

<span>As you can see from the code snippet above, there are multiple ways to achieve the same configuration:</span>
<ul>
 	<li><span>By default, a new Availability Set (AS) is created as standard type, that is no alignment of Storage FDs with Compute FDs (</span><em><span>first command</span></em><span>).</span></li>
 	<li><span>If you want to do the same as above, but specifying explicitly, you can do specifying value </span><span>“</span><em><strong><span>Classic</span></strong></em><span>”</span><span> for parameter </span><span>“</span><em><strong><span>-Sku</span></strong></em><span>”</span><span> (</span><em><span>second command</span></em><span>).</span></li>
 	<li><span>The new type of AS can be created specifying </span><span>“</span><strong><em><span>-Managed</span></em></strong><span>”</span><span> flag (</span><em><span>third command</span></em><span>).</span></li>
 	<li><span>Same configuration as the previous one can be obtained specifying </span><span>“</span><strong><em><span>Aligned</span></em></strong><span>”</span><span> for the parameter </span><span>“</span><strong><em><span>-Sku</span></em></strong><span>”</span><span> (</span><em><span>fourth command</span></em><span>)</span></li>
</ul>
<span>At the end, if you want to create a new Availability Set for VMs with Managed Disks that you want “</span><em><span>aligned</span></em><span>”, you can either specify “</span><strong><em><span>-Managed</span></em></strong><span>” or “</span><span>-</span><strong><em><span>Sku Aligned</span></em></strong><span>”, but the latter is recommended since the former may be removed in the future. This is how it looks like now using Azure PowerShell module </span><em><span>version 2.7.0</span></em><span> (</span><em><span>February 2017</span></em><span>) for </span><strong><span>AzureRm.Compute</span></strong><span>:</span>
<p style="padding-left: 210px"><a href="https://msdnshared.blob.core.windows.net/media/2017/03/101.jpg"><img width="231" height="354" class="wp-image-825 alignleft" alt="10" src="https://msdnshared.blob.core.windows.net/media/2017/03/101.jpg" />
</a></p>
&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

<span>For more information on Azure Virtual Machines and availability, you can reach the URL below:</span>
<p style="padding-left: 30px"><span> </span><strong><span><em>Manage the availability of Windows virtual machines in Azure</em> </span></strong></p>
<p style="padding-left: 30px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-manage-availability"><span>https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-manage-availability</span></a></p>

<h4>Higher VM resiliency – Data Disks</h4>
Same approach described for OS disks is valid also for Data Disks. You don’t have to worry about that: MD mechanism will take care of segregating storage accounts used to host Data Disks in different Storage Stamps, then aligning with Compute Fault Domains (FDs). Best practices in use before MD will remain valid: keep all Disks (OS and Data) associated with a VM in the same Storage Account, but in this case Azure will enforce it behind the scenes. It is worth mentioning that if you add a MD Data Disk later, after VM creation time, Azure will ensure to place in the correct Fault Domain (FD), eventually moving it to a different managed storage account. In this way, resiliency will not be diminished introducing a dependency on an object in a different FD.

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/20.jpg"><img width="367" height="402" class="aligncenter wp-image-855" alt="20" src="https://msdnshared.blob.core.windows.net/media/2017/03/20.jpg" /></a>
<h3><span>Independent Snapshots</span></h3>
<span>Snapshot of a MD is something totally different from what you may know already for classic UMD. Aligning the design with what other cloud providers do, Snapshots here are totally independent from the MD object: once created, you can delete the source MD and the Snapshot will survive. This new paradigm is more consistent with the concept of a read-only copy of some another object. You can create as many snapshots as you want on the same MD, I tried 500 personally, there is no hard limit as far as I know, but without noticing performance degradation of the source MD. This makes Snapshots suitable for Point-in-Time (<em>PIT</em>) backups of MD. Keep in mind that you will pay for the snapshot size as an allocated MD space, finally at the moment Snapshots on MD are not incremental but fully copy, this is something that may change in the future. Regarding resource allocation limit, there is no specific Snapshots limit per region per subscription, they are counted against the same cumulative quota with MD as I wrote previously. Since Snapshots are independent objects, sourced with a copy operation from MD, you can have a Snapshot created on Premium Storage originating from a MD allocated on Standard Storage, and vice-versa, if you don</span><span>’</span><span>t specify a storage type, Standard will be used. They also support encryption at the disk level, but not Storage Service Encryption (SSE) for Data at Rest, this will come in the future. These are the typical operations that you could do with MD Snapshots, in relationships with the other object types (<em>VM, Image, Managed Disk, VHD/Blob</em>):</span><span style="color: #000000;font-family: Calibri"> </span>
<ul>
 	<li><span style="color: #000000;font-family: Calibri">Create a Snapshot from a MD</span></li>
 	<li><span style="color: #000000;font-family: Calibri">Create a MD from a Snapshot</span></li>
 	<li><span style="color: #000000;font-family: Calibri">Create a Snapshot from a VHD/Blob</span></li>
 	<li><span style="color: #000000;font-family: Calibri">Create an Image from a Snapshot</span></li>
 	<li><span style="color: #000000;font-family: Calibri">Create a Snapshot as copy of another Snapshot</span></li>
</ul>
<span>Creating Snapshots using REST API or PowerShell is extremely easy, as with all the available SDKs, also in this case the specific Resource Provider is under the Compute umbrella, not the Storage one.</span>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdisksnapshotconfig1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmSnapshotConfig</span><span style="color: #000000"> </span><span>-AccountType</span><span style="color: #000000"> </span><span>StandardLRS</span><span style="color: #000000"> </span><span>-DiskSizeGB</span><span style="color: #000000"> </span><span>512</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$location</span><span style="color: #000000"> </span><span>-SourceUri</span><span style="color: #000000"> </span><span>$ref1</span><span>.</span><span style="color: #000000">Id  </span><span>-CreateOption</span><span style="color: #000000"> </span><span>Copy</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$mdisksnapshot1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmSnapshot</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-SnapshotName</span><span style="color: #000000"> </span><span>"EmptyManagedDiskMD1snaphot1"</span><span style="color: #000000"> </span><span>-Snapshot</span><span style="color: #000000"> </span><span>$mdisksnapshotconfig1</span></span></p>
<a href="https://msdnshared.blob.core.windows.net/media/2017/03/112.jpg"><img width="711" height="131" class="aligncenter wp-image-835" alt="11" src="https://msdnshared.blob.core.windows.net/media/2017/03/112.jpg" /></a>

<span>Like Managed Disks, also for Snapshots you have full support for all CRUD operations, including getting access to underlying Blob/VHD that is normally hidden to users: in PowerShell, you can use </span><strong><em><span>Grant-AzureRmSnapshotAccess</span></em></strong><span> and </span><em><strong><span>Revoke-AzureRmSnapshotAccess</span></strong></em><span> to obtain SAS URL to eventually copy the object. During my tests and project work, the only time I had to use underlying URL, was when I had to explicitly copy the Snapshot across subscriptions, this is something that is not provided (<em>yet</em>) by the platform, this may change in the future. </span><span>One final note about performances: even if a Snapshot is  full copy (<em>read-only</em>) of source Managed Disk (MD), copy operation is extremely fast, almost instantaneous, see next sections for details.</span>
<h2><span>Instant copy</span></h2>
<span>This is really a hidden gem in MD. Almost every copy operation involving MD or Snapshot is pretty instantaneous, completely different behavior compared to traditional UMD. Azure team here implemented some kind of </span><span>“</span><em><span>copy-on-read</span></em><span>”</span><span> mechanism that will asynchronously populate bits in the target object, but will return fast success acknowledge of the operation. We used this extensively during our projects, the only current limitation, not so bad for us, is tied to the locality of the copy that must happen in the same region. Again, this optimization is valid for both MD and Snapshots. Another big value of this of this mechanism, is that you can create a MD or a Snapshot based on a Blob resident in a storage account in another subscription, if the target subscription is under the same Azure Active Directory tenant. In our case this was extremely useful because Azure automatically copied in background the source blob using the super-fast </span><span>“</span><em><span>copy-on-read</span></em><span>”</span><span> feature. If you have scenarios where you build images and VMs in a </span><span>“</span><em><span>source</span></em><span>”</span><span> subscription and then you deploy running VMs in a </span><span>“</span><em><span>target</span></em><span>”</span><span> subscription, then this will be very useful for you. Remember: you can create an image from a VHD/Blob or Snapshot, not only directly from a VM. </span>
<h1><span>Syntax Difference: Managed vs. Non-Managed</span></h1>
<span>This is an area where you need to force yourself to pay close attention reading the code. Surprisingly, if you look at PowerShell syntax for example, there is no special cmdlet or parameter to create a VM based on a MD for the OS. </span><span>Here is a code snippet to create a VM using MD for the OS disk (</span><span>some parts removed for brevity</span><span>):</span><span> </span>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$sourceimage</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmImage</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-ImageName</span><span style="color: #000000"> </span><span>$ImageName</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmVMConfig</span><span style="color: #000000"> </span><span>-VMName</span><span style="color: #000000"> </span><span>$VMName</span><span style="color: #000000"> </span><span>-VMSize</span><span style="color: #000000"> </span><span>$VMSize</span><span style="color: #000000"> </span><span>-AvailabilitySetId</span><span style="color: #000000"> </span><span>$as</span><span>.</span><span style="color: #000000">Id </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Set-AzureRmVMOperatingSystem</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Linux</span><span style="color: #000000"> </span><span>-ComputerName</span><span style="color: #000000"> </span><span>$ComputerName</span><span style="color: #000000"> </span><span>-Credential</span><span style="color: #000000"> </span><span>$Credential</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Add-AzureRmVMNetworkInterface</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Id</span><span style="color: #000000"> </span><span>$nic</span><span>.</span><span style="color: #000000">Id </span><span>-Primary</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Set-AzureRmVMSourceImage</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Id</span><span style="color: #000000"> </span><span>$sourceimage</span><span>.</span><span style="color: #000000">Id</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000">  </span><span>=</span><span style="color: #000000"> </span><span>Set-AzureRmVMOSDisk</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$OSDiskName</span><span style="color: #000000"> </span><span>-StorageAccountType</span><span style="color: #000000"> </span><span>StandardLRS</span><span style="color: #000000"> </span><span>-DiskSizeInGB</span><span style="color: #000000"> </span><span>128</span><span style="color: #000000"> </span><span>-CreateOption</span><span style="color: #000000"> </span><span>FromImage</span><span style="color: #000000"> </span><span>-Caching</span><span style="color: #000000"> </span><span>ReadWrite</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmVM</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$Location</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span></span></p>
<span style="color: #000000;font-family: Calibri">Are you able to see where is the MD indication for this VM OS disk? The answer is not in what is here, but in what is *</span><b><span style="color: #000000;font-family: Calibri">not</span></b><span style="color: #000000;font-family: Calibri">* here. Here is the correspondent syntax using UMD:</span><span style="color: #000000;font-family: Calibri"> </span>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$sourceimage</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmImage</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-ImageName</span><span style="color: #000000"> </span><span>$ImageName</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmVMConfig</span><span style="color: #000000"> </span><span>-VMName</span><span style="color: #000000"> </span><span>$VMName</span><span style="color: #000000"> </span><span>-VMSize</span><span style="color: #000000"> </span><span>$VMSize</span><span style="color: #000000"> </span><span>-AvailabilitySetId</span><span style="color: #000000"> </span><span>$as</span><span>.</span><span style="color: #000000">Id </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Set-AzureRmVMOperatingSystem</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Linux</span><span style="color: #000000"> </span><span>-ComputerName</span><span style="color: #000000"> </span><span>$ComputerName</span><span style="color: #000000"> </span><span>-Credential</span><span style="color: #000000"> </span><span>$Credential</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Add-AzureRmVMNetworkInterface</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Id</span><span style="color: #000000"> </span><span>$nic</span><span>.</span><span style="color: #000000">Id </span><span>-Primary</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Set-AzureRmVMSourceImage</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Id</span><span style="color: #000000"> </span><span>$sourceimage</span><span>.</span><span style="color: #000000">Id</span></span></p>
<p style="padding-left: 30px"><span style="background: yellow;margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VirtualMachine</span><span style="background: yellow;margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000">  </span><span>=</span><span style="color: #000000"> </span><span>Set-AzureRmVMOSDisk</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$OSDiskName</span><span style="color: #000000"> </span><span>-VhdUri</span><span style="color: #000000"> </span><span>$osDiskUri</span><span style="color: #000000"> </span><span>-StorageAccountType</span><span style="color: #000000"> </span><span>StandardLRS</span><span style="color: #000000"> </span><span>-DiskSizeInGB</span><span style="color: #000000"> </span><span>128</span><span style="color: #000000"> </span><span>-CreateOption</span><span style="color: #000000"> </span><span>FromImage</span><span style="color: #000000"> </span><span>-Caching</span><span style="color: #000000"> </span><span>ReadWrite</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmVM</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgname</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$Location</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VirtualMachine</span><span style="color: #000000">  </span></span></p>
<span>As you can see in the highlighted lines, when you use MD, there is no </span><strong><em><span>“</span><span>-VhdUri</span></em></strong><span>”</span><span> parameter to supply and value to specify: simply tell Azure that you want a (managed) disk and you will get it, forget URI and everything related to storage accounts! </span><span>The story is a little bit different if want to attach a data disk to a VM. In this case, there is a <strong><em>*</em></strong></span><strong><em><span>single</span></em></strong><span><strong><em>*</em></strong> parameter to specify, that is the ID of the previously created MD you want to attach (</span><strong><em><span>-ManagedDiskId</span></em></strong><span>) :</span><span style="color: #000000;font-family: Calibri"> </span>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$MDdiskConfig</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmDiskConfig</span><span style="color: #000000"> </span><span>-AccountType</span><span style="color: #000000"> </span><span>$storageType</span><span style="color: #000000"> </span><span>-Location</span><span style="color: #000000"> </span><span>$location</span><span style="color: #000000"> </span><span>-CreateOption</span><span style="color: #000000"> </span><span>Empty</span><span style="color: #000000"> </span><span>-DiskSizeGB</span><span style="color: #000000"> </span><span>128</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$MDdisk1</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>New-AzureRmDisk</span><span style="color: #000000"> </span><span>-DiskName</span><span style="color: #000000"> </span><span>$dataDiskName</span><span style="color: #000000"> </span><span>-Disk</span><span style="color: #000000"> </span><span>$MDdiskConfig</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgName</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Get-AzureRmVM</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$VMName</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgName</span><span style="color: #000000"> </span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: orangered;font-family: 'Lucida Console';font-size: 9pt">$VM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>=</span><span style="color: #000000"> </span><span>Add-AzureRmVMDataDisk</span><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VM</span><span style="color: #000000"> </span><span>-Name</span><span style="color: #000000"> </span><span>$dataDiskName</span><span style="color: #000000"> </span><span>-CreateOption</span><span style="color: #000000"> </span><span>Attach</span><span style="color: #000000"> </span><span>-ManagedDiskId</span><span><span style="color: #000000"> </span>$MDdisk1.<span style="color: #000000">Id</span></span><span style="color: #000000"> </span><span>-Lun</span><span style="color: #000000"> </span><span>1</span></span></p>
<p style="padding-left: 30px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Update-AzureRmVM</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>-VM</span><span style="color: #000000"> </span><span>$VM</span><span style="color: #000000"> </span><span>-ResourceGroupName</span><span style="color: #000000"> </span><span>$rgName </span></span></p>
<span>You can see that is necessary since managed disks are first-class objects that need, at the minimum to be referenced for use. My personal kudos to Azure Engineering team that made the API and cmdlets so clear for MD.</span>

<span style="color: #000000;font-family: Calibri"> </span>
<h1>Additional Things to Remember</h1>
Azure Managed Disks is integrated in the new Portal and offers also full development tool coverage including .NET, Java, Ruby and Python SDKs, PowerShell and Azure CLI, ARM templates. What I described in this blog post was directly experienced in my recent works, but there are some other important details that deserve attention, I grouped the main one in the list below:
<ul>
 	<li><em><strong>Billing Model</strong></em>
<ul>
 	<li>With MD, costs are calculated in the same way (although still at different rates) for both Premium Storage and Standard storage.  Like UMD Premium storage – cost is based on the provisioned size of a disk rather than on current used space within a disk.   While one can still request a disk of any size up to 1TB, MD calculates costs based on a fixed set of standard sizes. For example, when one provisions a Standard MD 60GB disk, it would be billed as an S6 (64GB) disk – the smallest standard size of &gt;= 60GB (see Table 1.1 above).</li>
 	<li>Regarding Snapshots on MD, at the moment they are not incremental and you will pay for the full size of the sourced MD.</li>
</ul>
</li>
</ul>
<p style="padding-left: 120px"><strong><em>Azure Managed Disks Overview- Pricing and Billing</em></strong></p>
<p style="padding-left: 120px"><a href="https://docs.microsoft.com/en-us/azure/storage/storage-managed-disks-overview#pricing-and-billing">https://docs.microsoft.com/en-us/azure/storage/storage-managed-disks-overview#pricing-and-billing</a></p>
&nbsp;
<ul>
 	<li><strong><em>Outbound TCP port 8443</em></strong>
<ul>
 	<li>If you are using Managed Disks and if you use VM extensions,  you have to permit outbound only traffic over TCP port 8443, otherwise your VM deployment will fail. This port is required by the VM Agent to report VM extension status in the Azure storage as a blob. By default, outbound Internet access is permitted for Azure VMs, but if your environment requires strict traffic control and security lock-down, this may be an issue. Azure Engineering team is aware of this and working actively to remove this requirement. Based on the link below, estimated date for an update is “…by the end of May 2017.”:</li>
</ul>
</li>
</ul>
<p style="padding-left: 120px"><strong><em>Frequently Asked Questions about Azure IaaS VM Disks and managed and unmanaged premium disks</em></strong></p>
<p style="padding-left: 120px"><a href="https://docs.microsoft.com/en-us/azure/storage/storage-faq-for-disks">https://docs.microsoft.com/en-us/azure/storage/storage-faq-for-disks</a></p>

<ul>
 	<li><em><strong>Migration from Un-Managed Disks (UMD) to Managed Disks (MD)</strong></em>
<ul>
 	<li>Migrating from UMD to MD is possible, but will involve a service downtime for all your VMs in the specific Availability Set.</li>
 	<li>There is a nice PowerShell cmdlet called “<strong><em>ConvertTo-AzureRmVMManagedDisk</em></strong>” that will be very helpful in this task.</li>
 	<li>If your VM has disks on a storage account that is, or at any time has been, encrypted using Azure Storage Service Encryption (SSE), then direct migration is not possible. You have to copy the disk out and decrypt before.</li>
 	<li>During the migration from UMD to MD, is also possible to upgrade from Standard Storage to Premium Storage.</li>
 	<li>Is also possible to migrate disks from AWS to Azure MD, if you first export the EC2 instance to a VHD in an Amazon S3 bucket; procedure is detailed below:</li>
</ul>
</li>
</ul>
<p style="padding-left: 120px"><strong><em>Migrate from Amazon Web Services (AWS) to Azure Managed Disks</em></strong></p>
<p style="padding-left: 120px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-aws-to-azure">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-aws-to-azure</a></p>
<p style="padding-left: 120px">Essentially, the procedure in the article below will stop all your VMs (<span style="text-decoration: underline">with deallocation!)</span> in the specified Availability Set (AS), will “convert” (i.e. = copy!) all attached disks to MD type, then will also convert AS to be “<em>managed</em>”.</p>
<p style="padding-left: 150px"><strong><em>Convert a VM from unmanaged disks to managed disks</em></strong></p>
<p style="padding-left: 150px"><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-convert-unmanaged-to-managed-disks">https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-convert-unmanaged-to-managed-disks</a></p>

<ul>
 	<li><em><strong>Backup</strong></em>
<ul>
 	<li>Azure Backup Service now supports VM backups using Managed Disks:</li>
</ul>
</li>
</ul>
<p style="padding-left: 90px"><strong><em>Overview of the features in Azure Backup - Using Managed Disk VMs with Azure Backup</em></strong></p>
<p style="padding-left: 90px"><a href="https://docs.microsoft.com/en-us/azure/backup/backup-introduction-to-azure-backup#using-managed-disk-vms-with-azure-backup">https://docs.microsoft.com/en-us/azure/backup/backup-introduction-to-azure-backup#using-managed-disk-vms-with-azure-backup</a></p>
&nbsp;
<ul>
 	<li><em><strong>Azure modules for PowerShell</strong></em>
<ul>
 	<li>In order to use MD in PowerShell, be sure to use minimum version 2.6.0 or higher for AzureRM.Compute module:</li>
</ul>
</li>
</ul>
<p style="padding-left: 120px"><span style="margin: 0px;color: blue;font-family: 'Lucida Console';font-size: 9pt">Install-Module</span><span style="margin: 0px;font-family: 'Lucida Console';font-size: 9pt"><span style="color: #000000"> </span><span>AzureRM.Compute</span><span style="color: #000000"> </span><span>-RequiredVersion</span><span style="color: #000000"> </span><span>2.6.0</span><span><span style="color: #000000">  </span></span></span></p>

<h1>   <strong>Samples and Templates</strong></h1>
<ul>
 	<li>Azure MD obviously also support ARM "<strong><em>Templates</em></strong>", you can find a large collection in GitHub at this <a href="https://github.com/chagarw/MDPP">link</a>.</li>
 	<li><strong><em>Silvano Coriani</em></strong> from Azure CAT wrote some samples for Java, you can here:</li>
</ul>
<p style="padding-left: 60px"><strong><em>ServiceBuilder: Demo of a provisioning Engine with a multi-step workflow</em></strong></p>
<p style="padding-left: 60px"><a href="https://github.com/scoriani/ServiceBuilder">https://github.com/scoriani/ServiceBuilder</a></p>

<ul>
 	<li>Managed Disks are also available using Azure CLI tool, .NET an JAVA SDKs:
<ul>
 	<li><a href="https://azure.microsoft.com/en-us/blog/azure-cli-managed-disks/">Azure CLI: Managed Disks</a></li>
 	<li><u></u><u> </u><a href="https://azure.microsoft.com/en-us/blog/net-manage-azure-managed-disks/">.NET: Manage Azure Managed Disks</a></li>
 	<li><u></u><u> </u><a href="https://azure.microsoft.com/en-us/blog/java-manage-azure-managed-disks/">Java: Manage Azure Managed Disks</a></li>
</ul>
</li>
</ul>
<h1>Thank you!</h1>
For the patience and great support to the work I have done on Managed Disks, great kudos to <strong>Silvano Coriani</strong> from AzureCAT (<strong>@scoriani</strong>). Hope you enjoyed the post, let me know your feedbacks, you can also follow me on Twitter (<strong>@igorpag</strong>).

Best regards.

<span style="color: #000000;font-family: Calibri"> </span>]]></content:encoded>
    </item>
    <item>
      <title>My Personal FAQ on Azure Networking and ARM</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/my-personal-azure-faq-on-azure-networking-and-arm</link>
      <pubDate>Sun, 24 Jul 2016 13:56:12 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=555</guid>
      <description><![CDATA[Last updated: July 24, 2016.

IMPORTANT: The information I reported in this post is time sensitive...]]></description>
      <content:encoded><![CDATA[<span style="color: #ff0000"><strong><em><u>Last updated</u></em></strong>: July 24, 2016.</span>

<span style="color: #ff0000"><strong><em><u>IMPORTANT</u></em></strong></span><em>: The information I reported in this post is time sensitive since may change in the future. I will try to maintain the content updated, but you should double--check with official Azure documentation sources. This is a new article specifically focused on ARM, you can find a previous old one related to ASM at the link below:</em>
<p style="padding-left: 30px"><strong><em>My personal Azure FAQ on Azure Networking SLAs, bandwidth, latency, performance, SLB, DNS, DMZ, VNET, IPv6 and much more</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/igorpag/2014/09/28/my-personal-azure-faq-on-azure-networking-slas-bandwidth-latency-performance-slb-dns-dmz-vnet-ipv6-and-much-more">https://blogs.msdn.microsoft.com/igorpag/2014/09/28/my-personal-azure-faq-on-azure-networking-slas-bandwidth-latency-performance-slb-dns-dmz-vnet-ipv6-and-much-more</a></p>
In the last four years I worked extensively on Azure IaaS, during engagements with my partners I have been asked many questions on Azure networking in general, and more specifically on Virtual Network (VNET) and VMs in new Azure Resource Manager (ARM) world. Providing adequate answers is not always easy, sometime the documentation is not clear or missing in details, while other times you can deduct yourselves but requires pretty good knowledge. Since I detected some recurring patterns in these questions, I decided to write my personal FAQ list in this blog post. Just to be clear: even if I’m a MSFT and have inner knowledge of Azure, I’m not going to unveil you any reserved or secret information. Everything you will read here can be found playing directly with Azure or retrieved by using official and public documentation. If you have additional “nice” questions requiring a non-trivial or non-easy-to-retrieve answer, fill free to insert a comment below this post. Additionally, if you have proposals or feedbacks regarding new feature that Azure networking should have, please use the link below to submit your ideas or vote existing ones:
<p style="padding-left: 30px"><strong><em>FEEDBACK FORUM: Networking (DNS, Traffic Manager, VPN, VNET)</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/category/77469-virtual-networks-vnet">https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/category/77469-virtual-networks-vnet</a></p>
As usual, you can also follow me on Twitter at <strong><em>@igorpag</em></strong>. Regards.

&nbsp;

&nbsp;
<h2><strong>Can I create a Storage Account or Azure SQLDB server without a public VIP?</strong></h2>
While is possible to create a Virtual Machine not exposed to the Internet, for Azure Storage Accounts and Azure SQLDB logical servers there is a mandatory DNS name created that need to be exposed. During creation of these resources, a FQDN records is created and exposure cannot be avoided since this resource locator is required to access the resource. Both these resources are protected by Microsoft DDoS and Azure SQLDB can be also configured with its own firewall mechanism.
<p style="padding-left: 30px"><strong><em>Configure an Azure SQL Database server-level firewall rule using the Azure Portal</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings">https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings</a></p>

<h2><strong>Do Azure VPN or ExpressRoute provide traffic encryption?</strong></h2>
Azure VPN tunnels, for Site-to-Site connectivity (S2S), are by design/default encrypted using IPSEC. Encryption is also provided for Point-to-Site (P2S) using SSTP (Secure Socket Tunneling Protocol). ExpressRoute does not provide network traffic encryption for its circuits.
<p style="padding-left: 30px"><strong><em>VPN Gateway FAQ</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-vpn-faq">https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-vpn-faq</a></p>
&nbsp;
<h2><strong>Do Azure VPN or ExpressRoute provide QoS?</strong></h2>
ExpressRoute provides network traffic QoS only for Skype for Business, while Azure VPN does not provide this kind of service. You can read more details on ExpressRoute at the link below:
<p style="padding-left: 30px"><strong><em>ExpressRoute QoS requirements</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/expressroute-qos">https://azure.microsoft.com/en-us/documentation/articles/expressroute-qos</a></p>
&nbsp;
<h2><strong>Do Azure VPN and ExpressRoute support BGP?</strong></h2>
YES, now also Azure VPN supports Border Gateway Protocol (BGP) for automatic exchange of routing information when different VNETs and/or on-premises sites are connected together. ExpressRoute fully support BGP since the beginning. Transit routing is supported, but redundant tunnels between a pair of virtual networks are not supported yet. Be aware that is not possible today to filter BGP routes at the VPN level, if you need to build more advanced network topology, you should give a look to the second URL listed below.
<p style="padding-left: 30px"><strong><em>Overview of BGP with Azure VPN Gateways</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-bgp-overview">https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-bgp-overview</a></p>
&nbsp;
<p style="padding-left: 30px"><strong><em>Hub&amp;Spoke, Daisy-Chain and Full-Mesh VNET topologies in Azure ARM (V2)</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/igorpag/2016/02/11/hubspoke-daisy-chain-and-full-mesh-vnet-topologies-in-azure-arm-v2">https://blogs.msdn.microsoft.com/igorpag/2016/02/11/hubspoke-daisy-chain-and-full-mesh-vnet-topologies-in-azure-arm-v2</a></p>
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/113.jpg" rel="attachment wp-att-705"><img width="655" height="204" class="aligncenter size-full wp-image-705" alt="1" src="https://msdnshared.blob.core.windows.net/media/2016/07/113.jpg" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/144.png" rel="attachment wp-att-565"></a></p>

<h2><strong>Can I connect two Azure Virtual Networks without any Gateway?</strong></h2>
This feature is coming, stay tuned! It will permit to connect different Azure VNETs without VPN or ExpressRoute, then without bandwidth caps imposed by the Gateway.
<h2></h2>
<h2><strong>Can I assign multiple IPs to my single Network Interface Card (NIC)?</strong></h2>
This feature is coming, stay tuned!

<strong> </strong>
<h2><strong>Is it possible to change subnet or virtual network for my existing Virtual Machine?</strong></h2>
With some limitations, it is possible to change subnet for an existing Virtual Machine, but changing Virtual Network (VNET) is not directly possible, you will need to export VM definition/disks and recreate in the new VNET. You can read more details in the article below:

&nbsp;
<p style="padding-left: 30px"><strong><em>How to change Subnet and Virtual Network for Azure Virtual Machines (ASM &amp; ARM)</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/igorpag/2016/03/13/how-to-change-subnet-and-virtual-network-for-azure-virtual-machines-asm-arm">https://blogs.msdn.microsoft.com/igorpag/2016/03/13/how-to-change-subnet-and-virtual-network-for-azure-virtual-machines-asm-arm</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/03/Picture1.png" rel="attachment wp-att-354"><img width="1079" height="540" class="aligncenter size-full wp-image-354" alt="Picture1" src="https://msdnshared.blob.core.windows.net/media/2016/03/Picture1.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/03/Picture1.png" rel="attachment wp-att-354"></a>
<h2><strong>Can I mix ASM ARM Virtual Machines and Virtual Networks?</strong></h2>
NO, only Virtual Machines created with Azure Resource Manager (ARM) API can join ARM Virtual Networks, similarly only Azure Service Manager (ASM) Virtual Machines can join ASM Virtual Network. Additionally, migration is possible from ASM VMs/VNETs and Azure Resource Manager resource model, but this will happen at the VNET level, then including all the contained VMs at the same time. You can read more about migration tools and procedures at the link below:
<p style="padding-left: 30px"><strong><em>Technical deep dive on platform-supported migration from classic to Azure Resource Manager</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-migration-classic-resource-manager-deep-dive">https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-migration-classic-resource-manager-deep-dive</a></p>
<strong> </strong>
<h2><strong>Does Azure Load Balancer support multiple IPs for the same set of Virtual Machines? </strong></h2>
YES, now also using Azure Resource Manager (ARM), it is possible to have multiple IPs assigned to the same load balancer and then traffic forwarded to the same set of Virtual Machines included in one single Availability Set. This feature was previously available using the Azure Service Manager (ASM) model. For a code sample on how to add multiple VIP to Azure SLB, you can read the article below:
<p style="padding-left: 30px"><strong><em>Adding additional VIP to Azure Load Balancer</em></strong></p>
<p style="padding-left: 30px"><a href="https://jeffgraves.me/2016/04/13/adding-additional-vip-to-azure-load-balancer">https://jeffgraves.me/2016/04/13/adding-additional-vip-to-azure-load-balancer</a></p>
<strong> </strong>
<h2><strong>Does Azure Load Balancer provide Layer-7 load-balancing?</strong></h2>
Azure built-in load balancer is Layer-4 (TCP/UDP), but if you need Layer-7 load-balancing, you can use Azure Application Gateway or one of the Network Virtual Appliance (NVA) available in the Marketplace by 3rd-party vendors.
<p style="padding-left: 30px"><strong><em>Azure Load Balancer Overview</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/load-balancer-overview">https://azure.microsoft.com/en-us/documentation/articles/load-balancer-overview</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/07/233.png" rel="attachment wp-att-575"><img width="770" height="309" class="aligncenter size-full wp-image-575" alt="2" src="https://msdnshared.blob.core.windows.net/media/2016/07/233.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/233.png" rel="attachment wp-att-575"></a>
<h2><strong>Can I customize the Internet facing FQDN used by Azure for my public IP?</strong></h2>
Without using vanilla domains with CNAME records, you can only partially change the FQDN associated to your public IP, doesn’t matter if reserved or not, doesn’t matter if VIP or Instance-Level IP (ILPIP, PIP). The suffix will be always in the form of “<strong><em>location.cloudapp.azure.com”</em></strong>, where “<strong><em>location</em></strong>” is the Azure region where you deployed, you can only add a “<strong><em>domainnamelabel</em></strong>” prefix and obtain “<strong><em>domainnamelabel .location.cloudapp.azure.com</em></strong>” DNS domain.
<p style="padding-left: 30px"><strong><em>IP addresses in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-network-ip-addresses-overview-arm">https://azure.microsoft.com/en-us/documentation/articles/virtual-network-ip-addresses-overview-arm</a></p>
&nbsp;
<h2><strong>Can I use Receive Side Scaling (RSS) optimization in Azure VM?</strong></h2>
YES. Azure HyperV is able to support RSS on the host side, but to leverage this functionality in Guest OS you need to manually enable it following the instructions at the link below:
<p style="padding-left: 30px"><strong><em>Virtual Receive-side Scaling in Windows Server 2012 R2</em></strong></p>
<p style="padding-left: 30px"><a href="https://technet.microsoft.com/en-us/library/dn383582.aspx">https://technet.microsoft.com/en-us/library/dn383582.aspx</a></p>
For Windows Server, Guest OS must be Windows Server 2012 R2 version or later, while for support on Linux OS, see the article below:
<p style="padding-left: 30px"><strong><em>Linux and FreeBSD Virtual Machines on Hyper-V</em></strong></p>
<p style="padding-left: 30px"><a href="https://technet.microsoft.com/en-us/library/dn531030.aspx">https://technet.microsoft.com/en-us/library/dn531030.aspx</a></p>

<h2><strong>Does ICMP work in Azure?</strong></h2>
It depends from where you want to use ICMP tools and which targets you want to reach. ICMP works inside an Azure Virtual Network, between different Azure Virtual Networks connected via VPN or ExpressRoute or hybrid connections between on-premise and Azure VNET. It will *not* work if you have to cross the Azure Load Balancer (SLB), for example if you want to ping a Cloud Service from another Cloud Service. If you need ICMP for diagnostic and troubleshooting, there are valid alternatives to PING and TRACERT not based on ICMP but TCP. My favorite ones, among many others available in Internet, are PSPING from Mark Russinovich SysInternals tools and NMAP:
<p style="padding-left: 30px"><strong><em>PsPing v2.01</em></strong></p>
<p style="padding-left: 30px"><a href="https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx">https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx</a></p>
<p style="padding-left: 30px"><strong><em>NMAP</em></strong></p>
<p style="padding-left: 30px"><a href="https://nmap.org/download.html">https://nmap.org/download.html</a></p>

<h2><strong>Does Azure provide precise numbers on VM network bandwidth?</strong></h2>
I tested VM bandwidth limits on almost all VM sizes and found the results pretty consistent over time, then in theory there is nothing preventing you from generating your measure. What Azure documentation provide is a relative measure of network capacity for each VM SKU/SIZE as you can see in the table below:
<p style="padding-left: 30px"><strong><em>Sizes for virtual machines in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-sizes">https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-sizes</a></p>
If you look at column “<em>Max Network Bandwidth</em>”, you can find tags as LOW, MODERATE, HIGH, VERY HIGH, EXTREMELY HIGH. If you found in Internet, some old tables and information related to maximum network bandwidth for various VM SKUs, you should not trust them since outdated and Azure infrastructure evolved in the meanwhile. The only exceptions are Azure HPC instances where it is exactly specified the type of network adapter provided, that is 1 NIC 32Gbit/s and 1 NIC 10Gbit/s for A8/A9, and 1 NIC 10Gbit/s for A10/A11. See at the link below for more information:
<p style="padding-left: 30px"><strong><em>About the A8, A9, A10, and A11 compute-intensive instances</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-a8-a9-a10-a11-specs">https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-a8-a9-a10-a11-specs</a></p>

<h2><strong>Does Azure provide SLA on VM-to-VM network latency?</strong></h2>
During my tests and projects, Azure network Always provided excellent performances in terms of latency. At least at my knowledge, there is no Cloud vendor able to guarantee a maximum network latency, backed up by a formal SLA, between two different VMs. It’s very easy to test yourself and have a good understanding of average latencies, but you need to be very careful on your test criteria. First of all, you need to test over various hours during the day including peak and non-peak hours, various days over the week including weekends and working days, then finally you should use calculate the average and consider a good percentile sampling near the 95% to eliminate peaks and occasional strange values. Additionally, don’t assume latencies will be the same in all Azure datacenters. If you want to do your own tests, I would recommend you PSPING tool from SYSINTERNAL suite that you can find here: <a href="https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx">https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx</a>. What is really nice regarding this tool, is that it will not use ICMP then no problem to traverse firewalls and load-balancers, you can decide which TCP port to use and, very important, you can test for bandwidth, not only for latency. You can read full details on using this tool to test Azure latency in one of my previous blog post:
<p style="padding-left: 30px"><strong><em>Azure Network Latency &amp; SQL Server Optimization</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.com/b/igorpag/archive/2013/12/15/azure-network-latency-test-and-sql-server-optimization.aspx">https://blogs.msdn.com/b/igorpag/archive/2013/12/15/azure-network-latency-test-and-sql-server-optimization.aspx</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/07/327.png" rel="attachment wp-att-585"><img width="550" height="277" class="aligncenter size-full wp-image-585" alt="3" src="https://msdnshared.blob.core.windows.net/media/2016/07/327.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/327.png" rel="attachment wp-att-585"></a>

In the past, “<em>Affinity Group</em>” concept has been used to provide co-location of VMs and minimize latency: now this concept is officially deprecated with the new Azure Resource Manager (ARM) API and broad adoption of “Regional” VNET. Azure infrastructure continuous evolutions made network more efficient and performant, then you should not use it anymore.
<h2><strong>Azure Datacenter-to-Datacenter traffic will go through public Internet?</strong></h2>
Traffic between VNETs in different datacenters, connected via VPN connection will remain inside Microsoft owned network backbones, see slide [34] in the presentation below:
<p style="padding-left: 30px"><strong><em>Introduction to Microsoft Azure Networking Technologies and What's New</em></strong></p>
<p style="padding-left: 30px"><a href="https://channel9.msdn.com/Events/TechEd/Europe/2014/CDP-B227">https://channel9.msdn.com/Events/TechEd/Europe/2014/CDP-B227</a></p>
Also in the case of VNETs connected using Express Route, traffic will not go through public Internet, private leased line will be used.
<h2><strong>Is it possible to know Azure public IP address pools?</strong></h2>
YES, all Azure public IP ranges are published at the link below. If you want to white-list, for security reasons, on your on-premise network you can do that selectively by region but not by service.
<p style="padding-left: 30px"><strong><em>Microsoft Azure Datacenter IP Ranges </em></strong></p>
<p style="padding-left: 30px"><a href="https://www.microsoft.com/en-us/download/details.aspx?id=41653">https://www.microsoft.com/en-us/download/details.aspx?id=41653</a></p>
If you rely on specific Azure resources, for example an Azure SQLDB instance or blob storage account, be aware that the assigned IP you will see, resolving their specific DNS names, may change without notice. <strong><u>IMPORTANT</u></strong>: don’t rely on any geo-location service for Internet IP used by Azure since may report incorrect information, for more details see the blog post below:
<p style="padding-left: 30px"><strong><em>Microsoft Azure’s use of non-US IPv4 address space in US regions</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/06/11/windows-azures-use-of-non-us-ipv4-address-space-in-us-regions">https://azure.microsoft.com/blog/2014/06/11/windows-azures-use-of-non-us-ipv4-address-space-in-us-regions</a></p>
If you created your own Cloud Service, and want to be possible to validate it using reverse-DNS, you can do that enabling PTR record registration (by Azure) for your Cloud Service VIP as described at the link below:
<p style="padding-left: 30px"><strong><em>Announcing: Reverse DNS for Azure Cloud Services</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/07/21/announcing-reverse-dns-for-azure-cloud-services">https://azure.microsoft.com/blog/2014/07/21/announcing-reverse-dns-for-azure-cloud-services</a></p>
Be aware that the Virtual IP (VIP) associated to your Cloud Service may change under some conditions, if you need to be absolutely sure it will never happen, you need to enable "Reserved IP" feature as described at the blog post below:
<p style="padding-left: 30px"><strong><em>Reserved IP addresses for Cloud Services &amp; Virtual Machines</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/05/14/reserved-ip-addresses">https://azure.microsoft.com/blog/2014/05/14/reserved-ip-addresses</a></p>
<p style="padding-left: 180px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/513.png" rel="attachment wp-att-596"><img width="169" height="300" class="size-medium wp-image-596 alignnone" alt="5" src="https://msdnshared.blob.core.windows.net/media/2016/07/513-169x300.png" /></a></p>

<h2><strong>Is there any API to retrieve Azure public IP addresses?</strong></h2>
NO, there is no built-in API provided by the platform at the moment, instead you can download the XML file from the link below. Or you can build a simple logic to download the file and parse content as shown in the second URL listed below:
<p style="padding-left: 30px"><strong><em>Microsoft Azure Datacenter IP Ranges </em></strong></p>
<p style="padding-left: 30px"><a href="https://www.microsoft.com/en-us/download/details.aspx?id=41653">https://www.microsoft.com/en-us/download/details.aspx?id=41653</a></p>
<p style="padding-left: 30px"><strong><em>Step-by-Step: Automate Building Outbound Network Security Groups Rules via Azure Resource Manager (ARM) and PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.technet.microsoft.com/keithmayer/2016/01/12/step-by-step-automate-building-outbound-network-security-groups-rules-via-azure-resource-manager-arm-and-powershell">https://blogs.technet.microsoft.com/keithmayer/2016/01/12/step-by-step-automate-building-outbound-network-security-groups-rules-via-azure-resource-manager-arm-and-powershell</a></p>

<h2><strong>Azure “Affinity Group” is officially deprecated?</strong></h2>
YES, with the introduction of Azure Resource Manager (ARM) new API model, “<em>Affinity Group</em>” (AG) is officially deprecated, thus not recommended to use it.
<p style="padding-left: 30px"><strong><em>Azure Subscription and Service Limits, Quotas, and Constraints</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits">https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits</a></p>
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/421.png" rel="attachment wp-att-586"><img width="685" height="172" class="size-full wp-image-586 alignnone" alt="4" src="https://msdnshared.blob.core.windows.net/media/2016/07/421.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/614.png" rel="attachment wp-att-605"></a></p>
Even if AG can be still used in Service Management (SM) API, but not in the legacy and new Azure portals, usage is not recommended since many Azure networking features rely on “<em>Regional Virtual Networks</em>”. Using an AG to pin a Virtual Network in fact, will originate a “Local Network” tied to a single Azure Cluster and will not have benefits of the new Azure scale units for compute resources.
<p style="padding-left: 30px"><strong><em>Regional Virtual Networks</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/05/14/regional-virtual-networks">https://azure.microsoft.com/blog/2014/05/14/regional-virtual-networks</a></p>
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/713.png" rel="attachment wp-att-615"><img width="550" height="350" class="size-full wp-image-615 alignnone" alt="7" src="https://msdnshared.blob.core.windows.net/media/2016/07/713.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/713.png" rel="attachment wp-att-615"></a></p>

<h2><strong>What is “*.internal.cloudapp.net” DNS suffix in Azure VM?</strong></h2>
If you build an Azure VM and join to an Azure Virtual Network and try to ping it using the VM host name (legacy Netbios name to be clear), this is what you will see:
<p style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/810.png" rel="attachment wp-att-625"><img width="550" height="93" class="size-full wp-image-625 alignnone" alt="8" src="https://msdnshared.blob.core.windows.net/media/2016/07/810.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/810.png" rel="attachment wp-att-625"></a></p>
As you can see in the picture, there are two strange parts in the FQDN: nothing strange in “<strong>cloudapp.net</strong>”, but what are “<strong>internal</strong>” and “<strong>a3</strong>”? You can easily guess that “<strong>internal</strong>” is the default DNS sub-zone that Azure internal DNS (iDNS) will use to host records for VMs and resolve to internal VM IP (DIP). “<strong>a3</strong>” instead is a little bit complex: in short, it’s describing the network zone, inside the specific Azure datacenter, where the VM is allocated. There is no official documentation or list of these zones, then don’t ask more, but please note that it will change not only between Azure datacenters, but also inside a single datacenter. You can programmatically retrieve internal DNS setting using the simple PowerShell command below:
<p style="padding-left: 30px"><strong><span style="color: #0000ff">(Get-AzureRmNetworkInterface -Name "mynicname" -ResourceGroupName $rgname).DnsSettings.InternalFqdn</span></strong></p>
Output will be something like the string below:
<p style="padding-left: 30px"><strong><span style="color: #0000ff">InternalDomainNameSuffix : 0fcdtenvgl4urm0sv5aj1xkcrc.fx.internal.cloudapp.net</span></strong></p>
&nbsp;
<h2><strong>PING and TRACERT tools will work inside Azure Virtual Network?</strong></h2>
YES, they will work perfectly inside a VNET, and even from on-premise to VNET via VPN connection. They will not work if you try to cross the Azure Load Balancer (SLB/ILB).

&nbsp;
<h2><strong>Azure Load Balancer (SLB) uses Round-Robin policy to distribute incoming connections?</strong></h2>
This is a very common mis-understanding on how SLB works. Actually, Azure SLB is a Layer-4 software Load Balancer and uses a <u>5-tuple </u>(<em>source IP, source port, destination IP, destination port, protocol type</em>) to calculate the hash that is used to map traffic to the available servers behind a VIP. The hash function is chosen such that the distribution of connections to servers is fairly random then not perfect round-robin. Additionally, at least today, session affinity is not supported.
<p style="padding-left: 30px"><strong><em>Microsoft Azure Load Balancing Services</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/04/08/microsoft-azure-load-balancing-services">https://azure.microsoft.com/blog/2014/04/08/microsoft-azure-load-balancing-services</a></p>
More recently, Azure introduced a new distribution mode called Source IP Affinity (also known as session affinity or client IP affinity). Azure Load Balancer can be configured to use a 2 tuple (Source IP, Destination IP) or 3-tuple (Source IP, Destination IP, Protocol) to map traffic to the available servers. By using Source IP affinity, connections initiated from the same client computer goes to the same DIP endpoint.
<p style="padding-left: 30px"><strong><em>Azure Load Balancer new distribution mode</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/10/30/azure-load-balancer-new-distribution-mode">https://azure.microsoft.com/blog/2014/10/30/azure-load-balancer-new-distribution-mode</a></p>
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/96.png" rel="attachment wp-att-635"><img width="640" height="262" class="size-full wp-image-635 alignnone" alt="9" src="https://msdnshared.blob.core.windows.net/media/2016/07/96.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/96.png" rel="attachment wp-att-635"></a></p>

<h2><strong>Azure Load Balancer (SLB) supports SSL termination?</strong></h2>
Azure SLB (or ILB) does not support SSL termination at the edge, but you can use Azure Application Gateway to achieve this goal:
<p style="padding-left: 30px"><strong><em>Application Gateway Overview</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/application-gateway-introduction">https://azure.microsoft.com/en-us/documentation/articles/application-gateway-introduction</a></p>
Alternatively, you can handle the termination process for HTTPS encryption and decryption within each VM or Web/Worker role instance, use some 3<sup>rd</sup>-party appliances or OSS technologies as NGINX or HAPROXY.

&nbsp;
<h2><strong>Can I use my own Load Balancer and avoid Azure Load Balancer?</strong></h2>
YES, usage of Azure SLB is not mandatory, there is a specific offer from Azure called “<strong><em>Basic</em></strong>” that will give you up to 27% lower prices, compared to Standard SKUs:
<p style="padding-left: 30px"><strong><em>Basic Tier Virtual Machines</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/04/28/basic-tier-virtual-machines-2">https://azure.microsoft.com/blog/2014/04/28/basic-tier-virtual-machines-2</a></p>
Autoscaling will not be available with “<strong>Basic</strong>”, but you will still have 99,95% through “<em>Availability Set</em>”. Please also notes that not all the sizes, in terms of CPUs and RAM, will be available:
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/107.png" rel="attachment wp-att-645"><img width="550" height="344" class="size-full wp-image-645 alignnone" alt="10" src="https://msdnshared.blob.core.windows.net/media/2016/07/107.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/107.png" rel="attachment wp-att-645"></a></p>
Once selected the “<strong>Basic</strong>” tier for your VM, you can then install your own Load Balancer software. Be aware that sizes available in the “Basic” tiers are very limited and all listed in the picture and article above.

&nbsp;
<h2><strong>Can I expose full port range of my VM?</strong></h2>
YES, there is an Azure specific feature called “<strong><em>Instance-Level Public IP Addresses</em></strong>” that will provide your VM a “Public Instance IP” (PIP) with full port range opened by default, without any need to create any endpoint. Using normal VIPs, you can only create/open up to 150 endpoints/ports, then if you need a large number of ports to be opened this is the feature that will satisfy your requirements.
<p style="padding-left: 30px"><strong><em>Instance-Level Public IP Addresses</em></strong></p>
<p style="padding-left: 30px"><a href="https://msdn.microsoft.com/en-us/library/azure/dn690118.aspx">https://msdn.microsoft.com/en-us/library/azure/dn690118.aspx</a></p>
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/1114.png" rel="attachment wp-att-646"><img width="218" height="300" class="size-medium wp-image-646 alignnone" alt="11" src="https://msdnshared.blob.core.windows.net/media/2016/07/1114-218x300.png" /></a></p>

<h2><strong>How many connections a VM can support?</strong></h2>
For Windows Server, a VM can support about 500k TCP connections but you need to be careful about other potential limits that may come into the game before this threshold: if you expose your VM to Internet traffic through an Azure Load Balancer endpoint, you may be limited by SLB capacity or DDOS security mechanisms. Actually, there is no public documentation on SLB or Endpoint limits, neither on the number of connection nor network bandwidth, then you should conduct your own performance tests to ensure everything will work correctly.
<h2><strong>Can I have multiple VNET Gateways? </strong></h2>
Currently you can only have one virtual network Gateway per single VNET per single type, that is one for VPN and one for ExpressRoute. With VPN, if you configure multiple tunnels, they will share the same maximum network bandwidth.
<h2><strong>ExpressRoute and VPN can coexist in the same VNET?</strong></h2>
YES, it is possible to have a VNET with gateways supporting ExpressRoute and VPN at the same time. The only requirement is to enable ExpressRoute before VPN. One Gateway per VNET restriction persists.
<p style="padding-left: 30px"><strong><em>New Networking Capabilities for a Consistent, Connected and Hybrid Cloud</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud">https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud</a></p>
<p style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/1212.png" rel="attachment wp-att-655"><img width="610" height="577" class="size-full wp-image-655 alignnone" alt="12" src="https://msdnshared.blob.core.windows.net/media/2016/07/1212.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/1212.png" rel="attachment wp-att-655"></a></p>

<h2><strong>Can I connect VNETs across regions, geographies and subscriptions?</strong></h2>
YES, Azure provides two ways to connect VNETs: ExpressRoute and VPN. With VPN, there is no boundary on the region, geography or subscription, essentially the tunnel only need Gateway VIPs to see each other. In case you need more bandwidth and lower latency, you can eventually use ExpressRoute technology to connect up to 100 VNETs (depending on bandwidth) and share circuits between them, even with different subscriptions. Before Premium add-on announced in May 2015, ExpressRoute posed limitations on geographical boundaries: now it is possible not only to connect VNETs in the same geography (US, Europe, etc.) but also across different geographies. For example, you can connect a VNET in West US to a VNET in North Europe.
<p style="padding-left: 30px"><strong><em>New Networking Capabilities for a Consistent, Connected and Hybrid Cloud</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud">https://azure.microsoft.com/blog/2015/05/05/new-networking-capabilities-for-a-consistent-connected-and-hybrid-cloud</a></p>

<h2><strong>Does Azure provide DDoS network protection?</strong></h2>
YES, Azure infrastructure is designed to protect the network from DDOS originating from the Internet and also internally from other tenants VMs, you can read the details in the white-paper below:
<p style="padding-left: 30px"><strong><em>Microsoft Azure Network Security Whitepaper version 3 is now available</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/blog/microsoft-azure-network-security-whitepaper-version-3-is-now-available">https://azure.microsoft.com/en-us/blog/microsoft-azure-network-security-whitepaper-version-3-is-now-available</a></p>
 Please be aware of the following important points:
<ul>
	<li>Windows Azure’s DDoS defense system is designed not only to withstand attacks from the outside, but also from within.</li>
	<li>Windows Azure monitors and detects internally initiated DDoS attacks and removes offending VMs from the network.</li>
	<li>Windows Azure’s DDoS protection also benefits applications. However, it is still possible for applications to be targeted individually. As a result, customers should actively monitor their Windows Azure applications.</li>
</ul>
To augment your tenant security, you can deploy 3<sup>rd</sup>-party Network Virtual Appliances (NVA) in your Virtual Network, but be aware that custom DDoS to protect Azure public IPs (VIPs) is not supported.

&nbsp;
<h2><strong>Can I use IPv6 inside an Azure Virtual Network?</strong></h2>
IPv6 support has been confirmed to be under development as you can read at the link below:
<p style="padding-left: 30px"><strong><em>Support IPv6 throughout the Azure Platform</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/suggestions/4992369-support-ipv6-throughout-the-azure-platform">https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/suggestions/4992369-support-ipv6-throughout-the-azure-platform</a></p>
Additional comments from Azure FAQ on <a href="https://azure.microsoft.com/en-us/pricing/faq">https://azure.microsoft.com/en-us/pricing/faq</a>:

<em>Microsoft has played a leading role in helping customers to smoothly transition from IPv4 to IPv6 for the past several years. To date, Microsoft has built IPv6 support into many of its products and solutions like Windows 8 and Windows Server 2012 R2. Microsoft is committed to expanding the worldwide capabilities of the Internet through IPv6 and enabling a variety of valuable and exciting scenarios, including peer-to-peer and mobile applications. The foundational work to enable IPv6 in the Azure environment is well underway. However, we are unable to share a date when IPv6 support will be generally available at this time.</em>

&nbsp;
<h2><strong>UDP broadcast and multicast are supported inside Azure Virtual Network?</strong></h2>
This type of communication is not allowed inside a VNET or even across Azure SLB.
<p style="padding-left: 30px"><strong><em>Support Multicast within Virtual Networks</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/suggestions/3741233-support-multicast-within-virtual-networks">https://feedback.azure.com/forums/217313-networking-dns-traffic-manager-vpn-vnet/suggestions/3741233-support-multicast-within-virtual-networks</a></p>

<h2> <strong>Is it possible to have multiple NICs on VM? </strong></h2>
YES, this feature has been announced at TechEd Europe back in October 2014. Be aware that adding more NICs will not give you more bandwidth, all will share the same limit granted to the VM level. Now it's possible to have up to 4 additional NICs without any additional cost, the exact number varies depending on the VM size:
<ul>
	<li>Large (A3) and A6: 2</li>
	<li>ExtraLarge (A4) and A7: 4</li>
	<li>A9: 2</li>
	<li>D3: 2</li>
	<li>D4: 4</li>
	<li>D13: 4</li>
	<li>&lt;&lt;ETC&gt;&gt;</li>
</ul>
<div style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/1310.png" rel="attachment wp-att-665"><img width="636" height="272" class="size-full wp-image-665 alignnone" alt="13" src="https://msdnshared.blob.core.windows.net/media/2016/07/1310.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/1310.png" rel="attachment wp-att-665"></a></div>
<div style="padding-left: 30px">

&nbsp;

Be aware that some limitations exist, be sure to read the “<em>Multiple NIC FAQs &amp; Constraints</em>” section in the blog post below:
<p style="padding-left: 30px"><strong><em>Multiple VM NICs and Network Virtual Appliances in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/10/30/multiple-vm-nics-and-network-virtual-appliances-in-azure">https://azure.microsoft.com/blog/2014/10/30/multiple-vm-nics-and-network-virtual-appliances-in-azure</a></p>

<h2><strong>Can I persist my VM network card MAC address?</strong></h2>
Work is underway to provide this feature, that is preserving MAC addresses across Azure Host failures, VM resizes and re-deployments.
<h2><strong>Can I avoid DHCP for my VM inside Virtual Network?</strong></h2>
YES, when you join a VM to an Azure Virtual Network, by default it will take an internal IP (DIP) automatically assigned by Azure internal DHCP, valid in the address scope you defined and eventually in the subnet you indicated. This IP will have an infinite lease time, but under certain conditions may change, for example if you stop your VM with de-provisioning (default behavior). If you are going to mix DHCP dynamically assigned IPs and statically assigned IPs, it’s recommended to use separate subnets to avoid potential address clashes. You can read more details in the blog post below:
<p style="padding-left: 30px"><strong><em>Static Internal IP Address for Virtual Machines</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/blog/2014/04/22/static-internal-ip-address-for-virtual-machines">https://azure.microsoft.com/blog/2014/04/22/static-internal-ip-address-for-virtual-machines</a></p>

<h2><strong>Is it possible to run network penetration tests against my Azure VMs?</strong></h2>
YES, you can do that but it’s highly recommended to follow the specific procedure mentioned below, before running the test, otherwise Azure monitoring and defense systems will trigger in and blacklist your connections, IPs and/or VMs. Be sure your request will be approved before starting the test, you can find the form to fill-in at the bottom of the page URL reported below:

</div>
<div></div>
<div style="padding-left: 60px"><strong><em>Penetration Test Notification Process</em></strong>
<a href="https://security-forms.azure.com/penetration-testing/terms">https://security-forms.azure.com/penetration-testing/terms</a></div>
<div style="padding-left: 30px"></div>
<div style="padding-left: 120px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/145.png" rel="attachment wp-att-675"><img width="300" height="218" class="size-medium wp-image-675 alignnone" alt="14" src="https://msdnshared.blob.core.windows.net/media/2016/07/145-300x218.png" /></a></div>
<div style="padding-left: 90px"><em>Microsoft conducts regular penetration testing to improve Azure security controls and processes. We understand that security assessment is also an important part of our customers' application development and deployment. Therefore, we have established a policy for customers to carry out authorized penetration testing on their applications hosted in Azure. Because such testing can be indistinguishable from a real attack, it is critical that customers conduct penetration testing only after notifying Microsoft. Penetration testing must be conducted in accordance with our terms and conditions.</em></div>
<div></div>
<div>
<h2><strong>Which is the guaranteed bandwidth for Azure VPN?</strong></h2>
There is no minimum guaranteed bandwidth for Azure VPN, the only SLA provided is about high-availability (99,90%). Azure provides an indication for maximum theoretical limit that actually is 200Mbit/sec with “High-Performance” SKU:
<p style="padding-left: 30px"><strong><em>About VPN Gateway</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-about-vpngateways">https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-about-vpngateways</a></p>

</div>
<div></div>
<div style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/155.png" rel="attachment wp-att-685"><img width="470" height="280" class=" wp-image-685 alignnone" alt="15" src="https://msdnshared.blob.core.windows.net/media/2016/07/155.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/155.png" rel="attachment wp-att-685"></a></div>
<div></div>
<div>As you can see in the table above, there is a limit on the maximum number of tunnels you can create, based on the type of Gateway SKU and connectivity type (S2S VPN or Express Route).</div>
<h2><strong>VHD I/O will count toward VM network bandwidth cap?</strong></h2>
<div>I/O related to IaaS VM VHDs access will count against storage IOPS limits, not network limits. Seems a tricky question, but since persistent VM storage is networked, some customers and partners frequently ask it. Official numbers on scalability targets for Azure Storage are reported at the link below:</div>
<p style="padding-left: 30px"><strong><em>Azure Storage Scalability and Performance Targets</em></strong></p>
<p style="padding-left: 30px"><a href="https://msdn.microsoft.com/library/azure/dn249410.aspx">https://msdn.microsoft.com/library/azure/dn249410.aspx</a></p>
If you use some special features like SQL Server 2014 Azure Blob Storage integration or Azure Files (over SMB), it will count toward your VM network bandwidth limits, in addition to the target service scalability and performance limits.
<p style="padding-left: 30px"><strong><em>UPDATED: New White-Paper on SQL Server 2014 and Azure Blob storage integration</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.com/b/igorpag/archive/2014/06/22/update-new-white-paper-on-sql-server-2014-and-azure-blob-storage-integration.aspx">https://blogs.msdn.com/b/igorpag/archive/2014/06/22/update-new-white-paper-on-sql-server-2014-and-azure-blob-storage-integration.aspx</a></p>
&nbsp;
<p style="padding-left: 30px"><strong><em>Introducing Microsoft Azure File Service</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx">https://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx</a></p>
&nbsp;
<h2><strong>Can I use A8/A9 VM Infiniband NIC for my application traffic?</strong></h2>
It depends. I have been asked several times if, for example, Infiniband NIC can be used for SQL Server AlwaysOn Availability Group replication traffic, since it provides very high-bandwidth, low-latency connection and RDMA support. In this specific case, the answer is NO, this NIC does not provide general TCP/IP connectivity, as for all the applications that cannot talk over “Network Direct” interface and MPI protocol.
<p style="padding-left: 30px"><strong><em>New High Performance Capabilities for Windows Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.technet.com/b/windowshpc/archive/2014/01/30/new-high-performance-capabilities-for-windows-azure.aspx">https://blogs.technet.com/b/windowshpc/archive/2014/01/30/new-high-performance-capabilities-for-windows-azure.aspx</a></p>

<h2><strong>Can I create a DMZ in Azure?</strong></h2>
YES. With the introduction of “<em>Network Security Groups</em>” (NSG), Network Virtual Appliances (NVA), “<em>Multiple NICs”, </em>“<em>User Defined Routes</em>” and “<em>IP Forwarding</em>” it is now possible to implement a full-featured DMZ with strong segregation of traffic and full control between subnets inside a VNET. Creating a DMZ requires careful planning and architectural work, you can find a guided step-by-step tour, along with examples, at the link below:
<p style="padding-left: 30px"><strong><em>Microsoft cloud services and network security</em></strong></p>

<div style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/best-practices-network-security">https://azure.microsoft.com/en-us/documentation/articles/best-practices-network-security</a></div>
<div style="padding-left: 30px"></div>
<div style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/164.png" rel="attachment wp-att-686"><img width="738" height="342" class=" wp-image-686 alignnone" alt="16" src="https://msdnshared.blob.core.windows.net/media/2016/07/164.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/164.png" rel="attachment wp-att-686"></a></div>
<div>

There is already a certain number of 3<sup>rd</sup>-party Network Virtual Appliances (NVAs) you can use to provide security features like firewalls/DMZ, but also IDS/IPS, you can find them in the Azure Market Place through Azure Certified Program to ensure quality and simplify deployment.
<h2><strong>Azure ILB can be used to augment networking security?</strong></h2>
YES, but it’s necessary to clarify what is the security benefit since there is some confusion on how this feature works. Essentially, it can help security since will let you define one (or more) load-balanced endpoints, as when using Azure SLB, not exposed to the Internet, then more secure. Conversely, it’s not an isolation mechanism since will not segregate resources inside a VNET, all the VMs will have open and full connectivity to all other VMs if not using ILB, even if ACLs will be used. For the same reason, ILB alone is not enough to build a DMZ.

</div>
<div style="padding-left: 90px"></div>
<div style="padding-left: 90px"><a href="https://msdnshared.blob.core.windows.net/media/2016/07/173.png" rel="attachment wp-att-696"><img width="376" height="424" class="wp-image-696 alignnone" alt="17" src="https://msdnshared.blob.core.windows.net/media/2016/07/173.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/07/173.png" rel="attachment wp-att-696"></a></div>
<div></div>
<div>If you want to build a real DMZ configuration, it is recommended to look at the previous “<em>Can I create a DMZ in Azure?”</em> section in this blog post.</div>
<div></div>
<div></div>]]></content:encoded>
    </item>
    <item>
      <title>Azure Network Security Groups (NSG) - Best Practices and Lessons Learned</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/azure-network-security-groups-nsg-best-practices-and-lessons-learned</link>
      <pubDate>Sat, 14 May 2016 16:20:25 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=395</guid>
      <description><![CDATA[While Virtual Network (VNET) is the cornerstone of Azure networking model and provides isolation and...]]></description>
      <content:encoded><![CDATA[While Virtual Network (VNET) is the cornerstone of Azure networking model and provides isolation and protection. Network Security Group (NSG) is the main tool you need to use to enforce and control network traffic rules at the networking level. Customers can control access by permitting or denying communication between the workloads within a virtual network, from systems on customer’s networks via cross-premises connectivity, or direct Internet communication. In the diagram below, both VNETs and NSGs reside in a specific layer in the Azure overall security stack, where NSGs, UDR, and network virtual appliances can be used to create security boundaries to protect the application deployments in the protected network.
<p style="padding-left: 30px"><strong><em>What is a Network Security Group (NSG)?</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg">https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg</a></p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/1.bmp"><img class="aligncenter size-full wp-image-455" src="https://msdnshared.blob.core.windows.net/media/2016/05/1.bmp" alt="1" width="985" height="449" /></a>

In one of my recent engagement with my partners, I had the opportunity to test NSG power, facing some limitations and gaining some good knowledge and experiences I would like to share with you. For some of them, I will include links to existing documentations since published before this blog post.
<h2><strong>Think and Plan before Deploy</strong></h2>
If you played even only minimally with NSG, you immediately realized that you need to think very carefully about your subnets and virtual network architecture: even if you can also assign NSG to the VM network interface (NIC) level, probably you will want to use subnets as your level of granularity (<em>see below for more details</em>). Since it is not easy and immediate to change subnet structure, if you already deployed VMs in there, my first suggestion is to design your VNET architecture before and (also) according to your NSG needs. Once you have designed your network topology, you need to think about the architecture of the boundaries you want to enforce and probably how your DMZ will look like. In this case, you need to answer at least the questions below, I fetched from an excellent article (<em>see URL below</em>), written by <strong>Jon Ormond</strong>, that I strongly encourage you to read:
<ul>
	<li>Which characteristics and requirements perimeter network should have?</li>
	<li>How many boundaries are needed?</li>
	<li>Where are the boundaries located?</li>
	<li>How are the boundaries implemented?</li>
</ul>
<p style="padding-left: 30px"> <strong><em>Microsoft cloud services and network security</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/best-practices-network-security">https://azure.microsoft.com/en-us/documentation/articles/best-practices-network-security</a></p>
Good! Now you have VNET and subnets properly designed and implemented, and you are ready to deploy your NSG rules.
<h2><strong>Notable differences between ASM and ARM</strong></h2>
NSG is an Azure feature available in both ASM (Azure Service Manager or “classic”) and ARM (Azure Resource Manager) API. It is highly recommended to use ARM for new deployments, and then use ASM only when necessary to support existing environments. If you deployed an ARM VNET, you will need to use ARM API for NSG, similarly you will have to use ASM API in a VNET created in this way. If you played already with NSG in ASM, then jumped to ARM, you will be a bit “disoriented”, especially if you used PowerShell, since there are some changes that you need to be aware of.
<p style="padding-left: 30px"><strong><em>How to create NSGs (classic) in PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-create-nsg-classic-ps">https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-create-nsg-classic-ps</a></p>
<p style="padding-left: 30px"><strong><em> </em></strong><strong><em>How to create NSGs in Resource Manager by using PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-create-nsg-arm-ps">https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-create-nsg-arm-ps</a></p>
Essentially, there is no perfect symmetry between ASM and ARM, at least in PowerShell. NSG can be manipulated in the Azure Portal, but if you want to operate at scale and you want to “code” infrastructure, you will need to use PowerShell or SDKs/REST APIs. Also consider that if you want to do some advanced stuff, probably you will not be able to do that in Azure Portal GUI. This is what I found in my activities, be aware of the following:

-          <strong>NSG granularity: </strong>While in ASM you had the possibility to link NSG to VM, NIC and subnet levels, in ARM it is slightly different: you can associate only to NIC and subnet levels. This has historical reasons since initially multiple NICs were not allowed in ASM, then VM concepts was used when NSG was first implemented. You can see details of <em>Set-AzureNetworkSecurityGroupAssociation</em> for ASM.

-          <strong>Remove associations: </strong>While in PowerShell ASM you had cmdlets <em>Remove-AzureNetworkSecurityGroupFromSubnet</em> and <em>Remove-AzureNetworkSecurityGroupAssociation</em> to remove NSG from subnets or VMs, this is no longer the case in ARM. See section “<strong><em>Remove NSG association from Subnets or NICs</em></strong>” later in this blog post.

-          <strong>List NSGs: </strong>In ASM you have a nice cmdlet named <em>Get-AzureNetworkSecurityGroupForSubnet</em> to retrieve NSG associated to a subnet, in ARM there is not, you essentially need to retrieve the subnet object and then navigate through the properties and see which NSG, if any, is linked.

-          <strong>NSG logs: </strong>Logs and diagnostics for NSG are only available in ARM, there is no ASM coverage, see section “<strong><em>Enable NSG diagnostics and logs programmatically</em></strong>” later in this blog for details.

&nbsp;

In general, I noticed that for many Azure objects and resources, in PowerShell recently we switched from a model where a distinct pair of cmdlets existed for everything, to a new model where many operations are now managed by “Get/Set” approach. Now you can retrieve object references and then read and/or manipulate directly property values.
<h2><strong>Which Scope for NSG?</strong></h2>
Which scope you should use for linking your NSG: subnet level or NIC level or both? Binding NSG to the individual VMs (by NIC) is powerful, but you may quickly lose control of the complexity of your deployment since would be hard to track and maintain. Generally, this is used for specific VMs with Network Virtual Appliances (NVAs) roles, otherwise it is recommended to link NSG to the subnet level and re-use across your VNETs and subnets.

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/2.bmp"><img class="aligncenter size-full wp-image-465" src="https://msdnshared.blob.core.windows.net/media/2016/05/2.bmp" alt="2" width="532" height="484" /></a>

&nbsp;

Be very careful when you want to apply NSG to <span style="text-decoration: underline">both</span> VM (NIC) and subnet level at the same time: NSGs are evaluated independently, and an “allow” rule must exist at both levels otherwise traffic will not be admitted. Let me give you an example on incoming traffic on port 80: you need to have NSG at subnet level with ALLOW rule for port 80, and you also need another NSG with ALLOW rule on port 80 at the NIC level. For incoming traffic, NSG set at the subnet level is evaluated first, then the NSG set at the NIC level. For outgoing traffic is obviously the converse. The picture below should even clarify this concept more: you can see how rules are evaluated for network packets, once again remember that you need to evaluate this diagram two times: once for subnet level NSG rules, and once for NIC level NSG rules.

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/3.bmp"><img class="aligncenter size-full wp-image-445" src="https://msdnshared.blob.core.windows.net/media/2016/05/3.bmp" alt="3" width="991" height="486" /></a>
<h2><strong>Be very careful with Defaults and Tools</strong></h2>
When you create a Network Security Group (NSG), even completely empty without any rule, there are some <strong><span style="text-decoration: underline">defaults</span></strong> that come with it, you can visualize in ARM accessing the specific property of the NSG object in PowerShell:
<p style="padding-left: 30px"><strong>$nsg0.DefaultSecurityRulesText</strong></p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/4.bmp"><img class="aligncenter size-full wp-image-435" src="https://msdnshared.blob.core.windows.net/media/2016/05/4.bmp" alt="4" width="847" height="351" /></a>

Notice in the output that there are three <span style="text-decoration: underline">inbound </span>and three <span style="text-decoration: underline">outbound</span> rules. Rules are assigned a priority, and while the default rules cannot be deleted, they can be overridden by rules with higher priority. In ASM you can achieve the same using the PowerShell command below with the “-Detailed” switch:
<p style="padding-left: 30px"><span style="color: #0000ff"><strong>Get-AzureNetworkSecurityGroup -Name &lt;&lt;NSG Name&gt;&gt; –Detailed</strong></span></p>
<span style="text-decoration: underline"><strong>Default</strong></span> rules will ensure that no inbound traffic will be permitted, except for “polling” from Azure load balancer, connectivity inside the VNET/subnet is not blocked, outbound traffic will be permitted including also Internet address space. <span style="text-decoration: underline">Then, what is not included here?</span> Your application/service endpoints! Suppose that you installed an IIS VM, you opened port 80 on the Guest OS firewall, you created a load-balanced or NAT rule for port 80. Everything works fine, but now you decide to further secure your environment adding a new Network Security Group: you need to explicitly add a rule for port 80 and protocol HTTP, otherwise when you will apply to the VM/NIC or subnet, your existing application/service will break.

<strong><span style="text-decoration: underline">Tools</span></strong> are also very important and final results may differ greatly depending on your choice. If you create your VM using the Azure Portal, at a certain point you will be offered to create a new brand NSG and related rules, if you included a load balancer or Instance-Level IP (ILPIP or PIP). In this case the tool you have chosen has taken care of ensure that, since your VM is exposed to the Internet, access is restricted and secured. A new rule for RDP port, for Windows VMs, or SSH for Linux VM, will be present here. On the other side, if you use PowerShell instead, you will not be prompted or required to create NSG: it us under your responsibility to create proper NSG and rules. While for VIP no port will be opened and then no access will be permitted, even without NSG, if you decide to use ILPIP, you VM will be totally exposed to the Internet for all ports and NSG is strongly required, in addition to a very good Guest OS firewall.
<h2><strong>Be very careful on “Deny All” outbound Internet traffic</strong></h2>
If your intention is to harden network security of your environment, be very careful with adding NSG rules that will block everything, instead proceed incrementally in a test environment until you will be satisfied with the results. Default rules contains already “Deny All” rules for both inbound and outbound traffic, but are the lowest in priority (65500) and for outbound there is another rule that will allow connection to the Internet. This specific rule has been added to defaults to do not break previous Azure VM behaviors, I have seen many customers and partners that restricted this adding a new rule, with higher priority (lower number), to deny Internet connection partially or totally. This is legitimate, but deny all the Internet traffic maybe dangerous and cause your VM to fail if, for example, you are using VM Extensions as explained in the article below:
<p style="padding-left: 30px"><strong><em>VM stuck in “Updating” when NSG rule restricts outbound internet connectivity</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/mast/2016/04/27/vm-stuck-in-updating-when-nsg-rule-restricts-outbound-internet-connectivity">https://blogs.msdn.microsoft.com/mast/2016/04/27/vm-stuck-in-updating-when-nsg-rule-restricts-outbound-internet-connectivity</a></p>
The case above is only one, but there may be other situations where the applications and services installed inside your environment may need to access, for example, other Azure services like Azure SQL DB or Azure Storage resources. Unfortunately, today there is no tag in NSG to identify Azure datacenter IP ranges, they can vary over time and by regions, then how to selectively block Internet outbound traffic without compromising Azure access?

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/5.bmp"><img class="aligncenter size-full wp-image-475" src="https://msdnshared.blob.core.windows.net/media/2016/05/5.bmp" alt="5" width="510" height="324" /></a>

My colleague <strong>Keith Mayer </strong>built a nice solution as described in the article below. Since Azure datacenter ranges are published here, you can use his work to automate NSG creation, using PowerShell, based on this piece of information that Microsoft periodically update.
<p style="padding-left: 30px"><strong><em>Step-by-Step: Automate Building Outbound Network Security Groups Rules via Azure Resource Manager (ARM) and PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.technet.microsoft.com/keithmayer/2016/01/12/step-by-step-automate-building-outbound-network-security-groups-rules-via-azure-resource-manager-arm-and-powershell">https://blogs.technet.microsoft.com/keithmayer/2016/01/12/step-by-step-automate-building-outbound-network-security-groups-rules-via-azure-resource-manager-arm-and-PowerShell</a></p>
Another useful example is Azure Diagnostic: if you need to enable this feature for your VMs, you cannot deny all outbound traffic, otherwise the agent running inside the Virtual Machine will not be able to connect. The list can continue with SQL Server VM agents for automated patching and backup to Azure blob storage: if you enable these extensions, you need to permit outbound Internet access from these VMs.
<h2><strong>Remove NSG association from Subnets or NICs</strong></h2>
One of the problem I faced when initially playing with NSG in ARM was how to “reset” my NSG configuration, that is removing association at the NIC and subnet level. In ASM you have a nice cmdlet called <em>Remove-AzureNetworkSecurityGroupAssociation</em>, but there is no equivalent in ARM. After digging into the details of objects and making some experiment, I created a piece of PowerShell code to achieve that:
<p style="padding-left: 30px"><span style="color: #0000ff">$vnet = Get-AzureRmVirtualNetwork -Name "Vnet1" -ResourceGroupName $rgname</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "Subnet1" -VirtualNetwork $vnet</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$subnet.NetworkSecurityGroup = $null</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">Set-AzureRmVirtualNetwork -VirtualNetwork $vnet</span></p>
 Please remember to call <em>Set-AzureRmVirtualNetwork </em>after setting to NULL the NSG property value, otherwise Azure will not commit your modification in the control plane. Approach to do the same at the NIC level is similar, you need to change the NSG property value at the NIC object level:
<p style="padding-left: 30px"><span style="color: #0000ff">$nic = Get-AzureRmNetworkInterface -Name "nic2" -ResourceGroupName $rgname</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$nic.NetworkSecurityGroupText</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$nic.NetworkSecurityGroup = $null</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">Set-AzureRmNetworkInterface -NetworkInterface $nic</span></p>
Similarly to the previous case, don’t forget to tell Azure to commit the NIC object configuration change you have just done, otherwise will have no effect. You can use the same technique to change the assigned NSG. Regarding the timing for the operation to be completed, in all my tests I saw the task completed in 30 seconds approximately, but be aware that there is no SLA/SLO on this kind of operations.
<h2><strong>Enable NSG diagnostics and logs programmatically</strong></h2>
Diagnostic and logs are an important part, especially if you need to troubleshoot unexpected behaviors that may be related to NSG mis-configurations. Remember that in ASM you don’t have this feature. In the article below you can find more information on how to enable this feature and which level of details you can have:
<p style="padding-left: 30px"><strong><em>Log analytics for network security groups (NSGs)</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-network-nsg-manage-log">https://azure.microsoft.com/en-us/documentation/articles/virtual-network-nsg-manage-log</a></p>
You can use "<strong><em>Event logs</em></strong>" log to view what NSG rules are applied to VMs and instance roles based on MAC address, and "<strong><em>Counter logs</em></strong>" to view how many times each NSG rule was applied to deny or allow traffic. What is missing here is how to enable programmatically using PowerShell, you can use the sample below to achieve that:
<p style="padding-left: 30px"><span style="color: #0000ff">$nsg = New-AzureRmNetworkSecurityGroup -Name testNSGforLogs -ResourceGroupName testwrg -Location westus</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$sa = New-AzureRmStorageAccount -ResourceGroupName testwrg -Name nsglogs -Type Standard_LRS -Location westus</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">Set-AzureRmDiagnosticSetting -ResourceId $nsg.Id -StorageAccountId $sa.Id -Enabled $true</span></p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/6.bmp"><img class="aligncenter size-full wp-image-485" src="https://msdnshared.blob.core.windows.net/media/2016/05/6.bmp" alt="6" width="445" height="547" /></a>

This will enable "<strong><em>Event logs</em></strong>" and "<strong><em>Counter logs</em></strong>" that are <span style="text-decoration: underline">not</span> enabled by default, remember this if you need to troubleshoot a potential problem with NSG. Conversely, Azure ARM Audit logs are always enabled, you can programmatically retrieve it using <strong>Get-AzureRmLog</strong> PowerShell cmdlet.
<p style="padding-left: 30px"><strong><em>Audit operations with Resource Manager</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/resource-group-audit">https://azure.microsoft.com/en-us/documentation/articles/resource-group-audit</a></p>
As a great add-on to NSG, you can leverage the great PowerBI visualization and analytics capabilities to analyze NSG log, everything you need is reported at the link below:
<p style="padding-left: 30px"><strong><em>Azure Audit Logs content pack for Power BI</em></strong></p>
<p style="padding-left: 30px"><a href="https://powerbi.microsoft.com/en-us/documentation/powerbi-content-pack-azure-audit-logs">https://powerbi.microsoft.com/en-us/documentation/powerbi-content-pack-azure-audit-logs</a></p>
An example of the log entries you can retrieve is shown below:

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/8.bmp"><img class="aligncenter size-full wp-image-495" src="https://msdnshared.blob.core.windows.net/media/2016/05/8.bmp" alt="8" width="1243" height="335" /></a>
<h2><strong>VPN and Express Route</strong></h2>
If your Azure Virtual Network (VNET) has VPN and/or ExpressRoute gateways, you need to be very careful: applying NSG to the pre-defined “<strong>GatewaySubnet</strong>” is not supported neither recommended since you may break connectivity. For your information, few days ago, support for <strong><em>User Defined Routing</em></strong> (UDR) applied to the “<strong>GatewaySubnet</strong>” has been released and be now used.
<h2><strong>NSG and Azure Cloud Services (PaaS)</strong></h2>
YES, you heard it correctly, it is possible to leverage Network Security Groups (NSG) also for Azure Cloud Services (web/worker roles), if joined to an Azure (regional) Virtual Network (VNET). This possibility is not widely known because originally another feature was used for Azure PaaS v1, that is <strong><em>Network (or Endpoint) ACLs</em></strong>.
<p style="padding-left: 30px"><strong><em>Windows Azure PaaS ACLs Are Here!</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.microsoft.com/walterm/2014/04/22/windows-azure-paas-acls-are-here">https://blogs.msdn.microsoft.com/walterm/2014/04/22/windows-azure-paas-acls-are-here</a></p>
&nbsp;

You can consider this feature as NSG v1, then superseded by true Azure Network Security Group (NSG) as you know today in ARM. Please remember that there is no Cloud Service (web/worker roles) equivalent in ARM, this is a pure ASM concept only. Long-story short: if you still have Cloud Services, you can leverage NSG changing the “NetworkConfiguration” section of CSCFG file as in the example below:
<p style="padding-left: 30px"><span style="color: #0000ff"><strong>&lt;</strong><strong>NetworkConfiguration&gt;</strong></span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">    &lt;VirtualNetworkSite name="VNet-BL"/&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">    &lt;AddressAssignments&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">      &lt;InstanceAddress roleName="WebRole"&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">        &lt;Subnets&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">          &lt;Subnet name="TestSubnet-2"/&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">        &lt;/Subnets&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">      &lt;/InstanceAddress&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">    &lt;/AddressAssignments&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">    <span style="color: #ff0000"><strong>&lt;NetworkSecurityGroupRefs&gt;</strong></span></span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">      &lt;NetworkSecurityGroupRef roleName="WebRole"&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">        &lt;NetworkSecurityGroup name="BlockOutbound"/&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">      &lt;/NetworkSecurityGroupRef&gt;</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff"> <strong><span style="color: #ff0000">   &lt;/NetworkSecurityGroupRefs&gt;</span></strong></span></p>
<p style="padding-left: 30px"><span style="color: #0000ff"><strong>  &lt;/</strong><strong>NetworkConfiguration&gt;</strong></span></p>
&nbsp;

In the “<strong>NetworkSecurityGroupRefs</strong>” section, you can reference already existing NSGs, you cannot define new ones here: you have to create outside and using ASM APIs, ARM will not work here. Finally, please keep in mind that NSG is not compatible with Network/Endpoint ACLs.
<h2><strong>Nice-to-Have features and Roadmap </strong></h2>
At least in my case, Azure NSG provided everything needed, but there are some areas that require additional work and workarounds, because the platform doesn’t provide (yet) the ideal solution.

-          <strong>Built-in Tags for Azure services: </strong>As pointed out earlier in this post, there is no pre-defined tag to identify Azure services and then distinguish between Internet and Microsoft datacenter.
<p style="padding-left: 30px"> <strong><em>Add a source tag for Azure Datacenter IPs to NSG Rules</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking/suggestions/11716131-add-a-source-tag-for-azure-datacenter-ips-to-nsg-r">https://feedback.azure.com/forums/217313-networking/suggestions/11716131-add-a-source-tag-for-azure-datacenter-ips-to-nsg-r</a></p>
-          <strong>Effective NSG: </strong>Since you can have NSG at subnet and VM level, and many rules inside each of them, sometimes calculating the final net effect of a security configuration maybe hard: having a PowerShell cmdlet calculating the net result would be really a great enhancement.
<p style="padding-left: 30px"><strong><em>Packet tracert functionality for Network Security Group (NSG)</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking/suggestions/9639258-packet-tracert-functionality-for-network-security">https://feedback.azure.com/forums/217313-networking/suggestions/9639258-packet-tracert-functionality-for-network-security</a></p>
 -          <strong>Network Security Group logging capabilities to show dropped packets: </strong> This feature has been confirmed in NSG roadmap and will be available soon.
<p style="padding-left: 30px"><strong><em>Network Security Group logging capabilities to show dropped packets</em></strong></p>
<p style="padding-left: 30px"><a href="https://feedback.azure.com/forums/217313-networking/suggestions/6940205-network-security-group-logging-capabilities-to-sho">https://feedback.azure.com/forums/217313-networking/suggestions/6940205-network-security-group-logging-capabilities-to-sho</a></p>
 -          <strong>ICMP protocol: </strong>Today, you can only specify TCP and UDP as protocols, support for ICMP is not available yet.

-          <strong>NSG Nesting: </strong> You cannot have nested NSGs.

-          <strong>VM Groups: </strong>You cannot define groups of VMs as target for NSG, you have to use subnets for this purpose.

I cannot commit on behalf of the Azure Networking team here, but there are many feedbacks from customers, partners and the entire community out there, and I’m pretty sure will contribute to the next NSG feature improvement. You want to provide additional feedbacks at the link below:

<strong><em>How can we improve Azure Networking? Enter your idea</em></strong>
<p style="padding-left: 60px"><a href="https://feedback.azure.com/forums/217313-networking">https://feedback.azure.com/forums/217313-networking</a></p>
 Stay tuned and follow me also on Twitter <strong>@igorpag</strong>. Regards.]]></content:encoded>
    </item>
    <item>
      <title>How to change Subnet and Virtual Network for Azure Virtual Machines (ASM &amp; ARM)</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/how-to-change-subnet-and-virtual-network-for-azure-virtual-machines-asm-arm</link>
      <pubDate>Sun, 13 Mar 2016 11:00:36 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/?p=353</guid>
      <description><![CDATA[During the lifecycle of an Azure Virtual Machines (VM), you may encounter situations where you need...]]></description>
      <content:encoded><![CDATA[During the lifecycle of an Azure Virtual Machines (VM), you may encounter situations where you need to change the subnet, or maybe the Virtual Network (VNET) where your VM has been created. It is worth mentioning that in Azure Resource Manager (ARM) it is mandatory to place every VM in a VNET, you cannot avoid this. In legacy Azure Service Management (ASM) this requirement didn’t exist. This blog post focuses on how to change subnet, using PowerShell, for an existing VM in ARM and ASM, and clarifies what would happen in case of VNET movement. Before effectively starting, it is important to understand that the networking model in ARM is very different from the ASM model used in the earlier Azure days, you can have an immediate idea looking at the picture below:

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/Picture1.png"><img class="  wp-image-354 aligncenter" src="https://msdnshared.blob.core.windows.net/media/2016/03/Picture1-1024x512.png" alt="Picture1" width="886" height="443" /></a>
<h1><strong>Change Subnet in ASM</strong></h1>
Changing subnet in ASM is pretty simple, there is a nice PowerShell cmdlet that makes the magic:
<p style="padding-left: 30px"><strong><em>Set-AzureSubnet</em></strong>
<a title="https://msdn.microsoft.com/en-us/library/mt589103.aspx" href="https://msdn.microsoft.com/en-us/library/mt589103.aspx">https://msdn.microsoft.com/en-us/library/mt589103.aspx </a></p>
You can use this same cmdlet at VM creation time to configure the subnet, but you can also use to change subnet for an existing VM, PowerShell code is very simple:
<p style="padding-left: 30px"><span style="color: #0000ff">Get-AzureVM –Name $MyVMname –ServiceName $MyCloudServiceName `</span>
<span style="color: #0000ff"> | Set-AzureSubnet -SubnetNames $NewTargetSubnet `</span>
<span style="color: #0000ff"> | Update-AzureVM</span></p>
<span style="color: #ff0000"><strong><span style="text-decoration: underline">IMPORTANT</span></strong></span>: There is a strict requirement here: you can only change subnet if the new one is in the same VNET as the old one.
<h1><strong>Change Subnet in ARM</strong></h1>
In ARM, this cmdlet does not exist anymore, but changing subnet is very simple once you know where to operate the change. What I found particularly interesting is that this change needs to happen at the NIC object, not to the VM level, but if you give a look to the picture above, you will agree that is expected.  First start in the procedure is to obtain references to your VM, subnet, VNET and NIC objects as reported in the code snippet below:
<p style="padding-left: 30px"><span style="color: #0000ff"># Obtain VM reference and check Availability Set #</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$VMName = "igor-vm1"</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$VirtualMachine = Get-AzureRmVM -ResourceGroupName $RGname -Name $VMName</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff"># VM created in Availability Set</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$VirtualMachine.AvailabilitySetReference</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff"># Obtain NIC, subnet and VNET references: #</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$NIC = Get-AzureRmNetworkInterface -Name $NICname -ResourceGroupName $RGname</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$NIC.IpConfigurations[0].PrivateIpAddress # '10.1.1.4'</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$VNET = Get-AzureRmVirtualNetwork -Name $VNETname  -ResourceGroupName $RGname</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$Subnet2 = Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VNET -Name $Subnet2name</span></p>
Now, the subnet setting you need to change resides in the “IPConfigurations” property array, you can access it with index [0] and change directly the “Subnet.Id” value to the ID of the new target subnet:
<p style="padding-left: 30px"><span style="color: #0000ff">$NIC.IpConfigurations[0].Subnet.Id = $Subnet2.Id</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">Set-AzureRmNetworkInterface -NetworkInterface $NIC</span></p>
Once you have done this operation, you need to commit the change with the Azure ARM Network Provider using the cmdlet “Set-AzureRmNetworkInterface”. Please note that the execution of this cmdlet will take about two minutes, at least in my scenario with an A3 VM type. Why not an immediate operation? Because once you will commit the change, Azure will automatically restart the VM, then you can execute this procedure while the VM is running, but at a certain point you will have a service downtime.

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/Picture21.png"><img class="aligncenter size-medium wp-image-364" src="https://msdnshared.blob.core.windows.net/media/2016/03/Picture21-300x187.png" alt="Picture2" width="300" height="187" /></a>

&nbsp;

If you want to check the change completed, you need to re-acquire the NIC object reference and access the private IP address or subnet properties as in the example below:
<p style="padding-left: 30px"><span style="color: #0000ff">$NIC = Get-AzureRmNetworkInterface -Name $NICname -ResourceGroupName $RGname</span></p>
<p style="padding-left: 30px"><span style="color: #0000ff">$NIC.IpConfigurations[0].PrivateIpAddress # 10.1.1.4 -&gt; 10.1.2.4</span></p>
There is a last aspect I want to mention here: what happens if you have more than one VM in an Availability Set and you want to move one of more VMs in a different subnet? No problem, I tested this scenario and you can have one (or more) VMs in one subnet S1 and one (or more) VMs in a different subnet S2, provided that S1 and S2 are in the same VNET.

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/Picture31.png"><img class="aligncenter size-medium wp-image-374" src="https://msdnshared.blob.core.windows.net/media/2016/03/Picture31-300x194.png" alt="Picture3" width="300" height="194" /></a> <a href="https://msdnshared.blob.core.windows.net/media/2016/03/Picture4.png"><img class="aligncenter size-medium wp-image-383" src="https://msdnshared.blob.core.windows.net/media/2016/03/Picture4-300x196.png" alt="Picture4" width="300" height="196" /></a>
<h1><strong>Change Virtual Network in ASM and ARM</strong></h1>
Unfortunately, today is not possible/supported to change directly a VNET for an existing VM. the only way to operate this change is export the VM definition, drop the VM preserving disks, then re-create the VM with the same settings, except for the new VNET assignment, and attaching previous disks. As a proof in ARM, if you try to move a VM to a subnet in a different VNET, you will obtain an error like this:
<p style="padding-left: 30px"><span style="color: #0000ff">Update-AzureRmVM : Subnet Subnet4 referenced by resource </span>
<span style="color: #0000ff"> /subscriptions/8e95e0bb-d7cc-4454-9443-75ca862d34c1/resourceGroups/igorrg7/providers/Microsoft.Network/networkInterfaces/nic4-igor-vm1/ipConfigurations/ipconfig1 <span style="color: #ff0000">is </span></span><span style="color: #ff0000">not in the same Virtual Network as the subnets of other VMs in the availability set.</span>
<span style="color: #0000ff"> StatusCode: 400</span>
<span style="color: #0000ff"> ReasonPhrase: Bad Request</span>
<span style="color: #0000ff"> OperationID : ''</span>
<span style="color: #0000ff"> At line:1 char:1</span>
<span style="color: #0000ff"> + Update-AzureRmVM -VM $VirtualMachine -ResourceGroupName $rgname</span>
<span style="color: #0000ff"> + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
<span style="color: #0000ff">     + CategoryInfo          : CloseError: (:) [Update-AzureRmVM], ComputeCloudException</span>
<span style="color: #0000ff">     + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.UpdateAzureVMCommand</span></p>
Another very important property you cannot change once the VM is created, is the “Availability Set”, then you should think about it carefully. Finally, please note that even if with a single VM into an “Availability Set”, trying to move to a different VNET will give you exactly the same error as above, even if there only one VM.

That’s all I wanted to share with you on this topic, if you want you can also follow me on Twitter <em><strong>(@igorpag</strong></em>). Best regards.]]></content:encoded>
    </item>
    <item>
      <title>Hub&amp;Spoke, Daisy-Chain and Full-Mesh VNET topologies in Azure ARM (V2)</title>
      <link>https://docs.microsoft.com/archive/blogs/igorpag/hubspoke-daisy-chain-and-full-mesh-vnet-topologies-in-azure-arm-v2</link>
      <pubDate>Thu, 11 Feb 2016 06:37:00 GMT</pubDate>
      <dc:creator><![CDATA[Igor Pagliai (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/igorpag/2016/02/11/hubspoke-daisy-chain-and-full-mesh-vnet-topologies-in-azure-arm-v2/</guid>
      <description><![CDATA[IMPORTANT: This is an updated version, using Azure PowerShell ARM module later than 1.0.0 release,...]]></description>
      <content:encoded><![CDATA[<span style="background-color: #ffff00"><strong><span style="text-decoration: underline">IMPORTANT</span></strong></span>: This is an <strong><span style="text-decoration: underline">updated version</span></strong>, using Azure PowerShell ARM module <strong><span style="text-decoration: underline">later than 1.0.0 release</span></strong>, of the original blog post below. If you need PowerShell code samples <span style="text-decoration: underline"><strong>earlier than 1.0.0</strong></span>, please use the article below.
<p style="padding-left: 30px"><strong><em>Hub&amp;Spoke, Daisy-Chain and Full-Mesh VNET topologies in Azure ARM using VPN (V1)</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.com/b/igorpag/archive/2015/10/01/hub-amp-spoke-daisy-chain-and-full-mesh-vnet-topologies-in-azure-arm.aspx">https://blogs.msdn.com/b/igorpag/archive/2015/10/01/hub-amp-spoke-daisy-chain-and-full-mesh-vnet-topologies-in-azure-arm.aspx</a></p>
&nbsp;

<span style="font-size: large"><strong>Introduction</strong></span>

One of the key benefit of Azure VPN is the flexibility in arranging almost any kind of connected Virtual Network (VNET) topology in Azure: you can essentially connect together VNETs in any region, of any type (ARM vs. ASM), Azure only or with on-premise hybrid environment, in different subscriptions, etc. This was also possible with the legacy Azure management API called Azure Service Management (ASM), but the drawback was a not-easy not-nice manageability of the topology configuration: since no complete scripting support was available, you had to export an XML configuration file, add your connected VNETs address spaces editing it, then import back into Azure. Additionally, no PowerShell cmdlet existed to script creation of subnets nor getting programmatically the assigned Virtual IP (VIP) assigned to the VPN gateway. If you have never done this before, I suggest you to give a quick look to the article below to have an idea, you will then better appreciate the amazing support in ARM and how easy is to fully automate even complex layouts.
<p style="padding-left: 30px"><strong><em>Multihop Routing in Azure</em></strong></p>
<p style="padding-left: 30px"><a href="https://blogs.msdn.com/b/rslaten/archive/2014/12/06/multihop-routing-in-azure.aspx">https://blogs.msdn.com/b/rslaten/archive/2014/12/06/multihop-routing-in-azure.aspx</a></p>
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/7181.1.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/7181.1.png" alt="" border="0" /></a></p>
Then, what is effectively changed in Azure Resource Manager? In ARM, Azure Networking team took a totally different approach and promoted many network concepts to first-level objects with full and independent life cycle support. Now you have NET objects, subnet objects, gateway objects you can manipulate using REST PI, SDKs or PowerShell as explained below:
<ul>
	<li>You can create subnet objects with <strong>New-AzureRmVirtualNetworkSubnetConfig</strong>;</li>
	<li>You can create virtual network objects with <strong>New-AzureRmVirtualNetwork</strong>;</li>
	<li>You can create VIP objects with <strong>New-AzureRmPublicIpAddress</strong>;</li>
	<li>You can create You can create VPN gateway objects with <strong>New-AzureRmVirtualNetworkGateway</strong>;</li>
</ul>
Before going into details on the topologies I want to show you, let me first recap shortly the main limits of Azure VPN that you need to consider when using this connectivity feature:
<p style="padding-left: 30px"><strong><em>About VPN gateways</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-about-vpngateways">https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-about-vpngateways</a></p>
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/3058.2.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/3058.2.png" alt="" border="0" /></a></p>
As you can see in the table above, at maximum you can connect up to 30 VNETs using the same VPN gateway using “<em>High-Performance</em>” SKU, be careful also with the bandwidth limit of 200 Mbit/sec. Also remember that you can have only one VPN gateway per VNET. A nice feature recently introduced is also the possibility to have coexistence of VPN gateway and ExpressRoute for the same VNET. It is also worth mentioning that Azure VPN provide high-availability SLA of 99,90%. In the remaining part of this blog post I will show you how to create different connected VNET topologies, the base article you can start with to acquire necessary concepts for PowerShell is reported below:
<p style="padding-left: 30px"><strong><em>Configure a VNet-to-VNet connection using Azure Resource Manager and PowerShell</em></strong></p>
<p style="padding-left: 30px"><a href="https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-vnet-vnet-rm-ps">https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-vnet-vnet-rm-ps</a></p>
I will only use three VNETs to do not over-complicate the diagrams and PowerShell scripts, but the concepts are essentially the same for any number of connected networks. Attached to this blog post you will find a sample PowerShell script (<em>provided as-is with no warrant nor support!) </em>I used to test all the scenarios with complete PowerShell syntax.

&nbsp;

<span style="font-size: large"><strong>Configuration</strong></span>

I prepared three VNETs, in two different regions (West Europe and North Europe), with simple three subnets composition, just to make the examples more comprehensive.
<p style="padding-left: 30px"><strong>STEP(1): Creating subnets</strong></p>
<p style="padding-left: 60px"> <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/6521.3.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/6521.3.png" alt="" border="0" /></a></p>
<p style="padding-left: 60px"><span style="text-decoration: underline">NOTE</span>: Please note that the “<strong><em>GatewaySubnet</em></strong>” subnet definition is mandatory.</p>
<p style="padding-left: 30px"><strong>STEP(2): Create VNET</strong></p>
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/43476.4.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/43476.4.png" alt="" border="0" /></a></p>
<p style="padding-left: 30px"><strong>STEP(3): Create the VNET Gateway</strong></p>
<p style="padding-left: 30px"><strong><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/1581.5.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/1581.5.png" alt="" border="0" /></a></strong></p>
I repeated these steps for VNET(2) and VNET(3) using different IP address spaces.

<span style="font-size: large"><strong>Hub&amp;Spoke</strong></span>

In this type of layout, there is a central VNET (Hub) that must be connected to each other VNET (Spokes), with no direct connection between tenants, all network traffic flows back and forth from/to VNET1 in the graphical example below. Bi-directional connectivity is not mandatory gut generally required.
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/2018.6.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/2018.6.png" alt="" width="394" height="260" border="0" /></a></p>
All the logic to implement network traffic flow is in the definition of “<em>Local Networks</em>” objects, in PowerShell this is accomplished using “<strong><em>New-AzureRmLocalNetworkGateway</em></strong>” cmdlet. Here is what must be used for Hub&amp;Spoke topology:
<p style="padding-left: 30px"><strong><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/2161.7.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/2161.7.png" alt="" border="0" /></a></strong></p>
As you can see, the logic is pretty simple: for every VNET, I defined a “<em>Local Network</em>” logical object that I will later use in the connection definitions. The key information must be supplied with the “<strong><em>-AddressPrefix</em></strong>” parameter: you need to tell Azure what is on the other side of the connection and how to arrive there <em>(“<strong>-GatewayIpAddress</strong></em>”). Once defined the connected address spaces with their respective gateway IPs, you need to create the connections:
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/4477.8.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/4477.8.png" alt="" border="0" /></a></p>
Two important details to highlight:
<ul>
	<li><strong><span style="text-decoration: underline">A connection is unidirectional</span></strong>: if you want it bidirectional between VNET(1) and VNET(2), for example, you need to separately define a connection between VNET(1) and VNET(2), then another one between VNET(2) and VNET(1).</li>
	<li><strong><span style="text-decoration: underline">A connection is not transitive</span></strong>: if you define a connection between VNET(1) and VNET(2), and a second one between VNET(2) and VNET(3), it does not mean that traffic will flow between VNET(1) and VNET(3). If you want this, you need to look at the “Daisy-Chain” scenario later in this blog post.</li>
</ul>
<span style="font-size: large"><strong>Daisy-Chain</strong></span>

Differently from the previous scenario, here you want to define a “transitive” network traffic flow: you want your packets to travel (back and forth?) from VNET(1) to VNET(3) through VNET(2).
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/0726.9.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/0726.9.png" alt="" border="0" /></a></p>
What is different from the previous approach? Look at the local network definitions you have to use as reported below. In short, from VNET(1) perspective you need to tell Azure that on the other side of the connection, that you will create later, there are two address spaces, that is VNET(2) and VNET(3). If you want to have bi-directionality, you have to create a second object representing the VNET(3) perspective.
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/3414.10.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/3414.10.png" alt="" border="0" /></a></p>
And here are the connections that you will need to define:
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/4505.11.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/4505.11.png" alt="" border="0" /></a></p>
It is worth noting that the first two connections represent the “transitive” paths between VNET(1) and VNET(3) and vice-versa, but this is not sufficient: you still need to define explicitly the “direct” point-to-point connections between VNET(2) and VNET(1) and VNET(2) and VNET(3) otherwise transitive routing will not happen. Finally, keep in mind that failure on intermediate VPNs will cause a break in the chain and will make some VNETs unreachable.

&nbsp;

<span style="font-size: large"><strong>Full-Mesh</strong></span>

This last scenario is similar to the first one, that is “<strong><em>Hub&amp;Spoke</em></strong>”: what is different is that you need also to add connections between each tenant VNETs, including all possible combinations. Based on my example, here you simply need to add connections between VNET(2)
and VNET(3). Remember that these are two separate connections since they are mono-directional.
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/4643.12.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/4643.12.png" alt="" width="431" height="286" border="0" /></a></p>
Here is the list of the connections you need, as you can notice the number will increase very quickly since you will need to explicitly define <strong>[N*(N-1)] </strong>objects.
<p style="padding-left: 30px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/5315.13.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/5315.13.png" alt="" border="0" /></a></p>
&nbsp;

<span style="font-size: large"><strong>Final Notes</strong></span>
<ul>
	<li>VNET and VPN flexibility will allow you to change dynamically the layout of your connections, then it’s pretty easy to eventually add more VNETs and/or more connections. What is important to note is that (today) VPN does not support route advertising as ExpressRoute does with BGP: this is the reason why you need to define explicitly local network objects to tell Azure how to route traffic from one side of a connection to the other side and beyond.</li>
	<li>In this blog post, I used “<em>imperative</em>” ARM model in PowerShell, but it is absolutely possible to “<em>templatize</em>” your connectivity schema using very powerful ARM template feature. My suggestion is to start coding your network layout using “<em>imperative</em>” mode, then when you will be satisfied with the results, switch to “<em>declarative</em>” mode and build your template. See "<em>Template deployment</em>" section at the link below:</li>
</ul>
<p style="padding-left: 60px"><strong><em>Azure Resource Manager overview</em></strong></p>
<p style="padding-left: 60px"><a href="https://azure.microsoft.com/en-us/documentation/articles/resource-group-overview">https://azure.microsoft.com/en-us/documentation/articles/resource-group-overview</a></p>

<ul>
	<li>You can list all the existing connections in your resource group using the PowerShell cmdlet below:</li>
</ul>
<p style="padding-left: 60px"><span style="background-color: #ffff00"><strong>Get-AzureRmVirtualNetworkGatewayConnection</strong> -ResourceGroupName $rgname | select name, location</span></p>
<p style="padding-left: 90px"> <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/8780.14.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/8780.14.png" alt="" width="234" height="87" border="0" /></a></p>

<ul>
	<li>If you want to check connectivity status for all your connections and gateways, there is a nice PowerShell cmdlet that will report specific connection status along with some nice details on traffic transferred in/out from/to the connection (please note the “<strong>-Debug</strong>” switch):
<blockquote style="margin-right: 0px"><span style="background-color: #ffff00"><strong>Get-AzureRmVirtualNetworkGatewayConnection</strong> -ResourceGroupName $rgname -Name conn1to2and3 -Debug</span></blockquote>
</li>
</ul>
<p style="padding-left: 120px"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/7608.15.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/60/33/7608.15.png" alt="" width="377" height="147" border="0" /></a></p>

<ul>
	<li>Be aware that, at least today, you will not be able to see VPN Gateway with multiple connections in the Azure Portal.</li>
</ul>
That’s all folks, hope you enjoyed this tour of Azure Virtual Network VPN connectivity, let me know your feedbacks. You can also follow me on Twitter (<strong>@igorpag</strong>).

Regards.

&nbsp;

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/66/88/02/SampleScript(2).ps1.txt">SampleScript(2).ps1.txt</a>]]></content:encoded>
    </item>
  </channel>
</rss>