﻿<?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>Microsoft Azure Support Team Blog</title>
    <atom:link
      href="https://review.docs.microsoft.com/archive/blogs/mast/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://review.docs.microsoft.com/archive/blogs/mast/feed.xml</link>
    <description />
    <lastBuildDate>Thu, 05 Apr 2018 21:24:39 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Stale screenshot in Azure VM Boot Diagnostics</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/stale-screenshot-in-azure-vm-boot-diagnostics</link>
      <pubDate>Thu, 15 Feb 2018 23:56:02 GMT</pubDate>
      <dc:creator><![CDATA[Craig Landis]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1996</guid>
      <description><![CDATA[If you notice the Boot Diagnostics screenshot for your Azure VM is stale in the Azure portal, first...]]></description>
      <content:encoded><![CDATA[If you notice the Boot Diagnostics screenshot for your Azure VM is stale in the Azure portal, first make sure the virtual display timeout is disabled in the guest operating system.

For example, for a Windows VM you may see the time shown on the logon screen is stale.

For Windows, run the following command from elevated CMD:
<blockquote><span>powercfg /setacvalueindex SCHEME_CURRENT SUB_VIDEO VIDEOIDLE 0</span></blockquote>
For Linux, run the following command:
<blockquote><span>xset s off</span></blockquote>
For Windows VMs, the Azure provisioning agent is different than the VM agent, and it is the provisioning agent that runs the above command during provisioning for VMs created from a generalized image. You can see the evidence of that if you search for <strong>powercfg</strong> in <strong>C:\Windows\Panther\WaSetup.xml</strong>, which is the provisioning agent log. But since the provisioning agent does not need to run for VMs created from a specialized VHD, that is a scenario where you would need to run the powercfg command manually to disable the virtual display timeout. Also, it is possible to have a particularly old Azure VM created from generalized image that may not have it set because it was created before the provisioning agent was updated to disable the virtual display timeout.]]></content:encoded>
    </item>
    <item>
      <title>Enhanced Azure Security for sending Emails - November 2017 Update</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/enhanced-azure-security-for-sending-emails-november-2017-update</link>
      <pubDate>Wed, 15 Nov 2017 23:02:04 GMT</pubDate>
      <dc:creator><![CDATA[David Goddard (Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1995</guid>
      <description><![CDATA[Azure is committed to stopping SPAM and reducing the customer impact caused by negative IP...]]></description>
      <content:encoded><![CDATA[<span>Azure is committed to stopping SPAM and reducing the customer impact caused by negative IP reputation.  </span><span>Starting on November 15th, 2017, sending outbound email directly to external domains (such as outlook.com, gmail.com) from a Virtual machine (VM) will be made available only to certain subscription types. Outbound SMTP connections using TCP port 25 (primarily used for unauthenticated e-mail delivery) will be blocked for most new subscriptions (more details below).</span>

This change in behavior is only applicable to new subscriptions and new deployments<span> beginning on November 15, 2017.  </span>

The change will benefit both new and existing customers by preventing malicious users from using Azure IP addresses for abuse and adversely affecting the reputation of all Azure IPs.
<h2>Recommended Method of Sending E-mail</h2>
Microsoft recommends that Azure customers employ authenticated SMTP relay services (typically connected via TCP port 587 or 443, but often support other ports too) to send e-mail from Azure VMs or from Azure App Services.  These services specialize in sender reputation to minimize the possibility 3<sup>rd</sup> party e-mail providers will reject the message.  Such SMTP relay services include but are not limited to <a href="https://sendgrid.com/partners/azure/">SendGrid</a>.  It is also possible you have a secure SMTP relay service running on premises that can be used.

Use of these e-mail delivery services is in no way restricted in Azure regardless of subscription type.
<h2>Enterprise Agreement Customers</h2>
For Enterprise Agreement Azure customers, there is no change in the technical ability to send e-mail without using an authenticated relay.  Both new and existing Enterprise Agreement customers will be able to attempt outbound e-mail delivery from Azure VMs directly to external e-mail providers with no restrictions from the Azure platform.  While Microsoft cannot guarantee e-mail providers will accept inbound e-mail from any given customer, delivery attempts will not be blocked by the Azure platform for VMs in Enterprise Agreement subscriptions.  Customers will have to work directly with e-mail providers to resolve any message delivery or SPAM filtering issues with the specific provider.
<h2>Pay-As-You-Go Customers:</h2>
For customers who signed up <strong>before </strong>November 15<sup>th</sup>, 2017 using the Pay-As-You-Go or Microsoft Partner Network subscription offers, there will be <strong>no change </strong>in the technical ability to attempt outbound e-mail delivery.  Customers will continue to be able to attempt outbound e-mail delivery from Azure VMs in these subscriptions directly to external e-mail providers with no restrictions from the Azure platform.  Again, Microsoft cannot guarantee e-mail providers will accept inbound e-mail from any given customer and customers will have to work directly with e-mail providers to resolve any message delivery or SPAM filtering issues with the specific provider.

For Pay-As-You-Go or Microsoft Partner Network subscriptions created <strong>after</strong> November 15, 2017, there will be technical restrictions blocking e-mail sent directly from VMs in these subscriptions.  Customers that need the ability to send e-mail from Azure VMs directly to external e-mail providers (not using an authenticated SMTP relay) can make a request to remove the restriction.  Requests will be reviewed and approved at Microsoft’s discretion and will be only granted after additional anti-fraud checks are performed.  To make a request, open a support case with the issue type Technical --&gt; Virtual Network --&gt; Connectivity --&gt; Cannot send e-mail (SMTP/Port 25).  Be sure to add details about why your deployment needs to send mail directly to mail providers instead of going through an authenticated relay.

Once a Pay-As-You-Go or Microsoft Partner Network subscription gets exempted, VMs in that subscription only will be exempted going forward.  Microsoft reserves the right to revoke this exemption, should we determine a violation of our terms of service has occurred.
<h2>MSDN, Azure Pass, Azure in Open, Education, BizSpark, and Free Trial Customers:</h2>
Customers who create MSDN, Azure Pass, Azure in Open, Education, BizSpark, and Free Trial subscriptions <strong>after</strong> November 15, 2017 will have technical restrictions blocking e-mail sent from VMs in these subscriptions directly to e-mail providers to prevent abuse.  No requests to remove the restriction can be made as they will not be granted.

Customers using these subscription types are encouraged to use SMTP relay services as outlined above.
<h2>Cloud Service Provider (CSP)</h2>
Customers that are consuming Azure resources via Cloud Service Provider (CSP) can create a support case with their Cloud Service Provider (CSP) of choice and request the CSP to create an unblock case on their behalf if a secure SMTP relay cannot be used.]]></content:encoded>
    </item>
    <item>
      <title>How to monitor and alert potential Disk and VM Level IO Throttling on Linux VMs using ARM</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/monitor-alert-disk-vm-io-throttling-linux-vms-arm</link>
      <pubDate>Fri, 29 Sep 2017 13:26:18 GMT</pubDate>
      <dc:creator><![CDATA[Rossano Vitulli - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1875</guid>
      <description><![CDATA[Introduction
This blog post will present a step-by-step guide to enable disk performance monitoring...]]></description>
      <content:encoded><![CDATA[<h1>Introduction</h1>
This blog post will present a step-by-step guide to enable disk performance monitoring on Linux VMs running on Azure using the Linux Diagnostics Extension 3.0 (LAD3). This article is a continuation of a previous post regarding the monitoring of potential Disk and VM level throttling on Windows VM. For a full introduction on what is Throttling and what is the difference between Disk Level and VM Level throttling, please visit <a href="https://blogs.msdn.microsoft.com/mast/2017/09/12/how-to-monitor-and-alert-potential-disk-and-vm-level-io-throttling-on-windows-vms-using-arm/">this page</a>.

This guideline is applicable to all Azure VMs deployed with Azure Resource Manager running with any <a href="https://docs.microsoft.com/en-gb/azure/cost-management/overviewhttps:/docs.microsoft.com/en-us/azure/virtual-machines/linux/endorsed-distros">supported Linux Distro</a>.
<h1>Test VM Configuration</h1>
<h2>Azure settings</h2>
For the guideline presented in this article, we will use a sample VM configured as follows:

VM Name: "MonitorUbuntuVM"

VM size: <strong>DS2_v2</strong>

Operating System<strong>: Ubuntu Linux 16.04 LTS</strong>

Disk Layout:
<ul>
 	<li>OS disk type : Premium P10.</li>
 	<li>Attached 4 data disks to VM:
<ul>
 	<li><strong>2x Premium P10</strong> (128 GB - Disk limits: 500 IOPS or 100 MB/s - Disk Cache Setting: <strong>None</strong>)</li>
 	<li><strong>1x Premium P20</strong> (512 GB - Disk limits: 2300 IOPS or 150 MB/s - Disk Cache Setting: <strong>None</strong>)</li>
 	<li><strong>1x Premium P30</strong> (1024 GB - Disk limits: 5000 IOPS or 200 MB/s - Disk Cache Setting: <strong>None</strong>)</li>
</ul>
</li>
</ul>
&nbsp;
<h2>Guest OS settings</h2>
The OS disk (<strong>sda</strong>) has 1 partition mounted on '/'.

The temporary storage disk (<strong>sdb</strong>) has 1 partition mounted on '/mnt'.

The P30 disk (<strong>sdc</strong>) has 1 partition formatted with ext4 and mounted on '/p30'.

The P20 disk (<strong>sde</strong>) has 1 partition formatted with ext4 and mounted on '/p20'.

The 2 P10 disks (<strong>sdd</strong> + <strong>sdf</strong>) have been configured in a RAID 0 array with <em>mdadm</em>, and mounted on '/p10_RAID'.

The below <em>lsblk</em> output will show the disk layout in details:
<pre># lsblk
NAME      MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
fd0         2:0    1     4K  0 disk
sda         8:0    0    30G  0 disk
└─sda1      8:1    0    30G  0 part  /
sdb         8:16   0    14G  0 disk
└─sdb1      8:17   0    14G  0 part  /mnt
sdc         8:32   0  1023G  0 disk
└─sdc1      8:33   0  1023G  0 part  /p30
sdd         8:48   0   127G  0 disk
└─sdd1      8:49   0   127G  0 part
  └─md127   9:127  0 253.9G  0 raid0 /p10_RAID
sde         8:64   0   511G  0 disk
└─sde1      8:65   0   511G  0 part  /p20
sdf         8:80   0   127G  0 disk
└─sdf1      8:81   0   127G  0 part
  └─md127   9:127  0 253.9G  0 raid0 /p10_RAID</pre>
Note: starting with MS Azure Linux Agent 2.2.4, the OS disk and the temporary storage storage disk will always be associated to <em>sda</em> and <em>sdb</em> devices.
<h2>Disk Performance target</h2>
Basing on <a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-premium-storage#scalability-and-performance-targets">Premium Storage Disk limit documentation</a>, each mountpoint performance target can be summarized as follows:
<table style="padding:5px">
<tbody>
<tr style="border-bottom-width:1px;border-bottom-style:solid;border-color: #e3e3e3">
<td width="208"><strong>Mount point</strong></td>
<td width="208"><strong>Max IOPS</strong></td>
<td width="208"><strong>Max MBps</strong></td>
</tr>
<tr style="border-bottom-width:1px;border-bottom-style:solid;border-color: #e3e3e3">
<td width="208">/</td>
<td width="208">500</td>
<td width="208">100</td>
</tr>
<tr style="border-bottom-width:1px;border-bottom-style:solid;border-color: #e3e3e3">
<td width="208">/p30</td>
<td width="208">5000</td>
<td width="208">200</td>
</tr>
<tr style="border-bottom-width:1px;border-bottom-style:solid;border-color: #e3e3e3">
<td width="208">/p20</td>
<td width="208">2300</td>
<td width="208">150</td>
</tr>
<tr style="border-bottom-width:1px;border-bottom-style:solid;border-color: #e3e3e3">
<td width="208">/p10_RAID</td>
<td width="208">2x 500 = 1000</td>
<td width="208">2x 100 = 200</td>
</tr>
</tbody>
</table>
<h2>VM Performance Target</h2>
It is important to identify any storage limitations imposed by the VM size In this scenario, the disk caching is disabled on all the attached disks (None), so we need to look up the <strong>uncached</strong> disk throughput limit of the VM (IOPS / MBps) at column "<em>Max uncached disk throughput: IOPS/MBps</em>" as following:

<a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes-general#dsv2-series">https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes-general#dsv2-series</a>

<a href="https://blogs.msdn.microsoft.com/mast/?attachment_id=1905"><img width="974" height="343" class="alignnone size-full wp-image-1905" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_1.png" /></a>

&nbsp;

The test VM Disk Limits are then set to 6400 IOPS / 96 MBps.
<h1>How to measure Disk and VM Level Throttling using Metrics?</h1>
Azure VMs collects 2 types of metric data: host-level and guest-level.

Host metrics are measured directly at the physical host (node) where the VM is running and do not require any extension running inside the Guest VM. These metrics cannot be used to detect Disk Level Throttling. You can monitor Read and Write operations separately but not aggregated, therefore they cannot even be used for VM Level Throttling.

Guest Metrics are collected from within the Guest environment and they require the Diagnostics Extension to be installed and running in the VM. These metrics can help detecting both Disk and VM Level Throttling. Following section will describe how to install the Diagnostic Extension.

<h1>How to configure Linux Diagnostic Extension to collect Guest Metrics?</h1>

Configuration of LAD3 extension for Linux VM is possible through command line option (Azure CLI or PowerShell) and Azure Portal. 

<h2>Configuration Through Command Line</h2>

As described in the <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/diagnostic-extension">Extension documentation’s page</a> you need to define the metrics configuration through a public configuration file.
Reflecting how Linux manage the storage layout, we can choose between two categories of metrics: Disk Drive and Mount Points.

<h3>Disk Metrics</h3>

This category contains metrics for the individual Disk Drives presented to the VMs (sda, sdc, sdd, etc…). Useful Disk Metrics available under the <em>Disk</em> Class (built-in) are: TransfersPerSeconds (IOPS), BytesPerSeconds (Throughput), AverageTransferTime (latency) and AverageDiskQueueLength.

Note: current implementation of <a href="https://github.com/Microsoft/SCXcore">System Center XPlatform Provider for Operations Manager (SCXCore)</a> prevents LAD3 from collecting metrics Disk Drives configured with RAID. To detect Disk Level Throttling we shall use Mount Points Metrics as described in next paragraph.

Warning: although the Disk class provides a _Total aggregated metric, because of the same behavior, this will not include RAID devices; therefore, we cannot use this value to detect VM Level Throttling.

Below json snippets define metric collection items within the “<em>performanceCounterConfiguration</em>” array in the configuration file, for disk sdc:
<ul>
 	<li>IOPS – Transfers Per Second
<pre>{
  "unit": "CountPerSecond",
  "type": "builtin",
  "counter": "TransfersPerSecond",
  "counterSpecifier": "/builtin/Disk/TransfersPerSecond/sdc",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "sdc IOPS"
    }
  ],
  "condition": "Name=\"sdc\"",
  "class": "Disk"
}</pre>
</li>
 	<li>Bps – Bytes per Second
<pre>{
  "unit": "BytesPerSecond",
  "type": "builtin",
  "counter": "BytesPerSecond",
  "counterSpecifier": "/builtin/Disk/BytesPerSecond/sdc",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "sdc BPS"
    }
  ],
  "condition": "Name=\"sdc\"",
  "class": "Disk"
}</pre>
</li>
</ul>
Monitoring IOPS and MBps is sufficient to detect Throttling, but to evaluate its intensity with accuracy it is necessary to refer to other metrics like Average Latency and Average Queue Lenght:
<ul>
 	<li>Average Latency
<pre>{
  "unit": "Millisecond",
  "type": "builtin",
  "counter": "AverageTransferTime",
  "counterSpecifier": "/builtin/Disk/AverageTransferTime/sdc",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "sdc AvLat"
    }
  ],
  "condition": "Name=\"sdc\"",
  "class": "Disk"
}</pre>
</li>
 	<li>Queue Length
<pre>{
  "unit": "Count",
  "type": "builtin",
  "counter": "AverageDiskQueueLength",
  "counterSpecifier": "/builtin/Disk/AverageDiskQueueLength/sdc",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "sdc avQL"
    }
  ],
  "condition": "Name=\"sdc\"",
  "class": "Disk"
}</pre>
</li>
</ul>
<h3>Mount Point Metrics</h3>
You can define metrics collection for mount points (/p10_RAID, /p20, p30, /, etc…) and aggregated values (_Total). These metrics are available under the <em>FileSystem</em> Class (built-in).

Monitoring of individual mountpoints is necessary to detect Disk Level Throttling. By monitoring the _Total aggregated value you can detect VM Level Throttling.

Below json snippets define metric collection items within the “<em>performanceCounterConfiguration</em>” array in the configuration file:
<ul>
 	<li>Mount Point IOPS – Transfers Per Second
<pre>{
  "unit": "CountPerSecond",
  "type": "builtin",
  "counter": "TransfersPerSecond",
  "counterSpecifier": "/builtin/FileSystem/TransfersPerSecond/p10_RAID",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "p10_RAID IOPS"
    }
  ],
  "condition": "Name=\"/p10_RAID\"",
  "class": "FileSystem"
}</pre>
</li>
 	<li>Mount Point Bps – Bytes per Second
<pre>{
  "unit": "BytesPerSecond",
  "type": "builtin",
  "counter": "BytesPerSecond",
  "counterSpecifier": "/builtin/FileSystem/BytesPerSecond/p10_RAID",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "p10_RAID BPS"
    }
  ],
  "condition": "Name=\"/p10_RAID\"",
  "class": "FileSystem"
}</pre>
</li>
 	<li>Mount Point _Total – Transfers Per Second and Bytes per Second
<pre>{
  "unit": "CountPerSecond",
  "type": "builtin",
  "counter": "TransfersPerSecond",
  "counterSpecifier": "/builtin/FileSystem/TransfersPerSecond/_Total",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "_Total IOPS"
    }
  ],
  "condition": "Name=\"_Total\"",
  "class": "FileSystem"
},
{
  "unit": "BytesPerSecond",
  "type": "builtin",
  "counter": "BytesPerSecond",
  "counterSpecifier": "/builtin/FileSystem/BytesPerSecond/_Total",
  "annotation": [
    {
      "locale": "en-us",
      "displayName": "_Total BPS"
    }
  ],
  "condition": "Name=\"_Total\"",
  "class": "FileSystem"
}</pre>
</li>
</ul>
<h3>General Settings</h3>
You can also set a <strong>sample rate</strong> to define how often the metric of the performance counter will be collected. By default, it's set to 15 seconds so every 15 seconds one value for the performance counter will be collected. The smallest supported sample rate is 15 seconds. If your workload is more constant you can choose a higher sample rate like 30 or 60. The sample rate can be quickly changed at any time and you can monitor the added counters thru the Azure portal thru "Metrics”, so you should test the optimal values for monitoring. You can set this value individually for each counter, or globally for all counters at same time.

A copy of the Public Configuration file used in this sample scenario is <a href="https://msdnshared.blob.core.windows.net/media/2017/09/pubcfg.zip">available here</a>.
<h2>Extension Installation</h2>
The Azure CLI script below can be used to configure the Diagnostic Extension:
<pre>$my_resource_group=&lt;VM Resource Group Name&gt;
$my_linux_vm=&lt;VM Name&gt;
$my_diagnostic_storage_account=&lt;Diagnostic Storage Account Name&gt;
$my_config_file=&lt;.json Public Configuration File&gt;
$my_diagnostic_storage_account_sastoken=$(az storage account generate-sas --account-name $my_diagnostic_storage_account --expiry 9999-12-31T23:59Z --permissions wlacu --resource-types co --services bt -o tsv)
$my_lad_protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', 'storageAccountSasToken': '$my_diagnostic_storage_account_sastoken'}"
az vm extension set --publisher Microsoft.Azure.Diagnostics --name LinuxDiagnostic --version 3.0 --resource-group $my_resource_group --vm-name $my_linux_vm --protected-settings "${my_lad_protected_settings}" --settings $my_config_file
</pre>
&nbsp;
<h1>How to review Collected Metrics?</h1>
By navigating to the "Metrics" section of the VM's blade, you can select the configured performance metrics to observe their values in the chart. You can switch the "time range" on the upper right to "past hour" or even a timeframe below ("Custom") to see live monitoring data.

Below screenshots shows configuration of IOPS and Bps measured at mount point level defined for a custom timeframe.

<em>View of TransfersPerSecond (IOPS) metrics.</em>
<img width="790" height="491" class="wp-image-1915 alignnone" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_2.png" />

<em>View of BytesPerSecond metrics.</em>
<img width="790" height="493" class="wp-image-1916 alignnone" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_3.png" />
<h1>How to configure Metric Alerts?</h1>
<h2>Disk Level Metric Alert</h2>
From the "Metrics" section of the VM's blade you can add rules by clicking the "Add metric alert". This enables notification whenever your workload reaches the performance scalability limit.

<em>Example for configuration of rule for single mount point:</em>
<a href="https://blogs.msdn.microsoft.com/mast/?attachment_id=1925"><img width="400" height="695" class="alignnone wp-image-1925" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_4.png" /></a>
Select your disk performance counter from the "Metric" dropdown (here we choose the counter for the p10_RAID mount point). Then select "Greater than or equal to" from the "Condition" dropdown. Provide a "Threshold" value (here we need to provide the scalability target at disk level, so 1000 IOPS for the striped P10 disks). Select "Over the last 5 minutes" (time span you like to monitor by this alert rule) from the "Period" dropdown. Mark the checkbox to be notified by email and provide an additional email address if required. Finally, you need to provide a name for your rule and click "OK".

Please create rules for all added mountpoint counters.
<h2>VM Level Metric Alert</h2>
To monitor VM Level Throttling, you need to choose the “_Total” aggregated metric and set the threshold to the target VM limit. For the scenario described in this article the IOPS limit is 6400.

<em>Example for configuration of rule on aggregated _Total counter:</em>
<a href="https://blogs.msdn.microsoft.com/mast/?attachment_id=1935"><img width="400" height="585" class="alignnone wp-image-1935" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_5.png" /></a>
Similar instructions can also be applied for configuring Metric Alert Rules to detect Throttling limit reached for BytesPerSeconds.
<h1>How to test Metrics Alert Rules?</h1>
You can test Metrics Alert Rules by running benchmarking load with <a href="https://fio.readthedocs.io/en/latest/fio_doc.html">Flexible-IO (fio)</a>:
<pre># fio --runtime 7000 fiowrite_p10_RAID.ini</pre>
The following fio configuration .ini file can be used to maximize Write Operations per Second against a single mount point ‘p10_RAID’:
<pre>[global]
size=30g
direct=1
iodepth=256
ioengine=libaio
bs=8k

[writer1]
rw=randwrite
directory=/p10_RAID
[writer2]
rw=randwrite
directory=/p10_RAID
[writer3]
rw=randwrite
directory=/p10_RAID
[writer4]
rw=randwrite
directory=/p10_RAID</pre>
You can access the ‘Metrics’ section on the VM’s blade and monitor a single mount point, like i.e. ‘/p10_RAID IOPS’ by selecting the guest metric “[Guest] p10_RAID IOPS”.

As per the above screenshot, the p10_RAID volume reached 1020 IOPS, meeting the criteria configured on the alert rule and it lasted for more than 5 minutes. An email notification will be sent.

<em>Sample email alert for reaching the Disk Level limit:</em>
<img width="275" height="300" class="size-medium wp-image-1945 alignnone" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_7-275x300.png" />

<em>Example notification email for workload has decreased below the Disk level limit (has been resolved, so workload doesn't meet the defined criteria of the alert rule):</em>
<img width="275" height="300" class="size-medium wp-image-1946 alignnone" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_8-275x300.png" />

To test the VM Level Throttling Metric Alert you can run multiple simultaneous fio executions against different mount points. You must make sure that the total IOPS generated against all the mount points in the VM are enough to overcome the VM Limit. The fio execution must also be perfectly configured to maximize target mount point IOPS.

In our example we have:
<ul>
 	<li>1000 IOPS generated over /p10_RAID.</li>
 	<li>2300 IOPS generated over /p20</li>
 	<li>5000 IOPS generated over /p30</li>
</ul>
Total expected IOPS is 8300, which is greater than 6400. This is also telling us that the only valid combination of tests to reach VM Limit is by maximizing all 3 mountpoints at same time.

<em>Below screenshot shows VM Total IOPS reaching the target 6400 IOPS defined at VM Level:</em>
<a href="https://blogs.msdn.microsoft.com/mast/?attachment_id=1975"><img width="1024" height="426" class="alignnone size-large wp-image-1975" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_9-1024x426.png" /></a>

<em>Notification emails showing IOPS Limit reached and then resolved at VM Level:</em>
<img width="524" height="263" class="alignnone wp-image-1955" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_10-1024x514.png" />
<h1>Where is the metrics data stored?</h1>
All performance counter metrics will be stored into Azure Storage Tables inside the provided storage account.

<em>Example Storage Table populated by diagnostics metrics using <a href="https://azure.microsoft.com/en-us/features/storage-explorer/">Azure Storage Explorer</a>:</em>

<a href="https://blogs.msdn.microsoft.com/mast/?attachment_id=1965"><img width="1024" height="376" class="alignnone size-large wp-image-1965" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/mon_throttling_linux_11-1024x376.png" /></a>

To prevent excessive costs for Monitoring data which is archived in table storage, you should consider doing "data maintenance" from time to time:

<a href="https://gallery.technet.microsoft.com/scriptcenter/How-to-clear-out-bfb2b41d">https://gallery.technet.microsoft.com/scriptcenter/How-to-clear-out-bfb2b41d</a>
<h1>Conclusions</h1>
This article provided end to end guidance to enable Storage Performance monitoring and alerting to detect possible Throttling events on Linux VM created with ARM.

If you don't reach the expected scalability targets at Disk or VM level, but your VM is "behaving slow", please <a href="https://azure.microsoft.com/en-us/support/options/">contact Azure support</a>.
<h1>Next Steps</h1>
Learn more on Benchmarking Azure Premium Storage on Linux VM
<ul>
 	<li><span> </span><a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-premium-storage-performance#benchmarking">Azure Premium Storage: Design for High Performance - Benchmarking</a></li>
 	<li><a href="https://fio.readthedocs.io/en/latest/fio_doc.html">Flexible-IO (fio)</a></li>
</ul>
Configuring Storage on Linux VM
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/attach-disk">How to Attach a Data Disk to a Linux Virtual Machine</a></li>
 	<li><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/configure-raid?toc=%2Fazure%2Fvirtual-machines%2Flinux%2Ftoc.json">Configure Software RAID on Linux</a></li>
</ul>
Linux Diagnostic Extension and related components
<ul>
 	<li><span> </span><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/diagnostic-extension">Use Linux Diagnostic Extension to monitor metrics and logs</a></li>
 	<li><a href="https://github.com/Microsoft/SCXcore">System Center Cross Platform Provider for Operations Manager</a></li>
 	<li><a href="https://github.com/Microsoft/omi">Open Management Infrastructure</a></li>
</ul>
More about Premium Storage
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-premium-storage">High-performance Premium Storage and managed disks for VMs</a></li>
 	<li><a href="https://azure.microsoft.com/en-us/blog/azure-premium-storage-now-generally-available-2/">Azure Premium Storage, now generally available</a></li>
</ul>
More about Linux VM sizes
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/">General purpose Linux VM sizes</a></li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>How to monitor and alert potential Disk and VM Level IO Throttling on Windows VMs using ARM</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/how-to-monitor-and-alert-potential-disk-and-vm-level-io-throttling-on-windows-vms-using-arm</link>
      <pubDate>Tue, 12 Sep 2017 12:34:22 GMT</pubDate>
      <dc:creator><![CDATA[Dirk Sc - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1735</guid>
      <description><![CDATA[This article will present a step-by-step guide to enable disk performance monitoring on Windows VMs...]]></description>
      <content:encoded><![CDATA[This article will present a step-by-step guide to enable disk performance monitoring on Windows VMs running on Azure.

Goal is to detect potential Disk Level and VM Level IO Throttling.

This guideline is applicable to all Azure VMs deployed with Azure Resource Manager and running any Windows OS version.

&nbsp;

Let's start first by explaining some prerequisites concepts:

<strong>What is Throttling?</strong>

Azure Disks are provisioned with a maximum number of IOPS and Throughput depending on the Storage Type (Standard or Premium). When using Premium Storage there are also other factors to consider, which are VM size and Disk sizes you choose. When applications try to drive IOPS or Throughput above the limits imposed by the VM or Disk size, the Azure platform will throttle it. This manifests in the form of degraded performance in your application. This could add up to higher latency, limited Throughput or limited IOPS.

We can differentiate between two types of Throttling: Disk Level and VM Level Throttling.

For more information about Throttling see:

<a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-premium-storage-performance#throttling">https://docs.microsoft.com/en-us/azure/storage/common/storage-premium-storage-performance#throttling</a>

&nbsp;

<strong>What is Disk Level Throttling</strong>?

Basically, you are exceeding the performance limits/scalability targets for a virtual machine disk which will lead to higher latency as all IOs which exceed the limit will be queued.

See limits for managed and unmanaged virtual machine disks here:

<a href="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#storage-limits">https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#storage-limits</a>

&nbsp;

<strong>What is VM Level Throttling</strong>?

Basically, you are exceeding the performance limits/scalability targets for a virtual machine as the combined IOs of all attached disks have exceeded the cached or uncached disk throughput limit. This only applies when using Premium Storage Disks. There is no VM Level IO Throttling when using Standard Storage Disks on non-premium VM sizes.

For further information about IO Throttling see: <a href="https://blogs.technet.microsoft.com/xiangwu/2017/05/14/azure-vm-storage-performance-and-throttling-demystify/">https://blogs.technet.microsoft.com/xiangwu/2017/05/14/azure-vm-storage-performance-and-throttling-demystify/</a>

&nbsp;

&nbsp;

For the guideline presented in this article, we will use a sample VM configured as follows:

VM Name: "MonitorVM"

VM size : <strong>DS2_v2</strong>

Disk Layout:

Attached 4 data disks to VM:

<strong>2x P10</strong> (128 GB - Disk limits: 500 IOPS or 100 MB/s - Disk Cache Setting: <strong>None</strong>)

<strong>1x P20</strong> (512 GB - Disk limits: 2300 IOPS or 150 MB/s - Disk Cache Setting: <strong>None</strong>)

<strong>1x P30</strong> (1024 GB - Disk limits: 5000 IOPS or 200 MB/s - Disk Cache Setting: <strong>None</strong>)

&nbsp;

In this scenario, the disk caching is disabled on all the attached disks (see above), so we need to look up the uncached disk throughput limit of the VM (IOPS / MBps) at column "Max uncached disk throughput: IOPS/MBps" as followed:

<a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes-general#dsv2-series">https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes-general#dsv2-series</a>

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/dsv2_sizes.png"><img width="1024" height="392" class="alignnone size-large wp-image-1775" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/dsv2_sizes-1024x392.png" /></a>

If we had enabled disk caching on all disk (e.g. ReadOnly/ReadWrite), we would have to look up the cached disk throughput limit of the VM (IOPS / MBps) at column "Max cached and temp storage throughput: IOPS/MBps (cache size in GiB)" (see above).

&nbsp;

&nbsp;

<strong>Details about configured disks setup inside the VM "MonitorVM"</strong>:

Created <a href="https://technet.microsoft.com/en-us/library/hh831739.aspx#BKMK_AZURE">Storage Spaces configuration</a> (striped volume) for 2x P10 disks (Volume F:\), IO limit 1000 IOPS (2x 500 IOPS):

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/storagespaces.png"><img width="1024" height="389" class="alignnone size-large wp-image-1776" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/storagespaces-1024x389.png" /></a>

&nbsp;

View of Disk Management:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/diskmanagement.png"><img width="940" height="505" class="alignnone size-full wp-image-1785" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/diskmanagement.png" /></a>

&nbsp;

View of File Explorer:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/explorer.png"><img width="806" height="219" class="alignnone size-full wp-image-1795" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/explorer.png" /></a>

&nbsp;

View of Performance Monitor inside the VM "MonitorVM":

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/perfmon.png"><img width="1022" height="731" class="alignnone size-full wp-image-1796" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/perfmon.png" /></a>

Now that we have collected information about the "instances" for the VM's PhysicalDisk performance counters from the Performance Monitor within the VM, we can add the following performance counters to the diagnostics settings blade to monitor IOPS in the Azure Portal:

&nbsp;

<strong>IOPS</strong>:

"\PhysicalDisk(_Total)\Disk Transfers/sec" (VM Level Throttling - 6400 IOPS)

"\PhysicalDisk(<strong>0 C:</strong>)\Disk Transfers/sec" (Disk Level Throttling - OS disk P10 - 500 IOPS)

"\PhysicalDisk(<strong>2</strong>)\Disk Transfers/sec" (Disk Level Throttling - P10 disk - 500 IOPS)

"\PhysicalDisk(<strong>3</strong>)\Disk Transfers/sec" (Disk Level Throttling - P10 disk - 500 IOPS)

"\PhysicalDisk(<strong>4 G:</strong>)\Disk Transfers/sec" (Disk Level Throttling - P20 disk - 2300 IOPS)

"\PhysicalDisk(<strong>5 H:</strong>)\Disk Transfers/sec" (Disk Level Throttling - P30 disk - 5000 IOPS)

"\PhysicalDisk(<strong>6 F:</strong>)\Disk Transfers/sec" (Disk Level Throttling - Storage Spaces Drive - 1000 IOPS)

&nbsp;

&nbsp;

&nbsp;

<strong>How to enable Performance Counter Monitoring on the Azure Portal?</strong>

Performance counters which have been added through the diagnostics settings on the Azure Portal:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/perfcounterportal.png"><img width="1024" height="467" class="alignnone size-large wp-image-1805" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/perfcounterportal-1024x467.png" /></a>
<ul>
 	<li>Navigate to your VM "MonitorVM" in the Azure Portal.</li>
 	<li>Select "Diagnostics settings" on the VM's blade. Switch to "Performance counters" tab (<strong>1.</strong>).</li>
 	<li>Choose "Custom" (<strong>2.</strong>) to add new custom performance counter.</li>
 	<li>Add text of new performance counter in textbox (<strong>3.</strong>) e.g. "\PhysicalDisk(0 C:)\Disk Transfers/sec".</li>
 	<li>Click "Add" button (<strong>4.</strong>) to add performance counter to collection.</li>
 	<li>Provide sample rate by adding number of seconds to textbox (<strong>5.</strong>).</li>
 	<li>Finally click "Save" button at the top to save configuration.</li>
</ul>
&nbsp;

The <strong>sample rate</strong> defines how often the metric of the performance counter will be collected. By default, it's set to 60 seconds so every 60 seconds one value for the performance counter will be collected. If your workload is spiky you may need a smaller sample rate like 10 seconds or even down to 1 second to be able to understand if you have reached a limitation at disk or VM level. If your workload is more constant you can choose a higher sample rate like 30 or 60. The sample rate can be quickly changed at any time and you can monitor the added counters thru the Azure portal thru "Metrics" so you should test the optimal values for monitoring.

&nbsp;

<strong>
</strong>

<strong> </strong>

<strong>How to review the collected metrics ?</strong>

View of the "Metrics" monitoring within the Azure Portal:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/metricportal.png"><img width="1024" height="509" class="alignnone size-large wp-image-1806" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/metricportal-1024x509.png" /></a>

&nbsp;

By navigating to the "Metrics" section of the VM's blade, you can select the added performance counters to see their values in the chart. You can switch the "time range" on the upper right to "past hour" or even a timeframe below ("Custom") to see live monitoring data.

Now we are going to add rules by clicking the "Add metric alert" so we will be notified when our workload has reached a limit.

&nbsp;

<strong>
</strong>

<strong> </strong>

<strong>How to enable metric alert Rules?</strong>

<strong> </strong>Example for configuration of rule at disk level:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/ruleconfigdisk.png"><img width="416" height="639" class="alignnone wp-image-1815" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/ruleconfigdisk.png" /></a>

Select your disk performance counter from the "Metric" dropdown (here we have chosen the counter for the OS disk). Then select "Greater than or equal to" from the "Condition" dropdown. Provide a "Threshold" value (here we need to provide the scalability target at disk level, so 500 IOPS for a P10 disk). Select "Over the last 5 minutes" (time span you like to monitor by this alert rule) from the "Period" dropdown. Mark the checkbox to be notified by email and provide an additional email address if required. Finally, you need to provide a name for your rule and click "OK".

Please create rules for all added performance counters.

&nbsp;

Example for configuration of rule at VM level:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/ruleconfigVMIO.png"><img width="416" height="554" class="alignnone wp-image-1825" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/ruleconfigVMIO.png" /></a>

The counter which contains "(_Total)" is used for the rule to monitor the VM limit ( "\PhysicalDisk(_Total)\Disk Transfers/sec" for IOPS).

&nbsp;

<strong>
</strong>

<strong> </strong>

<strong>How to test the Metrics Alert Rules? </strong>

To be able to test the configured rules I have used the benchmark tool <a href="https://github.com/Microsoft/diskspd">diskspd</a> with the following parameters (e.g. for volume <strong>F</strong> which is the storage space drive for 2x P10 disks):

<strong>diskspd.exe -c1024M -d300 -W30 -w100 -t1 -o25 -b8k -r -h -L F:\_diskSpd_test\testfile.dat</strong>

&nbsp;

Example for workload of storage spaces drive reaching the limits:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/storagespacesvmlimit.png"><img width="1024" height="603" class="alignnone size-large wp-image-1826" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/storagespacesvmlimit-1024x603.png" /></a>

As we can see from the screenshot above, the two P10 disks of the storage spaces drive are both at 500 IOPS or above and the volume F: is at 1000 IOPS.

&nbsp;

Example for workload of P30 disk and then VM level reaching the limits:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/iovmlimit.png"><img width="1024" height="467" class="alignnone size-large wp-image-1835" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/iovmlimit-1024x467.png" /></a>

As we can see from the screenshot above, first the limit of 5000 IOPS for the P30 disks was reached and then the limit at VM level was reached as the combined workload of both disks (G: P20 and H: P30) together reached 6400 IOPS. While the theoretical workload of both disks combined is 7300 IOPS = 2300(P20) + 5000(P30), the uncached throughput limit of a VM of size DS2_v2 is 6400 IOPS.

&nbsp;

If the workload inside your VM has met the configured criteria of the alert rules defined above, you will be notified by email.

&nbsp;

Example notification email for reaching the VM level limit:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/notificationalertvmlimit.png"><img width="691" height="645" class="alignnone wp-image-1836" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/notificationalertvmlimit.png" /></a>

&nbsp;

Example notification email for workload has decreased below the VM level limit (has been resolved, so workload doesn't meet the defined criteria of the alert rule):

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/notificationbelowlimit.png"><img width="730" height="514" class="alignnone wp-image-1845" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/notificationbelowlimit-1024x721.png" /></a>

Due to the <a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-premium-storage-performance#nature-of-io-requests">nature of IO requests</a> it's possible that your workload may not reach the IOPS limit, but the throughput limit has been reached (workload with larger IO size), so you need to configure the monitoring and alert rules for MBps as well:

<strong>Throughput/MBps</strong>:

"\PhysicalDisk(_Total)\Disk Bytes/sec" (VM Level Throttling - <strong>96</strong> MBps)

"\PhysicalDisk(<strong>0 C:</strong>)\Disk Bytes/sec" (Disk Level Throttling - OS disk P10 - 100 MBps)

"\PhysicalDisk(<strong>2</strong>)\Disk Bytes/sec" (Disk Level Throttling - P10 disk - 100 MBps)

"\PhysicalDisk(<strong>3</strong>)\Disk Bytes/sec" (Disk Level Throttling - P10 disk - 100 MBps)

"\PhysicalDisk(<strong>4 G:</strong>)\Disk Bytes/sec" (Disk Level Throttling - P20 disk - 150 MBps)

"\PhysicalDisk(<strong>5 H:</strong>)\Disk Bytes/sec" (Disk Level Throttling - P30 disk - 200 MBps)

"\PhysicalDisk(<strong>6 F:</strong>)\Disk Bytes/sec" (Disk Level Throttling - Storage Spaces Drive 2x P10 - 200 MBps)

&nbsp;

As all limits for throughput at disk level are higher than the possible VM level throughput limitation, we only need to configure the limit at VM level. If the VM level throughput limitation is higher than the limitation at disk level (e.g. by choosing a VM size DS4_v2 - 384 MBps), please configure the monitoring and alerts for each individual disk/volume as well.

&nbsp;

Example for configuration of rule at VM level for MBps:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/rulembps.png"><img width="416" height="642" class="alignnone wp-image-1846" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/rulembps.png" /></a>

If your workload has reached the maximum IOPS or MBps at Disk or VM level the values of the following two counters will increase due to throttling (e.g. for the OS disk):

"\PhysicalDisk(<strong>0 C:</strong>)\Current Disk Queue Length"

"\PhysicalDisk(<strong>0 C:</strong>)\Avg. Disk sec/Transfer"

&nbsp;

&nbsp;

<strong>Where is the metrics data stored?</strong>

All performance counter metrics will be stored in table named "WADPerformanceCountersTable" within the storage account which was setup from the <a href="https://msdnshared.blob.core.windows.net/media/2017/09/diagnostic-settings.png"><img width="191" height="43" class="alignnone size-full wp-image-1855" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/diagnostic-settings.png" /></a> of your VM e.g.:

<a href="https://msdnshared.blob.core.windows.net/media/2017/09/storageaccount.png"><img width="313" height="78" class="alignnone size-full wp-image-1865" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/09/storageaccount.png" /></a>

To prevent excessive costs for Monitoring data which is archived in table storage, you should consider doing "data maintenance" from time to time:

<a href="https://gallery.technet.microsoft.com/scriptcenter/How-to-clear-out-bfb2b41d">https://gallery.technet.microsoft.com/scriptcenter/How-to-clear-out-bfb2b41d</a>

<strong> </strong>

<strong>Conclusions</strong>

This article provided end to end guidance to enable Storage Performance monitoring and alerting in order to detect possible Throttling events.

&nbsp;

If you don't reach the expected scalability targets at Disk or VM level, but your VM is "behaving slow", please use <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/how-to-use-perfinsights">PerfInsights</a> for a first analysis of your disk configuration and to collect more detailed traces or <a href="https://azure.microsoft.com/en-us/support/options/">contact Azure support</a>.

&nbsp;

Enjoy!

Dirk Schneider - MSFT

&nbsp;

<strong>Update:</strong> Rossano Vitulli has now published a new <a href="https://blogs.msdn.microsoft.com/mast/2017/09/29/monitor-alert-disk-vm-io-throttling-linux-vms-arm/">post</a> to cover a similar monitoring for <strong>Linux</strong> VMs deployed with Azure Resource Manager.]]></content:encoded>
    </item>
    <item>
      <title>Troubleshooting Windows activation failures on Azure VMs</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/troubleshooting-windows-activation-failures-on-azure-vms</link>
      <pubDate>Wed, 14 Jun 2017 00:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Craig Landis]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/2014/12/23/troubleshooting-windows-activation-failures-on-azure-vms/</guid>
      <description><![CDATA[Azure uses the following KMS endpoints for Windows product activation of Azure Virtual Machines:...]]></description>
      <content:encoded><![CDATA[Azure uses the following KMS endpoints for Windows product activation of Azure Virtual Machines:
<ul>
 	<li>Azure public cloud regions - <strong>kms.core.windows.net:1688</strong></li>
 	<li>Azure China national cloud regions -  <strong>kms.core.chinacloudapi.cn:1688</strong></li>
 	<li>Azure Germany national cloud regions - <strong>kms.core.cloudapi.de:1688</strong></li>
 	<li>Azure US Gov national cloud regions - <strong>kms.core.usgovcloudapi.net:1688</strong></li>
</ul>
Azure VMs will activate using the Azure KMS service if all of the following are true:
<ol>
 	<li>Windows is configured with the appropriate <a href="https://technet.microsoft.com/en-us/library/jj612867%28v=ws.11%29.aspx?f=255&amp;MSPPError=-2147217396">KMS client setup key</a> for that version of Windows.</li>
 	<li>Windows is configured to use the Azure KMS service, e.g. <strong>kms.core.windows.net:1688 </strong>for VMs in Azure public cloud regions.</li>
 	<li>VM has network connectivity to the KMS endpoint, e.g. <strong>kms.core.windows.net:1688 </strong>for VMs in Azure public cloud regions.<span> For example, if the guest OS firewall or an Azure network security group (NSG) rule does not allow TCP port 1688 outbound, the activation request will be blocked.
</span></li>
 	<li>Source IP address of KMS activation requests from the VM must be an IP address within the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=41653">Azure IP ranges</a>. This is necessary because the Azure KMS service only allow requests through if the source IP is within the Azure IP ranges. If you are using ExpressRoute, <span>please see </span><a target="_blank" href="https://blogs.msdn.com/b/mast/archive/2015/12/01/azure-vm-may-fail-to-activate-over-expressroute.aspx" rel="noopener" title="Azure VM may fail to activate over ExpressRoute">Azure VM may fail to activate over ExpressRoute</a>. If you are using site-to-site VPN please see <a target="_blank" href="https://blogs.msdn.com/b/mast/archive/2015/05/20/use-azure-custom-routes-to-enable-kms-activation-with-forced-tunneling.aspx" rel="noopener" title="Use Azure custom routes to enable KMS activation with forced tunneling">Use Azure custom routes to enable KMS activation with forced tunneling</a>.</li>
</ol>
Windows activation works the same way regardless if the VM is using <a href="https://azure.microsoft.com/en-us/pricing/hybrid-use-benefit/">Azure Hybrid Use Benefit</a> (HUB) or not.

Note that while using an <a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn303421(v=ws.11)">Automatic Virtual Machine Activation</a> (AVMA) key may work on some Azure VMs, the use of AVMA keys is not supported because not all Azure hosts are guaranteed to support it. So while it may work initially, when the VM moves to a different Azure host when deallocated and started, when the Redeploy option is used, or when planned maintenance occurs, it may end up on an Azure host that does not support AVMA.

Run <strong>slmgr.vbs /dlv</strong> from within the VM to check #1 and #2 above. In the example below, <strong>VOLUME_KMSCLIENT</strong> is what tells you a <a href="https://technet.microsoft.com/en-us/library/jj612867%28v=ws.11%29.aspx?f=255&amp;MSPPError=-2147217396">KMS client setup key</a> was used, and <strong>Registered KMS machine name: kms.core.windows.net:1688</strong> is what confirms that it is configured to activate against the Azure KMS service. Note that the KMS endpoint differs for public versus national cloud regions as listed at the beginning of this article.
<pre>C:\&gt;cscript <strong>c:\windows\system32\slmgr.vbs /dlv</strong>
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

Software licensing service version: 10.0.14393.351

Name: Windows(R), ServerDatacenter edition
Description: Windows(R) Operating System, <strong>VOLUME_KMSCLIENT</strong> channel
Activation ID: 21c56779-b449-4d20-adfc-eece0e1ad74b
Application ID: 55c92734-d682-4d71-983e-d6ec3f16059f
Extended PID: 03612-03764-000-000000-03-1033-14393.0000-1642017
Product Key Channel: Volume:GVLK
Installation ID: 009858430382850574122213203392636030969202304948320740858134404
Partial Product Key: 8XDDG
License Status: Licensed
Volume activation expiration: 258206 minute(s) (180 day(s))
Remaining Windows rearm count: 1000
Remaining SKU rearm count: 1000
Trusted time: 6/14/2017 6:24:25 PM
Configured Activation Type: All

Most recent activation information:
Key Management Service client information
 Client Machine ID (CMID): 54653727-addd-4b5f-bde9-824359786b75
 <strong>Registered KMS machine name: kms.core.windows.net:1688</strong>
 KMS machine IP address: 23.102.135.246
 KMS machine extended PID: 06401-00206-001-010007-03-1033-9600.0000-2322016
 Activation interval: 120 minutes
 Renewal interval: 10080 minutes
 KMS host caching is enabled</pre>
If <strong>slmgr.vbs /dlv</strong> shows <strong>RETAIL channel</strong>, run the following commands to set the <a href="https://technet.microsoft.com/en-us/library/jj612867%28v=ws.11%29.aspx?f=255&amp;MSPPError=-2147217396">KMS client setup key</a> for the version of Windows Server 2016 being used, and force it to retry activation.
<pre><span>cscript c:\windows\system32\slmgr.vbs </span>/ipk &lt;KMS client setup key&gt;
<span>cscript c:\windows\system32\slmgr.vbs </span>/ato</pre>
For example, for Windows Server 2016 Datacenter, you would run:
<pre><span>cscript c:\windows\system32\slmgr.vbs </span><span>/ipk <span>CB7KF-BWN84-R7R2Y-793K2-8XDDG</span></span></pre>
This step is not necessary for VMs created from the Windows Server 2016 gallery image, as the gallery image has the appropriate KMS client setup key already configured.

For activation issues involving Windows Server 2016 VMs failing to activate despite having the KMS client setup key configured, or for activation issues with Azure VMs using other versions of Windows, please review the remaining steps below.

Windows VMs should be configured with the <a target="_blank" href="https://technet.microsoft.com/en-us/library/jj612867.aspx" rel="noopener" title="KMS client setup key">KMS client setup key</a> for the version of Windows being used, and have connectivity to port 1688 at kms.core.windows.net in order to activate successfully.

If you are using site-to-site VPN with forced tunneling, please see <a target="_blank" href="https://blogs.msdn.com/b/mast/archive/2015/05/20/use-azure-custom-routes-to-enable-kms-activation-with-forced-tunneling.aspx" rel="noopener" title="Use Azure custom routes to enable KMS activation with forced tunneling">Use Azure custom routes to enable KMS activation with forced tunneling</a>.

If you are using ExpressRoute with a default route published, please see <a target="_blank" href="https://blogs.msdn.com/b/mast/archive/2015/12/01/azure-vm-may-fail-to-activate-over-expressroute.aspx" rel="noopener" title="Azure VM may fail to activate over ExpressRoute">Azure VM may fail to activate over ExpressRoute</a>.

If your Azure VM experiences Windows activation failures, please try the following steps to resolve the issue. An example of an error message you may see is:
<pre>Error(s):  Activating Windows(R), ServerDatacenter edition
 Error: 0xC004F074 The Software Licensing Service reported that the computer could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.</pre>
<strong></strong>Note that when the grace period has expired and Windows is still not activated, Windows Server 2008 R2 and later versions of Windows will show additional notifications about activating, the desktop wallpaper remains black, and Windows Update will install security and critical updates only, but not optional updates. See also the <strong>Notifications</strong> section at the bottom of the <a target="_blank" href="https://technet.microsoft.com/en-us/library/ff793403.aspx" rel="noopener" title="Licensing Conditions">Licensing Conditions</a> TechNet page.

<strong style="font-size: small">Steps to Troubleshoot Activation</strong>
<ol>
 	<li>Download and extract the <strong>Psping</strong> tool to a local folder in the VM that is failing to activate.<a target="_blank" href="https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx" rel="noopener" title="https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx">https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx</a>To download the file, first go to <strong>Server Manager</strong>, <strong>Configure this local server</strong>, select <strong>IE Enhanced Security Configuration</strong>, and select <strong>Off</strong> under <strong>Administrators</strong>.</li>
 	<li>Go to <strong>Start</strong>, search on <strong>Windows PowerShell</strong>, right-click <strong>Windows PowerShell</strong> and select <strong>Run as administrator</strong>.</li>
 	<li>Make sure the VM is configured to use the Azure KMS server by running the following command. This is set at VM creation, so running this command is just a troubleshooting step to make sure the proper configuration is set.<strong>iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /skms kms.core.windows.net:1688"</strong>The command should return:<strong>Key Management Service machine name set to kms.core.windows.net:1688 successfully. </strong>Note that the KMS endpoint differs for public versus national cloud regions as listed at the beginning of this article, so if the VM is in a national cloud region (e.g. China, Germany, or US Gov), replace kms.core.windows.net:1688 with the relevant KMS endpoint for the region where the VM resides.<strong>
</strong></li>
 	<li>Verify with Psping that you have connectivity to the KMS server. Switch into the folder where you extracted the Pstools.zip download, then run:<strong>.\psping.exe kms.core.windows.net:1688</strong>In the second-to-last line of the output, make sure you see:<strong>Sent = 4, Received = 4, Lost = 0 (0% loss)</strong>If <strong>Lost</strong> is greater than <strong>0</strong>, the VM does not have connectivity to the KMS server. In that case, if the VM is in a virtual network and has a custom DNS server specified, you must make sure that DNS server is able to resolve <strong>kms.core.windows.net</strong>. Or, change the DNS server to one that does resolve <strong>kms.core.windows.net</strong>. Note that if you remove all DNS servers from a virtual network, VMs will then use Azure's internal DNS service, which is able to resolve <strong>kms.core.windows.net</strong>.Aside from DNS issues, verify the guest firewall has not been configured in such a way that would block activation attempts. Note that the KMS endpoint differs for public versus national cloud regions as listed at the beginning of this article, so if the VM is in a national cloud region (e.g. China, Germany, or US Gov), replace kms.core.windows.net:1688 with the relevant KMS endpoint for the region where the VM resides.</li>
 	<li>After verifying successful connectivity to <strong>kms.core.windows.net:1688 </strong>(or the respective KMS endpoint for the national cloud region where the VM is running) run the following command from that elevated PowerShell prompt. This command attempts activation multiple times in a row.<strong>1..12 | % { iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ato" ; start-sleep 5 }</strong>Successful activation will return:<strong>Activating Windows(R), ServerDatacenter edition (12345678-1234-1234-1234-12345678) ...</strong>
<strong>Product activated successfully.
</strong></li>
 	<li>If activation still failed, and the VM is running Windows Server 2012 R2 Datacenter, Standard, or Essentials, try the command below for the specific SKU. You can verify the OS version by going to <strong>Start</strong>, searching on <strong>Msinfo32</strong>, double-clicking <strong>Msinfo32.exe</strong>, and looking at the <strong>OS Name</strong> in the right pane.For Windows Server 2012 R2 Datacenter, run the following from the elevated PowerShell prompt:<strong>iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ipk W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9"</strong>For Windows Server 2012 R2 Standard, run the following from the elevated PowerShell prompt:<strong>iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ipk D2N9P-3P6X9-2R39C-7RTCD-MDVJX"</strong>For Windows Server 2012 R2 Essentials, run the following from the elevated PowerShell prompt:<strong>iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ipk KNC87-3J2TX-XB4WP-VCPJV-M4FWM"</strong>After entering the specific command above for the SKU of Windows Server 2012 R2 the VM is using, try activating again:<strong>iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ato"</strong></li>
 	<li>At this point if you are still unable to activate the VM, check the <strong>Application</strong> event log for events from source <strong>Microsoft-Windows-Security-SPP</strong> to help understand why activation is failing.</li>
</ol>
If you are still unable to activate after attempting the above steps, let us know in the comments or <a target="_blank" href="https://azure.microsoft.com/en-us/support/options/" rel="noopener" title="contact Azure support">contact Azure support</a>.]]></content:encoded>
    </item>
    <item>
      <title>Azure Disk Encryption - Convert BEK Disk Encryption to KEK for Azure Recovery Services</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/azure-disk-encryption-how-to-encrypt-azure-resource-manager-iaas-vm-using-kek</link>
      <pubDate>Mon, 28 Nov 2016 01:24:46 GMT</pubDate>
      <dc:creator><![CDATA[manojsehgal]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1605</guid>
      <description><![CDATA[Convert BEK Disk Encryption to KEK for Azure Recovery Services

A common desire is to convert...]]></description>
      <content:encoded><![CDATA[<strong>Convert BEK Disk Encryption to KEK for Azure Recovery Services</strong>

<strong>A common desire is to convert Azure IaaS VM's that were encrypted using only BEK to also using KEK in order to take advantage of Azure Recovery Services. In this scenario, you do not need to decrypt your VM, rather simply enable with a KEK key using the following steps:</strong>

<strong>Steps:</strong>

<strong>Pre-requisites:</strong> Install Azure Power Shell from <a href="https://docs.microsoft.com/en-us/azure/powershell-install-configure">https://docs.microsoft.com/en-us/azure/powershell-install-configure</a>

Connect to Azure Subscription using the below Azure Power Shell command.

<strong>Login-AzureRmAccount</strong>

To use Azure backups there is a requirement to use KEK to encrypt the VHD files using azure disk encryption process. You will use your existing Key Vault Server which is used for backing keys and secrets for disk encryption.

<strong>Step 1:</strong> If you have a VM which is already encrypted without BEK, then you want to encrypt with KEK, use the ARM template or PS cmdlet below to change from <em><strong>noKEK to KEK.</strong></em>

Use the below command to add a Keyvaultkey.

This command creates a software-protected key named <strong>ITSoftware</strong> in the vault named Contoso.

<strong>Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITSoftware' -Destination 'Software' </strong>

To get full version of KEK URL run below PS cmdlet.

<strong>Get-AzureKeyVaultKey -VaultName &lt;KeyVaultName&gt; -Name &lt;KEKName&gt;</strong>

Example:

{"kid":"<a href="https://keyvault.vault.azure.net/keys/deKEK/9e7ec10d95a84585abdbb2611070c820">https://keyvault.vault.azure.net/keys/deKEK/9e7ec10d95a84585abdbb2611070c820</a>","kty":"RSA","key_ops":["encrypt","decrypt","sign","verify","wrapKey","unwrapKey"],"n":"oOEexAcY1zIFxEcKqM5Fn6rJYEiQsZubcuRwpoIzE6f5Fqfk4Huro-Gbn5WUPc81japyhzGVZMvBApUY0458F3HNCxvtc5Xszq570HOsMtyi9z8AgF_ZJUZ7rGgnpACcztuIhv2vsAASy-Wg3ELSU6AWA-6ijbehKLSoUG-1XRMLR7t8LQGZcv42V0P-crW17lUyk3AYF86KvA1hnux-6IKtqfGKZEzCeYoORtHka7R1d2G8AdYkHN7qcnIsm0Kxk71qU6PJzTiKRum69d581sZOcpNFGJQiF5dEfZBKnSTxdQvG1u9YDVekvXvHsnXqc9K6oHxs3PbpgAxWAr_qew","e":"AQAB" VaultName  : &lt;keyvaultname&gt; Name       : &lt;keyencryptionkeyname&gt; Version    : 9e7ec10d95a84585abdbb2611070c820 Id         : <a href="https://%3ckeyvaultname%3e.vault.azure.net/keys/%3CKeyEncryptionKeyName%3E/9e7ec10d95a84585abdbb2611070c820">https://&lt;keyvaultname&gt;.vault.azure.net:443/keys/&lt;KeyEncryptionKeyName&gt;/9e7ec10d95a84585abdbb2611070c820</a>
<ol start="3">
 	<li>Now you have the KEK URL, use the below ARM template to encrypt the VM, supply the KEK.</li>
</ol>
<a href="https://github.com/Azure/azure-quickstart-templates/tree/master/201-encrypt-running-windows-vm">https://github.com/Azure/azure-quickstart-templates/tree/master/201-encrypt-running-windows-vm</a>

<a href="https://msdnshared.blob.core.windows.net/media/2016/11/Parameter2.jpg"><img width="455" height="969" class="alignnone size-full wp-image-1625" alt="parameter2" src="https://msdnshared.blob.core.windows.net/media/2016/11/Parameter2.jpg" /></a><a href="https://msdnshared.blob.core.windows.net/media/2016/11/Parameter2.jpg"></a>

&nbsp;

OR

<strong>PowerShell Command:</strong>

<strong>Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId -KeyEncryptionKeyVaultId $KeyVaultResourceId -KeyEncryptionKeyUrl 'KEK URL which you got from above command where it shows the KEK id’ -VolumeType Data</strong>

Example of KEK id:  <a href="https://keyvaultwestus.vault.azure.net/keys/KEKSoftware/1848053030b64216a476ab53f7c5fc5f">https://keyvaultserver.vault.azure.net/keys/ITSoftware/1848053030b64216a476ab53f7c5fc5f</a>

<strong>Azure backup: </strong>

To enable the protection on encrypted VMs [encrypted using BEK and KEK], you need to give permissions for Azure Backup service to read keys and secrets from key vault.

<strong>Set-AzureRmKeyVaultAccessPolicy -VaultName 'KeyVaultServerName' -ResourceGroupName 'RGName' -PermissionsToKeys backup,get,list -PermissionsToSecrets get,list -ServicePrincipalName 262044b1-e2ce-469f-a196-69ab7ada62d3</strong>

<strong>Get-AzureRmKeyVault -VaultName $keyVaultName</strong>

<strong>Get-AzureRmRecoveryServicesVault -Name "ARSName" | Set-AzureRmRecoveryServicesVaultContext</strong>

<strong>$pol=Get-AzureRmRecoveryServicesBackupProtectionPolicy -Name "NewPolicy"</strong>

<strong>Enable-AzureRmRecoveryServicesBackupProtection -Policy $pol -Name "NameofVMtoBackup" -ResourceGroupName "RGNameofVM"</strong>

&nbsp;

<strong>Reference: </strong>

<strong>Deploy and manage backups for Resource Manager-deployed VMs using PowerShell</strong>

<strong><a href="https://docs.microsoft.com/en-us/azure/backup/backup-azure-vms-automation">https://docs.microsoft.com/en-us/azure/backup/backup-azure-vms-automation</a></strong>

<strong>Backup and restore encrypted VMs using Azure Backup: <a href="https://docs.microsoft.com/en-us/azure/backup/backup-azure-vms-encryption">https://docs.microsoft.com/en-us/azure/backup/backup-azure-vms-encryption</a></strong>

<strong>Taking backup of encrypted Azure VMs with ADE (Azure Disk Encryption) using Azure Backup in OMS</strong>

<strong><a href="https://blogs.technet.microsoft.com/privatecloud/2016/09/15/taking-backup-of-encrypted-azure-vms-with-ade-azure-disk-encryption-using-azure-backup-in-oms/">https://blogs.technet.microsoft.com/privatecloud/2016/09/15/taking-backup-of-encrypted-azure-vms-with-ade-azure-disk-encryption-using-azure-backup-in-oms/</a></strong>

<strong>Add-AzureKeyVaultKey Reference: <a href="https://msdn.microsoft.com/en-us/library/dn868048.aspx">https://msdn.microsoft.com/en-us/library/dn868048.aspx</a></strong>

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Azure Disk Encryption - How to recover BEK file from Azure Key Vault</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/azure-disk-encryption-how-to-recover-bek-file-from-azure-key-vault</link>
      <pubDate>Sun, 27 Nov 2016 23:42:10 GMT</pubDate>
      <dc:creator><![CDATA[manojsehgal]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1555</guid>
      <description><![CDATA[In today’s blog, we will demonstrate behavior of Azure Disk Encryption Extension and how it...]]></description>
      <content:encoded><![CDATA[In today’s blog, we will demonstrate behavior of Azure Disk Encryption Extension and how it integrates with Key Vault and the Azure Platform to create and read the (BEK) secrets. It will also describe how you can recover the BEK file from the Key Vault in a scenario where you need to recover the data manually and need to unlock the drive.

If the Volume is encrypted with KEK then use steps in the blog -
<h2><strong>How does Azure Disk Encryption unlock the disk</strong></h2>
When we start the VM the encrypted key is read from the BEK volume which is on azure platform. If they BEK volume is encrypted or the BEK key is not present in BEK volume, then VM will not boot and you will see the below screen.

<a href="https://msdnshared.blob.core.windows.net/media/2016/11/BDEError.jpg"><img width="300" height="234" class="alignnone size-medium wp-image-1565" alt="bdeerror" src="https://msdnshared.blob.core.windows.net/media/2016/11/BDEError-300x234.jpg" /></a>

<strong>Steps</strong>:

&nbsp;
<ol>
 	<li>Stop the VM from Azure Management Portal. VM will go in Deallocated State.</li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2016/11/StopVM.jpg"><img width="300" height="43" class="alignnone size-medium wp-image-1575" alt="stopvm" src="https://msdnshared.blob.core.windows.net/media/2016/11/StopVM-300x43.jpg" /></a>
<ol start="2">
 	<li>Copy the VHD file of the OS disk to a storage account to create a backup. You can use storage explorer to copy the vhd file. (<a href="https://storageexplorer.com/">https://storageexplorer.com</a> ).</li>
 	<li>Attach this copy of VHD file to a running Windows Server test VM as a data drive from azure portal.</li>
 	<li>RDP to the running test VM and you can see the data disk with a drive letter. It will be locked by BitLocker, so you will need to use below steps to get the secret from azure key vault and unlock the volume.</li>
</ol>
<h2>How can you recover BEK files stored in Key Vault</h2>
It is possible to retrieve and extract these BEK files from Key Vault if you have a requirement to manually recover data from a VHD where the OS may not boot. This may also be useful if you are migrating a VM or restoring a VM in a Disaster Recovery scenario.

The BEK files are uploaded to the Key Vault as secrets of the Content Type “BEK”. The secrets themselves are recorded as the name of the BEK, and Tags are used to indicate the Machine Name and Volume Letter. To find the secrets for a specific VM you are working with you can use the below steps using Azure PowerShell command:

<strong>Pre-requisites:</strong> Install Azure Power Shell from <a href="https://docs.microsoft.com/en-us/azure/powershell-install-configure">https://docs.microsoft.com/en-us/azure/powershell-install-configure</a>

Connect to Azure Subscription using the below PS command.

Login-AzureRmAccount

<strong>Steps:</strong>

$vmName = "VMName"

$vault = "KeyVaultServerName"

<em><strong># Get the Secret from Azure Key Vault if VM was encrypted with BEK</strong></em>

Get-AzureKeyVaultSecret -VaultName $vaultName | where {($_.Tags.MachineName -eq $vmName) -and ($_.Tags.VolumeLetter -eq "C:\") -and ($_.ContentType -eq '<strong>BEK</strong>')}

<strong>OR</strong>

<em><strong># Use the below command to get BEK keys for all the Volumes</strong></em>

Get-AzureKeyVaultSecret -VaultName $vault | where {($_.Tags.MachineName -eq $vmName) -and ($_.ContentType -eq 'BEK')}

&nbsp;

<strong>#Convert the KeyVaultSecret to Base64</strong>

<strong>$keyVaultSecret = Get-AzureKeyVaultSecret -VaultName $vault -Name 06327EF7-XXXX-XXXX-XXXX-XXXXXXXXXXXX</strong>

<strong>$bekSecretBase64 = $keyVaultSecret.SecretValueText</strong>

&nbsp;

The next step is to convert the Base64 encoded value to Bytes and then Write the output to a file. <strong>Please note, the BEK file name must match the original BEK GUID</strong> <strong>if using USB unlock option</strong>

&nbsp;

<em><strong>$bekFileBytes = [Convert]::FromBase64String($bekSecretbase64)</strong></em>

<em><strong>$path = "c:\BEK\06327EF7-XXXX-XXXX-XXXX-XXXXXXXXXXXX.BEK"</strong></em>

<em><strong>[System.IO.File]::WriteAllBytes($path,$bekFileBytes)</strong></em>

&nbsp;

<strong>Detail Steps with Results:</strong>

PS C:\&gt; $vmName = "VMName"

$vault = "KeyVaultServerName"

PS C:\&gt; Get-AzureKeyVaultSecret -VaultName $vault | where {($_.Tags.MachineName -eq $vmName) -and ($_.ContentType -eq 'BEK')}

Vault Name   : keyvault

Name         : 06327EF7-xxxx-xxxx-xxxx-xxxxxxxxx

Version      :

Id           : https://keyvault.vault.azure.net:443/secrets/06327EF7-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Enabled      : True

Created      : 11/16/2016 10:06:12 PM

Updated      : 11/16/2016 10:06:12 PM

Content Type : <em><strong>BEK</strong></em>

Tags         : Name                                  Value

VolumeLetter                          C:\

MachineName                           VMName

DiskEncryptionKeyFileName             06327EF7-XXXX-XXXX-XXXX-XXXXXXXXXXXX.BEK

DiskEncryptionKeyEncryptionAlgorithm  RSA-OAEP

&nbsp;

<em>Once the BEK file is created on your PC, copy the BEK file to the azure VM where you can unlock the OS disk.</em>

<em>Open elevated command prompt and run below command, where F is the drive letter of the data disk.</em>

&nbsp;

<em><strong>C:\&gt;manage-bde -status f:</strong></em>

BitLocker Drive Encryption: Configuration Tool version 10.0.14393

Copyright (C) 2013 Microsoft Corporation. All rights reserved.

Volume F: [Label Unknown]

[Data Volume]

Size:                 Unknown GB

BitLocker Version:    2.0

Conversion Status:    Unknown

Percentage Encrypted: Unknown%

Encryption Method:    AES 256

Protection Status:    Unknown

<em><strong>Lock Status:          Locked</strong></em>

Identification Field: Unknown

Automatic Unlock:     Disabled

<em><strong>All Key Protectors:</strong></em>

<em><strong>External Key</strong></em>

Numerical Password

&nbsp;

Since the volume is encrypted by BitLocker, it does shows that it is locked.

&nbsp;

<strong>C:\&gt;manage-bde -unlock f: -rk C:\06327EF7-4C0A-4846-95AB-9AEC07CCE257.BEK</strong>

BitLocker Drive Encryption: Configuration Tool version 10.0.14393

Copyright (C) 2013 Microsoft Corporation. All rights reserved.

The file "C:\06327EF7-4C0A-4846-95AB-9AEC07CCE257.BEK" successfully <strong>unlocked volume F:.</strong>

&nbsp;

If the above command fails to unlock the drive, it means either the BEK file which you got from KeyVault is incorrect.

<em><strong>OR</strong></em>

The drive which is locked does not have the External Key Protector and someone has removed the protector manually using manage-bde command.

To check the External Key protector, use the below command from elevated command prompt:

&nbsp;

<em><strong>manage-bde -protectors -get F:</strong></em>

<em><strong>where F is the drive letter of the volume.</strong></em>

&nbsp;

<strong>References:</strong>

Azure Disk Encryption: <a href="https://azure.microsoft.com/en-us/documentation/articles/azure-security-disk-encryption/">https://azure.microsoft.com/en-us/documentation/articles/azure-security-disk-encryption/</a>

Whitepaper with detail steps: <a href="https://gallery.technet.microsoft.com/Azure-Disk-Encryption-for-a0018eb0">https://gallery.technet.microsoft.com/Azure-Disk-Encryption-for-a0018eb0</a>

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Microsoft Azure: How to execute a synchronous Azure PowerShell cmdlet multiple times at once, using a single PowerShell session</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/microsoft-azure-how-to-execute-a-synchronous-azure-powershell-cmdlet-multiple-times-at-once-using-a-single-powershell-session</link>
      <pubDate>Wed, 29 Jun 2016 14:09:32 GMT</pubDate>
      <dc:creator><![CDATA[Adam Conkle - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1085</guid>
      <description><![CDATA[&nbsp;
Overview
Often times, Microsoft Azure customers have requirements to create multiple...]]></description>
      <content:encoded><![CDATA[&nbsp;
<h1>Overview</h1>
Often times, Microsoft Azure customers have requirements to create multiple resources of the same type, and they wish to have these resources created as quickly as possible in a scripted solution.

Many of the Azure PowerShell cmdlets are synchronous in nature, where the cmdlet will not return until provisioning is complete.

Synchronous operations in PowerShell can significantly slow down a scripted deployment, and the purpose of this post is to help Azure customers script synchronous cmdlets in multiple threads within a single PowerShell session to speed up deployment times.

The example we will demonstrate is the creation of PublicIpAddress resources in Azure Resource Manager (ARM). The cmdlet used is: <strong><em>New-AzureRmPublicIpAddress</em></strong>

<strong><em> </em></strong>
<h1>Disclaimer</h1>
<strong>This post contains a link to a PowerShell code sample. This sample is being provided only as a sample, and is not intended to serve as a solution to any technical issue. Microsoft provides this code sample without support, warranties, and confers no rights. By executing any portion of this code sample, you are agreeing to do so at your own risk.</strong>

&nbsp;
<h1>Sample Scenario</h1>
<ul>
	<li>You have a requirement to create <strong>15 PublicIpAddress resources</strong> in Azure</li>
	<li>You have written a simple for loop like this:<strong><em>for($i=0;$i -lt 15;$i++){New-AzureRmPublicIpAddress -Name "piptest$($i)" -ResourceGroupName contosoRg -Location "East US" -AllocationMethod Dynamic}</em></strong></li>
	<li><strong><u>Result:</u></strong> 15 PublicIpAddress resources are created in roughly <span style="color: #ff0000"><strong>8 minutes, 30 seconds</strong></span>. This is not fast enough, so you decide to try this in Powershell jobs, like this:<strong><em>Start-Job -Name createPip -ScriptBlock {New-AzureRmPublicIpAddress -Name "piptest1" -ResourceGroupName contosoRg -Location "East US" -AllocationMethod Dynamic}</em></strong></li>
	<li><strong><u>Result:</u></strong> <span style="color: #ff0000"><strong>The Powershell job fails because you need to execute Login-AzureRmAccount.</strong></span> This happens because Start-Job does not execute within the context of your existing PowerShell session. The Azure PowerShell module will expect you to authenticate each job.</li>
</ul>
<h1>Final Solution</h1>
There is a trick to making this work with a single Azure Powershell session. The key is the use of <strong><em>[Powershell]::Create()</em></strong> and then passing in and invoking a script block with arguments.
<ol>
	<li>Save a <strong>.ps1</strong> file containing the following code sample:</li>
</ol>
<p style="padding-left: 60px"><strong><a href="https://gallery.technet.microsoft.com/Execute-a-synchronous-8113cf56" target="_blank">TechNet Gallery Code Sample</a></strong></p>
     2. Execute the code sample by calling the saved <strong>.ps1</strong> file using arguments for the following:
<p style="padding-left: 30px">a. <strong><u>Count</u></strong> – Number of resources you need to create</p>
<p style="padding-left: 30px">b. <strong><u>NamePrefix</u></strong> – Resources will be created as “NamePrefixY” where Y is an integer counter for the count of resources created (i.e. – “PipTest1” – “PipTest15” where “PipTest” is the NamePrefix value)</p>
<p style="padding-left: 30px">c. <strong><u>RgName </u></strong>– Name of the Azure Resource Group within your Azure subscription (this must already exist, as the script sample does not create a new Resource Group)</p>
<p style="padding-left: 30px">d. <strong><u>Location</u></strong> – A valid Azure location (i.e. – “East US” or “North Europe”)</p>

<h2>Sample Syntax</h2>
<strong><em>C:\PipTest.ps1 -Count 15 -NamePrefix “PipTest” -RgName “ContosoRg” -Location “East US”</em></strong>

&nbsp;
<h2>Sample Output</h2>
Job for PublicIpAddress PipTest1 - started

Job for PublicIpAddress PipTest2 - started

Job for PublicIpAddress PipTest3 - started

Job for PublicIpAddress PipTest4 - started

Job for PublicIpAddress PipTest5 - started

Job for PublicIpAddress PipTest6 - started

Job for PublicIpAddress PipTest7 - started

Job for PublicIpAddress PipTest8 - started

Job for PublicIpAddress PipTest9 - started

Job for PublicIpAddress PipTest10 - started

Job for PublicIpAddress PipTest11 - started

Job for PublicIpAddress PipTest12 - started

Job for PublicIpAddress PipTest13 - started

Job for PublicIpAddress PipTest14 - started

Job for PublicIpAddress PipTest15 - started

<strong><span style="color: #00ff00">Completed in 0 minutes, 39 seconds</span></strong>

&nbsp;

To conclude, we can execute synchronous Azure PowerShell cmdlets in an asynchronous fashion while sharing Azure authentication across script blocks in a single PowerShell session. This sample demonstrates a <span style="color: #00ff00"><strong>time advantage of nearly 8 minutes </strong></span>for deployment of 15 resources of a single resource type (PublicIpAddress). This sample could be modified to utilize other Azure PowerShell cmdlets to suit your deployment needs.

Enjoy!
Adam Conkle - MSFT]]></content:encoded>
    </item>
    <item>
      <title>Cross-subscription circuit links that cross the ARM/classic boundary</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/cross-subscription-circuit-links-that-cross-the-armclassic-boundary</link>
      <pubDate>Wed, 18 May 2016 01:13:26 GMT</pubDate>
      <dc:creator><![CDATA[Evan Basalik]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=1055</guid>
      <description><![CDATA[(contributed by Michael Jolley)

While enabling an ARM circuit for use with classic deployments is...]]></description>
      <content:encoded><![CDATA[<span style="color: #ff6600;font-family: Calibri"><em>(contributed by Michael Jolley)</em></span>

<span style="color: #000000;font-family: Calibri">While enabling an ARM circuit for use with classic deployments is fairly straightforward on its own, it can be confusing to do so as part of creating cross-subscription circuit links with classic deployments. To do the circuit links, you have to switch between ARM and classic mode while simultaneously switching subscriptions. This can lead to some serious confusion, so I thought it would be worthwhile to document the exact steps and the corresponding PowerShell commands.</span>

<span style="color: #000000;font-family: Calibri"> </span><span style="color: #000000;font-family: Calibri">This walkthrough assumes you have two subscriptions named as follows:</span>

<span style="color: #000000;font-family: Calibri"> </span><span style="color: #000000;font-family: Calibri">1)</span><span style="color: #000000;font-family: Calibri">      </span><span style="color: #000000;font-family: Calibri">Subscription A that contains your ARM circuit</span>

<span style="color: #000000;font-family: Calibri">2)</span><span style="color: #000000;font-family: Calibri">      </span><span style="color: #000000;font-family: Calibri">Subscription B that contains your ASM VNET</span>

<span style="color: #000000;font-family: Calibri"> </span><span style="color: #000000;font-family: Calibri">First, let’s log into ARM under Subscription A so we can enable the circuit for classic operations.</span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"> </span><span style="color: #000000"># Sign in to your Azure Resource Manager environment</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">$SubscriptionA=”GUID for Subscription A”</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">$SubscriptionB=”GUID for Subscription B”</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"> </span><span style="color: #000000">Login-AzureRmAccount</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"> </span><span style="color: #000000"># Select the appropriate Azure subscription</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Get-AzureRmSubscription -SubscriptionId $SubscriptionA | Select-AzureRmSubscription</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"> </span><span style="color: #000000"># Get details of the ExpressRoute circuit</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">$ckt = Get-AzureRmExpressRouteCircuit -Name "DemoCkt" -ResourceGroupName "DemoRG"</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"> </span><span style="color: #000000"># Set "Allow Classic Operations" to TRUE</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">$ckt.AllowClassicOperations = $true</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"> </span><span style="color: #000000"># Update circuit</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Set-AzureRmExpressRouteCircuit -ExpressRouteCircuit $ckt</span></span>

<span style="color: #000000;font-family: Calibri">Now, let’s create the circuit link authorization for the classic VNET. Since we are creating an authorization for use by a classic deployment in Subscription B, you will use the classic commands. Note that since Subscription A owns the circuit, we are still logging in as Subscription A.</span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"># Sign in to your classic environment</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Add-AzureAccount</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"># Select the appropriate Azure subscription</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Set-AzureSubscription -SubscriptionId $SubscriptionA</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"># Create the classic authorization</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">New-AzureDedicatedCircuitLinkAuthorization -ServiceKey $ckt.ServiceKey -Description "Dev-Test Links" -Limit 2 -MicrosoftIds 'devtest@contoso.com'</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Description</span><span style="color: #000000">         </span><span style="color: #000000">: Dev-Test Links</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Limit</span><span style="color: #000000">               </span><span style="color: #000000">: 2</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">LinkAuthorizationId : **********************************</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">MicrosoftIds</span><span style="color: #000000">        </span><span style="color: #000000">: devtest@contoso.com</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Used</span><span style="color: #000000">                </span><span style="color: #000000">: 0</span></span>

<span style="color: #000000;font-family: Calibri">Next, log into Subscription B. Because you are wanting to work with a classic VNET, you need to log in using the classic mode. Since you already logged in under classic mode, all you need to do is change to Subscription B.</span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"># Select the appropriate Azure subscription</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Set-AzureSubscription -SubscriptionId $SubscriptionB</span></span>

<span style="color: #000000;font-family: Calibri">Now, use the authorization. Again, since we are linking to a classic VNET, we will continue to use the classic commands.</span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000"># Use the classic authorization</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">New-AzureDedicatedCircuitLink –servicekey $ckt.ServiceKey –VnetName 'ClassicVNET1'</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">State VnetName</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">----- --------</span></span>

<span style="margin: 0px;line-height: 107%;font-family: 'Courier New';font-size: 10pt"><span style="color: #000000">Provisioned ClassicVNET1</span></span>]]></content:encoded>
    </item>
    <item>
      <title>VM stuck in "Updating" when NSG rule restricts outbound internet connectivity</title>
      <link>https://review.docs.microsoft.com/archive/blogs/mast/vm-stuck-in-updating-when-nsg-rule-restricts-outbound-internet-connectivity</link>
      <pubDate>Wed, 27 Apr 2016 21:00:38 GMT</pubDate>
      <dc:creator><![CDATA[Craig Landis]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mast/?p=955</guid>
      <description><![CDATA[An Azure VM may experience the following symptoms if you have a network security group (NSG) rule...]]></description>
      <content:encoded><![CDATA[An Azure VM may experience the following symptoms if you have a network security group (NSG) rule configured to deny outbound internet connectivity:
<ol>
	<li>When you create a new VM the status remains on <strong>Updating</strong>.</li>
	<li>When you update a VM agent extension on an existing VM, the VM status remains on <strong>Updating</strong>.</li>
	<li>When you update a VM agent extension from Azure Powershell, after 60 minutes the command fails with error <strong><strong>Long running operation failed with status 'Failed'. ErrorCode: VMExtensionProvisioningError ErrorMessage: Multiple VM extensions failed to be provisioned on the VM. Please see the VM extension instance view for details.</strong></strong></li>
	<li>When you check the VM's instance view by running <strong>Get-AzureRmVM -resourcegroupname &lt;resourcegroupname&gt; -name &lt;name&gt; -status,</strong> you see <strong>VMAgent</strong> shows <strong>message:</strong> <strong>VM Agent is unresponsive</strong>.</li>
</ol>
The VM agent requires internet connectivity to connect to Azure storage to update extension status (in a <strong>.status</strong> file in the VM's storage account) as well as to download the extensions themselves into the VM.

To restrict internet connectivity while still allowing the required VM agent connectivity, add NSG rules permitting internet connectivity to only the Azure public IP address ranges for the region where the VM resides.

See the following blog post for steps to configure an NSG to allow traffic to Azure public IP ranges:

<a title="Step-by-Step: Automate Building Outbound Network Security Groups Rules via Azure Resource Manager (ARM) and PowerShell" 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/" target="_blank">Step-by-Step: Automate Building Outbound Network Security Groups Rules via Azure Resource Manager (ARM) and PowerShell</a>

<strong>VM status stuck on "Updating"</strong>

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/NSG01.png"><img class="alignnone size-full wp-image-1035" src="https://msdnshared.blob.core.windows.net/media/2016/04/NSG01.png" alt="NSG01" width="556" height="306" /></a>

<strong> VM extensions show status "unavailable"</strong>

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/NSG2.png"><img class="alignnone size-full wp-image-975" src="https://msdnshared.blob.core.windows.net/media/2016/04/NSG2.png" alt="NSG2" width="555" height="350" /></a>

&nbsp;

<strong>Network security group outbound security rule is configured to deny all outbound internet connectivity</strong>

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/NSG3.png"><img class="alignnone size-full wp-image-985" src="https://msdnshared.blob.core.windows.net/media/2016/04/NSG3.png" alt="NSG3" width="772" height="225" /></a>

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/NSG4.png"><img class="alignnone size-full wp-image-995" src="https://msdnshared.blob.core.windows.net/media/2016/04/NSG4.png" alt="NSG4" width="294" height="587" /></a>

&nbsp;]]></content:encoded>
    </item>
  </channel>
</rss>