<?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>Paulo Marques</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/paulomarques/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/paulomarques/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 26 Mar 2019 21:34:32 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Azure Image Management Automation</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/new-azure-automation-solution-azure-image-management-automation</link>
      <pubDate>Sun, 13 Aug 2017 22:16:29 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=3055</guid>
      <description><![CDATA[&nbsp;

Hello, in this blog post, I will talk about the Azure Image Management Automation which is...]]></description>
      <content:encoded><![CDATA[&nbsp;

Hello, in this blog post, I will talk about the Azure Image Management Automation which is a set Azure Automation Runbooks that allows us to alleviate some of the overhead work that comes with the adoption of custom “golden” images built on-premises and used in Azure.

This solution is a team effort between John Knightly (which is also a PFE) and me, where he could propose an initial solution to his customer and after some discussions between us we could design, develop  and test this solution.
<h1>Overview</h1>
To give a little perspective of how does this solution may help you, lets think about the manual process of having to build a custom golden image (steps 1-3 will exist anyways):
<ol>
 	<li>On Hyper-v or whatever hypervisor solution you use, install the OS from an ISO</li>
 	<li>Perform your customizations</li>
 	<li>Run SYSPREP (for Windows) or waagent -deprovision+user (for Linux)</li>
 	<li>Upload the VHD to a Storage Account by using Azure Storage Explorer, AzCopy, Add-AzureRmVHD, etc.</li>
 	<li>Create a managed Image of this VHD in order to be able to easily deploy VMs from that golden image</li>
</ol>
&nbsp;

These steps are actually very simple but that simplicity stops when you need to make that image available to a second region, in this above example I uploaded the VHD in West US region and into a single subscription, now, what if you need to start deploying VMs from the same golden image throughout one more region? Simple, copy the VHD from the Storage Account in West US to West US 2 and then create a new managed image in that region. Why is that? Because managed images can be only created from VHDs located in the same region. Now, let’s add more, what if you have a DEV, QA and PROD subscriptions? Well, multiply the two steps by 3, giving you 6 operations. Expanding a little bit more, add a Windows and Linux golden image. This math will go to 12 operations you need to manually execute and monitor. Do that each month if you have a monthly golden image release cycle. Already too much work for a small shop correct?

To close this thought, imagine you’re a big global company with lots of business units and each one with its own requirements on Azure, leading you to have 300 subscriptions, be present in at least 10 Azure regions and need to maintain at least two golden images, one for Windows and one for Linux? Well, that will result in 6,000 manual operations a month. This would result in lots o man/hours of work and be error prone.

This solution helps you to simplify and automate this process, what you need to do is to continue producing your golden images and just use a single script to upload the VHD and wait the images being created in each subscription and region.

&nbsp;

It uses the following Azure components:
<ol>
 	<li>Azure Active Directory</li>
 	<li>Azure Storage Accounts</li>
 	<li>Azure Storage Tables</li>
 	<li>Azure Storage Queues</li>
 	<li>Azure Automation</li>
</ol>
&nbsp;

We are also relying on two PowerShell modules I built in order to interact with <a href="https://blogs.technet.microsoft.com/paulomarques/2017/01/17/working-with-azure-storage-tables-from-powershell/">Storage Tables</a> and <a href="https://blogs.technet.microsoft.com/paulomarques/2017/08/12/working-with-azure-storage-queues-from-powershell/">Storage Queues</a>. It also depends on a module created specifically for this solution to avoid code duplication as much as possible.

This diagram summarizes the process:

<a href="https://msdnshared.blob.core.windows.net/media/2018/01/image263.png"><img width="1051" height="990" title="image" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/01/image_thumb258.png" border="0" /></a>

&nbsp;

The following diagram shows how the process works under the hood, from uploading the VHD to producing the managed Image.

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/08/image264.png"><img width="1280" height="1525" title="image" style="border-width: 0px;padding-top: 0px;padding-right: 0px;padding-left: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb204.png" border="0" /></a>

&nbsp;

Before I continue to more details, let me define some terms:
<ul>
 	<li>Tier 0 Storage Account – Storage account that contains the configuration table, the queues for VHD copy process and Managed Image creation process. Finally it is the initial point where the VHD is uploaded first.</li>
 	<li>Tier 1 Blobs – Multiple copies of the original VHD are made inside of the Tier 0 Storage Account to allow multiple parallel copies (this is defined during setup).</li>
 	<li>Tier 0 Subscription – Subscription where all automation components are created.</li>
 	<li>Tier 2 Subscriptions – Subscriptions that holds tier 2 Storage Accounts and will get the <strong>Managed Image</strong> created.</li>
 	<li>Tier 2 Storage Accounts – Final destination of the VHDs, they can be in same or different subscription, different regions, etc.</li>
</ul>
&nbsp;

Step by step explanation:
<ol>
 	<li>After building your VHD, use UploadVHD.ps1 script to upload it to a tier 0 storage account</li>
 	<li>UploadVHD.ps1 script will upload the VHD to Tier 0 Storage Account and will trigger Start-ImageManagementTier1Distribution runbook</li>
 	<li>Start-ImageManagementTier1Distribution will create multiple copies of the VHD in order to allow parallel copies (when using Start-AzureStorageBlobCopy, the source blob is locked until the copy is in progress, meaning that no other copy operation can start)</li>
 	<li>After all copies are done, a message is placed in the copy-process-queue stating that there is a VHD to distribute to Tier 2 Storage Accounts (with other information that will be consumed later)</li>
 	<li>Runbook Start-ImageManagementTier2Distribution is scheduled to run every hour (minimum value) and check the copy-process-queue, if there is a message there, it will trigger one runbook called Start-ImageManagementVhdCopyTier2 that resides in a different Automation Account per destination Tier 2 Storage Account. Note that this is in another Automation Account due to the 200 runbook jobs running at the same time, for a complete list of limitations, please refer to <a href="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#automation-limits" title="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#automation-limits">https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#automation-limits</a>)</li>
 	<li>After each individual runbooks completes its execution, a message per copied VHD is placed in the image-creation-process-queue</li>
 	<li>Another scheduled runbook called Start-ImageManagementImageCreation will monitor that queue (hourly again) and trigger one New-ImageManagementImage runbook (located in another Azure Automation Account due to same reasons already explained, it also can be in multiple Automation Accounts, all depends on how you did the initial setup) per VHD and perform the image creation.</li>
 	<li>The end result is that the managed images will start showing up at the locations you defined.</li>
</ol>
&nbsp;
<h1>Setup Guide</h1>
<!--CRLF-->

To quick install the solution, please refer to the <a href="https://github.com/paulomarquesc/AzureImageManagementAutomation/blob/master/docs/Setup.md">Setup Guide</a>.

For operations and troubleshooting, please refer to the <a href="https://github.com/paulomarquesc/AzureImageManagementAutomation/blob/master/docs/OperationsGuide.md">Operations Guide</a>.

&nbsp;
<h1>Details on SetupInfo.json file</h1>
In order to provide an easy to use solution, I provided a setup script that will automate the installation process for you. But just before we go into this process, we need to review the SetupInfo.json as follows:

<script src="https://gist.github.com/paulomarquesc/baaa3b22b417a86de46070c6081216c7.js"></script>

This JSON file contains the information needed by the setup script to perform its installation, it is basically split into four main sections as follows:
<ul>
 	<li>general</li>
 	<li>requiredModulesToInstall</li>
 	<li>storage</li>
 	<li>automationAccount</li>
</ul>
&nbsp;

Following items describes in detail all sections and what is required to be changed in order to set this up in your own environment.

&nbsp;
<h3>General section</h3>
This section mainly requires the Azure Active Directory tenant name and defines the queue names.
<table width="807" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="139" valign="top">Element Name</td>
<td width="581" valign="top">Description</td>
<td width="85" valign="top">Modification Required?</td>
</tr>
<tr>
<td width="139" valign="top">tenantName</td>
<td width="581" valign="top">That’s the Azure Active Directory tenant name. e.g. test.onmicrosoft.com</td>
<td width="85" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">copyProcessQueueName</td>
<td width="581" valign="top">Name of the queue monitored by the copy process</td>
<td width="85" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">imageCreationQueueName</td>
<td width="581" valign="top">Name of the queue monitored by the image creation process</td>
<td width="85" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">jobTableName</td>
<td width="581" valign="top">Name of the table that holds information about an image distribution job</td>
<td width="85" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">jobLogTableName</td>
<td width="581" valign="top">Name of the log table, it holds all log information for all distribution steps</td>
<td width="85" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">imagesResourceGroup</td>
<td width="581" valign="top">Resource Group where the managed images will be created in all configured subscriptions</td>
<td width="85" valign="top">No</td>
</tr>
</tbody>
</table>
&nbsp;

Section example
<script src="https://gist.github.com/paulomarquesc/38e9e3f65bc1c15140c39baddb459602.js"></script>

&nbsp;
<h3>RequiredModulesToInstall section</h3>
This sections needs to remain unchanged unless you want to have additional modules installed in your Automation Account as soon as it gets created, This is consumed by the setup script to download the required module from PowerShell Gallery and make it available in the Tier 0 storage account for later Azure Automation Account deploment.

This is a simple array with the module names that you want to install.

Section example
<script src="https://gist.github.com/paulomarquesc/e2c7bebe3395b8e67c39da5e466be302.js"></script>

&nbsp;
<h3>Storage section</h3>
This section defines the Tier 0 Storage Account information, number of Tier 1 blob copies and other important information, it also defines each Tier 2 Storage Account which is each individual Storage Accounts that will receive a copy of the VHD, can be in the same or different region/subscription.

This section is split between tier0StorageAccount and tier2StorageAccount as follows:
<h4><u>tier0StorageAccount subsection</u></h4>
Defines information about Tier 0 Storage Account. This SA is the one that contains the configuration table, queues and the blobs to be copied.
<table width="851" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="139" valign="top">Element Name</td>
<td width="631" valign="top">Description</td>
<td width="79" valign="top">Modification Required?</td>
</tr>
<tr>
<td width="139" valign="top">storageAccountName</td>
<td width="631" valign="top">Full name of the tier 0 storage account, make sure this name is unique and can be tested with the cmdlet:
<div>
<div><strong>Get-AzureRmStorageAccountNameAvailability -Name &lt;sa name&gt;</strong></div>
<div></div>
<div>Example: mytierstorageaccount01</div>
</div></td>
<td width="79" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">resourceGroup</td>
<td width="631" valign="top">Name of the resource group that you want this storage account to be created on.

Example: &lt;Company Initials&gt;-OS-Images-Solution-rg</td>
<td width="79" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">location</td>
<td width="631" valign="top">A valid Azure location, to obtain the Azure location list you can execute <strong>Get-AzureRmLocation </strong>to get a list of all locations, use location value.</td>
<td width="79" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">subscriptionId</td>
<td width="631" valign="top">This is guid of the subscription that will have the Tier 0 Storage Account created on. Use <strong>Get-AzureRmSubscription</strong> cmdlet to list all subscriptions you have access.</td>
<td width="79" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">container</td>
<td width="631" valign="top">This is the name of the container that will have the VHD copied to plus the tier 1 copies. Default is “goldenvhds”.</td>
<td width="79" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">modulesContainer</td>
<td width="631" valign="top">This is a container at the storage account that will get all necessary modules uploaded to, later on, the setup process will use this as the source for the Azure Automation modules setup.</td>
<td width="79" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">configurationTableName</td>
<td width="631" valign="top">This is the table that has all configurations used by this solution, manual edit of this table can be done later if you need to change something. Defaults to imageManagementConfiguration.</td>
<td width="79" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">tier1Copies</td>
<td width="631" valign="top">This is the number of copies inside of Tier 0 Storage Account the VHD blob will have, this number will help you to have more copies done in parallel, so the higher the number, the higher the number of concurrent copies. This dictates how fast step 4 described earlier will be but will put some strand on step 3 since will will have multiple copy operations waiting for the source blob to complete the previous copy so a good number will be based on your own environment. This defaults to 300 copies.</td>
<td width="79" valign="top">Yes, adjust it accordingly to how many copy process you will have, maximum supported value is 999.</td>
</tr>
<tr>
<td width="139" valign="top">imagesResourceGroup</td>
<td width="631" valign="top">Resource Group name where the managed images will be created in the tier 0 subscription. Usually this name is the same as the imagesResourceGroup setting of the General section.</td>
<td width="79" valign="top">Yes</td>
</tr>
</tbody>
</table>
&nbsp;
<h4><u>tier2StorageAccounts subsection</u></h4>
This is an array that defines information about each Tier 2 Storage Account. This SA is the one that will receive the final VHD blob and will be used by the managed image creation process. Initially we asked to provide these values inside the SetupInfo.json file, now there is a PowerShell script (Scripts\GenerateTier2StorageJson.ps1) that fills this section based on a text file with the list of subscriptions or single subscription provided from the command line, described later in this document.
<table width="852" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="139" valign="top">Element Name</td>
<td width="629" valign="top">Description</td>
<td width="82" valign="top">Modification Required?</td>
</tr>
<tr>
<td width="139" valign="top">id</td>
<td width="631" valign="top">Id that uniquely identifies this storage account within this section, this is used to perform a test if the storage account exists during setup phase, it looks for this Id in the configuration table, if it is there, it means that the storage account was already deployed and no action is needed. Generally it is obtained using a guid, the GenerateTier2StorageJson.ps1 already adds this value.</td>
<td width="79" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">enabled</td>
<td width="631" valign="top">Indicates if this storage account is enabled or not to receive the VHDs and finally get the image created in the subscription and region where it was deployed, this is enabled by default.</td>
<td width="79" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">imagesResourceGroup</td>
<td width="631" valign="top">Resource Group name where the managed images will be created in the tier 2 subscription. Usually this name is the same as the imagesResourceGroup setting of the General section.</td>
<td width="79" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">storageAccountName</td>
<td width="629" valign="top">This is the full <strong>tier 2</strong> storage account name, the provided example shows how to use a PowerShell 5 class in order to generate the storage account name during the setup phase, the first parameter of this method is the name prefix which is the important change that needs to be made. The provided script (GenerateTier2StorageJson.ps1) asks for the prefix as one of its parameters and build that value.
Example: "^([StorageAccountName]::new(\"<strong>&lt;sa name prefix&gt;</strong>\",[storageAccountTier]::tier2)).GetSaName($true)"<b> </b></td>
<td width="82" valign="top"><b></b>Yes, just the &lt;sa name prefix&gt; part.</td>
</tr>
<tr>
<td width="139" valign="top">resourceGroup</td>
<td width="629" valign="top">Name of the resource group that you want this storage account to be created on.</td>
<td width="82" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">location</td>
<td width="629" valign="top">A valid Azure location, to obtain the Azure location list you can execute <strong>Get-AzureRmLocation </strong>to get a list of all locations, use location value.</td>
<td width="82" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">subscriptionId</td>
<td width="629" valign="top">This is guid of the subscription that will have the Tier 2 Storage Account created on. Use <strong>Get-AzureRmSubscription</strong> cmdlet to list all subscriptions you have access.</td>
<td width="82" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">container</td>
<td width="629" valign="top">This is the name of the container that will have the VHD copied to plus the tier 1 copies. Default is “goldenvhds”.</td>
<td width="82" valign="top">No</td>
</tr>
</tbody>
</table>
&nbsp;

You will have as many Tier 2 Storage Accounts listed in this section as you need, they need to be added as an extra element of this array. Notice that if in the future you need to expand your solution to have more/new Tier 2 Storage Accounts, make sure you use the same JSON file with the additions and run the setup script again. The script will create the new storage accounts or any other extra items you place here, like new number of Automation Accounts as you will see further in this article.

&nbsp;

Section example

<script src="https://gist.github.com/paulomarquesc/19621831cdbfe3e5be2f8489da1f1f80.js"></script>

&nbsp;

You will notice in the sample section that we used a different notation for some of the values, We are adding the ^ sign in the beginning of the string, which means that the setup script will execute a PowerShell expression evaluation of the content of the string. In this case what we are referencing is a value inside of the same JSON file. <strong>$config </strong>is the object we use to load the content of this file, so you can use the paths that we are showing and reference existing values throughout the file so if you have values that repeats, you don’t need to keep copying all the time, but this is complete optional and if you think that adding the actual values will be more educational for documentation purposes feel free to use the actual values. Intention here is just to offer a way to avoid repeating content.

&nbsp;
<h3>Automation Account section</h3>
This section defines your Automation Account settings, we will have here some general settings for the Automation Accounts plus specific sections for three Automation Account types (this is solution wise and does not mean that Azure contains different types of Automation Accounts) as follows:
<ul>
 	<li><strong>Main Automation Account,</strong> this is the one that contains the Start-ImageManagementImageCreation, Start-ImageManagementTier1Distribution and Start-ImageManagementTier2Distribution runbooks.</li>
 	<li><strong>Copy Process Automation Account(s)</strong>, one or more automation accounts to execute the <strong>tier 2</strong> copy process, the number of this type of Automation Accounts will depend on number of subscriptions, regions and images, as it was previously explained, a single Automation Account can execute a maximum of 200 runbook jobs (we cap at a default of 150 in this solution) so if you have, lets say 300 subscriptions, 2 images (1 Windows and 1 Linux) and need to include two regions, you will need at least 8 copy dedicated Automation Accounts in order to be as parallel as possible.</li>
 	<li><strong>Image Creation Process Automation(s)</strong>, same case of the previous description, this automation account is dedicated to create the Managed Images.</li>
</ul>
&nbsp;

<span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px">The formula to easily determine the number of worker automation accounts (copy and image types described above) is :</span>

&nbsp;

(Number of Subscriptions X Number of Images X Number of Regions ) / 150 = Value to be used on <span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px"><strong>workerAutomationAccountsCount</strong> value</span>.

&nbsp;

This section contains the following items:
<table width="851" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="139" valign="top">Element Name</td>
<td width="625" valign="top">Description</td>
<td width="85" valign="top">Modification Required?</td>
</tr>
<tr>
<td width="139" valign="top">automationAccountPrefix</td>
<td width="625" valign="top">This string is used to compose the Automation Account name, this name will be used as the main Automation Account, whereas copy Automation accounts will have this prefix appended with <strong>–Copy999 </strong>where 999 is an incremental counter and image creation Automation Accounts will have <strong>–Img999</strong> appended in the same way. Since these account names cannot be greater than 50, this prefix cannot be more than 42 characters.</td>
<td width="85" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">resourceGroup</td>
<td width="625" valign="top">Name of the resource group that you want the Automation Accounts to be created on.</td>
<td width="85" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">location</td>
<td width="625" valign="top">A valid Azure location, to obtain the Azure location list you can execute <strong>Get-AzureRmLocation </strong>to get a list of all locations, use location value.</td>
<td width="85" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">subscriptionId</td>
<td width="625" valign="top">This is guid of the subscription that will have the Automation Accounts created on. Use <strong>Get-AzureRmSubscription</strong> cmdlet to list all subscriptions you have access.</td>
<td width="85" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">applicationDisplayNamePrefix</td>
<td width="625" valign="top">This is the prefix that will be used to create the service principals in Azure Active Directory, these names will end up being with &lt;prefix&gt;-Copy999 and &lt;prefix&gt;-Img999 the same way the Automation Account Prefix.</td>
<td width="85" valign="top">Yes</td>
</tr>
<tr>
<td width="139" valign="top">workerAutomationAccountsCount</td>
<td width="625" valign="top">This element will dictate how many Automation Accounts will be created for Copy and Image Creation processes, by default it will create two of them, allowing this solution to serve up to 300 subscriptions with one tier 2 storage account and in one location at the same time, increase the number if you want to have more parallel distributions. For example, if we have 100 subscriptions with 3 locations each and maintain one Linux and one Windows image we will end up with (100x3x2) = 600 copy and image creation operations, and in this case we can divide this number by 150 runbook executions and we will have our new number which will be 4.
You can start with a lower number, like the default and increase it to as much as needed and execute the setup gain, setup will add the extra new automation accounts. Note that if you decide to decrease the number this will not remove the extra Automation Accounts, therefore nothing will happen in that setup execution.</td>
<td width="85" valign="top">Yes (depending of how may copy and image creation operations needed for 100% parallel operations)</td>
</tr>
<tr>
<td width="139" valign="top">maxDedicatedCopyJobs</td>
<td width="625" valign="top">Maximum number of copy jobs, this number is a control number, used in a way that the solution knows the maximum and perform corrections if needed.</td>
<td width="85" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">maxDedicatedImageCreationJobs</td>
<td width="625" valign="top">Similar case of maxDedicatedCopyJobssetting but dedicated to image creation jobs.</td>
<td width="85" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">connectionName</td>
<td width="625" valign="top">This is the name of the connection to be created (runas account) during setup.</td>
<td width="85" valign="top">No</td>
</tr>
</tbody>
</table>
&nbsp;

&nbsp;
<h4><u>Runbooks subsection</u></h4>
This section defines all necessary runbooks to setup in each Automation Account type.

It is split between mainAutomationAccount, copyProcessAutomationAccount and imageCreationProcessAutomationAccount and for the sake of trying to keep this post as small as possible (which is being hard to <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/2017/08/wlEmoticon-smile5.png" />) I’m describing one element that is used to define a runbook in any of the sections.

&nbsp;
<table width="844" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="139" valign="top">Element Name</td>
<td width="614" valign="top">Description</td>
<td width="89" valign="top">Modification Required?</td>
</tr>
<tr>
<td width="139" valign="top">name</td>
<td width="614" valign="top">Runbook Name.</td>
<td width="89" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">scriptPath</td>
<td width="614" valign="top">Path to the script to be imported into the PowerShell runbook. This path can be a http path as well, when you download the script directly from GitHub raw path for example.</td>
<td width="89" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">scheduleName</td>
<td width="614" valign="top">Name of the schedule to create and assign to the runbook, the type is hourly schedule only.</td>
<td width="89" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">startTimeOffset</td>
<td width="614" valign="top">This value is used to set the start time of the schedule, in minutes, it tells how many minutes to get started with the schedule during the schedule creation, good for staggering between tier 2 copy runbook and the image creation runbook.</td>
<td width="89" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">executeBeforeMoveForward</td>
<td width="614" valign="top">Forces the execution of the runbook as soon as it gets imported and wait for it to finish. In our case we add the update runbook from GitHub and execute it in order to update all existing modules in the Automation Account since they are outdated at the moment of account creation, if we don’t execute it all other runbook imports fails.</td>
<td width="89" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">parameters</td>
<td width="614" valign="top">This element define an array of key and value pairs, this defines all parameters that the runbook needs when scheduling its execution. For example:

<a href="https://msdnshared.blob.core.windows.net/media/2017/08/image270.png"><img width="987" height="498" title="image" style="border-width: 0px;padding-top: 0px;padding-right: 0px;padding-left: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb210.png" border="0" /></a></td>
<td width="89" valign="top">No</td>
</tr>
<tr>
<td width="139" valign="top">requiredModules</td>
<td width="614" valign="top">An array of modules to import in this automation account if not imported yet. The module list item needs to come from the requiredModulesToInstall section.</td>
<td width="89" valign="top">No</td>
</tr>
</tbody>
</table>
&nbsp;

Section example

<script src="https://gist.github.com/paulomarquesc/bf3b46b0ebdf55b6894b46a193994e93.js"></script>

This section is highly sensitive to what runbooks to install, order and modules so if changing it be sure to don’t change the already existing items.

&nbsp;

&nbsp;

That’s it for this blog post and I hope that this can help.

&nbsp;

Regards

Paulo]]></content:encoded>
    </item>
    <item>
      <title>Working with Azure Storage Queues from PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/working-with-azure-storage-queues-from-powershell</link>
      <pubDate>Sat, 12 Aug 2017 18:16:31 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=3035</guid>
      <description><![CDATA[&nbsp; Hello Everyone, in this blog post I would like to introduce you to my latest PowerShell...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p>Hello Everyone, in this blog post I would like to introduce you to my latest PowerShell module, similarly to the <a href="https://blogs.technet.microsoft.com/paulomarques/2017/01/17/working-with-azure-storage-tables-from-powershell/">AzureRmStorageTables</a> module that I developed a while ago, this module works with Storage Queues, enabling IT Pros to rely on this great service that Azure Storage provides.</p> <p>A fully function example of how IT Pros could leverage tables and queues is presented in <a href="https://github.com/paulomarquesc/AzureImageManagementAutomation">this</a> GitHub repository where I published an Azure Automation based solution that helps customers upload custom virtual hard drives to Azure and have it distributed amongst different regions/subscriptions and generating managed images. This solution will have a separate blog post shortly.</p> <h1>Introduction</h1> <p>Azure Storage Queues is one of the four Microsoft Azure Storage abstractions available (Blobs, Tables and Azure Files are the other ones) at the time that this blog was written. It provides cloud messaging between application components. In designing applications for scale, application components are often decoupled, so that they can scale independently. Queue storage delivers asynchronous messaging for communication between application components, whether they are running in the cloud, on the desktop, on an on-premises server, or on a mobile device. Azure also provides a more full featured alternative called Azure Service Bus which is similar in concept but provides other features.</p> <p>For more information about Service Bus, please refer to <a href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview">Service Bus messaging: flexible data delivery in the cloud</a>.</p> <p>For more information about Azure Storage Queue, please refer to <a href="https://azure.microsoft.com/en-us/services/storage/queues/">Queue storage</a> and <a href="https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-how-to-use-queues">Get started with Azure Queue storage using .NET</a>.</p> <p>If you want to compare Service Bus against Storage Queue, please refer to <a href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted">Storage queues and Service Bus queues - compared and contrasted</a>.</p> <p>&nbsp;</p> <p>Since up to today there are no official cmdlets to support placing/retrieving/deleting/modifying messages on Storage Queues from Azure PowerShell module, I decided to create this simple module to help IT Pros to leverage this service without having knowledge of .NET framework through some simple cmdlets as follows:</p> <table cellspacing="0" cellpadding="2" width="1136" border="0"> <tbody> <tr> <td valign="top" width="353"><strong>Cmdlet</strong></td> <td valign="top" width="781"><strong>Description</strong></td></tr> <tr> <td valign="top" width="353">Add-AzureRmStorageQueueMessage</td> <td valign="top" width="781">Adds a message into the queue</td></tr> <tr> <td valign="top" width="353">Clear-AzureRmStorageQueue</td> <td valign="top" width="781">Clears all messages in a queue</td></tr> <tr> <td valign="top" width="353">Get-AzureRmStorageQueueQueue</td> <td valign="top" width="781">Creates/Gets a queue object/resource</td></tr> <tr> <td valign="top" width="353">Invoke-AzureRmStorageQueueGetMessage</td> <td valign="top" width="781">Get a message from queue and marks it as invisible in the queue for a period of time</td></tr> <tr> <td valign="top" width="353">Invoke-AzureRmStorageQueuePeekMessage</td> <td valign="top" width="781">Gets a single message from the queue without removing it from the queue</td></tr> <tr> <td valign="top" width="353">Invoke-AzureRmStorageQueuePeekMessageList</td> <td valign="top" width="781">Gets a list of messages from the queue without removing it from the queue</td></tr> <tr> <td valign="top" width="353">Remove-AzureRmStorageQueueMessage</td> <td valign="top" width="781">Deletes a message from the queue</td></tr> <tr> <td valign="top" width="353">Update-AzureRmStorageQueueMessage</td> <td valign="top" width="781">Updates a message in the queue</td></tr></tbody></table> <p>&nbsp;</p> <p>There are a number of use cases for using it with PowerShell, specially during automation scenarios where you want to scale your automation to the next level. One example is the before mentioned solution I posted in GitHub. I would love to get more examples from the community over time in the comments section of this post.</p> <p>&nbsp;</p> <h1>Requirements</h1> <ul> <li>PowerShell 4.0 or greater  <li>This module requires Azure PowerShell module installed, which can be downloaded from <a href="https://aka.ms/webpi-azps">https://aka.ms/webpi-azps</a> or the following minimum modules installed via PSGet module from <a href="https://www.powershellgallery.com/">PowerShell Gallery</a>:  <ul> <li>AzureRM.Profile  <li>AzureRM.Storage  <li>AzureRM.Resources  <li>Azure.Storage</li></ul></li></ul> <p>&nbsp;</p> <h1>Installation/Source Code</h1> <p>Since this module is published on PowerShell Gallery, you can install this module directly from PowerShell 5.0 and Windows 10 / Windows Server 2016 by executing the following cmdlet in an elevated PowerShell command prompt window:</p> <div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Install-Module AzureRmStorageQueue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Note that if you want to use the PowerShellGet module in Windows 2012 R2 with PowerShell 4, please look at the <a title="https://www.powershellgallery.com/" href="https://www.powershellgallery.com/">https://www.powershellgallery.com/</a> initial page on how to download and install it. The process is not that straight forward to enable it on Windows 2012 R2 and because of that I placed a summary of the steps below:</p>
<ol>
<li>Download PowerShellGet source code from GitHub (<a title="https://github.com/PowerShell/PowerShellGet/releases" href="https://github.com/PowerShell/PowerShellGet/releases">https://github.com/PowerShell/PowerShellGet/releases</a>) 
<li>Right-click the ZIP flie and click “Unblock” 
<li>Extract it anywhere 
<li>Copy the folder &lt;your extraction folder&gt;\PowerShellHGet-XYZ\PowerShellGet to C:\Program Files\WindowsPowerShell\Modules 
<li>Download and install PackageManagement PowerShell Modules Preview from <a title="https://www.microsoft.com/en-us/download/details.aspx?id=51451" href="https://www.microsoft.com/en-us/download/details.aspx?id=51451">https://www.microsoft.com/en-us/download/details.aspx?id=51451</a> 
<li>Open an elevated PowerShell command prompt and execute<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Install-PackageProvider Nuget –Force</pre><!--CRLF--></div></div>
<li>Close the command prompt 
<li>Open a new elevated PowerShell command prompt and you’re ready to install the Azure Rm Storage Queue module <br></li></ol>
<p>As an alternative, you can manually download the module from my GitHub repository (<a href="https://github.com/paulomarquesc/AzureRmStorageQueue">here</a>) and extract to <strong>C:\Program Files\WindowsPowerShell\Modules</strong> and rename the folder to <strong>AzureRmStorageQueue</strong>. Please remember to unblock the zip file before extracting it.</p>
<p>&nbsp;</p>
<h1>Working with Azure Rm Storage Queue PowerShell Module</h1>
<p>The following steps will walk you through loading the module and perform one or more example tasks of the basic operations offered in this module.</p>
<p>&nbsp;</p>
<p>Before you start working with it, you need to authenticate to Azure and select the correct subscription if you have multiple subscriptions:</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Add-AzureRmAccount</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">Select-AzureRmSubscription -SubscriptionName &lt;your subscription&gt;</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Next, lets import AzureRmTableQueue PowerShell module and list the functions available on it:</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Import-Module AzureRmStorageQueue</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">Get-Command -Module AzureRmStorageQueue -CommandType Function</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>You should see the following cmdlets</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image231.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb174.png" width="1079" height="229"></a></p>
<p>&nbsp;</p>
<p>For the sake of simplicity, we need to define some variables at this point to make our examples a little bit more clean, please, <strong>make sure you have a general purpose storage account to use and that you change the values of the variables below to reflect your environment</strong>. Notice that one of the variables is called <strong>$partitionKey</strong>, in this example we are using only one partition, please refer to the documentation at the end of this blog in order to get a better understanding on benefits of partitions.</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$resourceGroup = <span style="color: #006080">"imageprocess-rg"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">$storageAccountName = <span style="color: #006080">"pmcstorage07tier0"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$queueName = <span style="color: #006080">"my-test-queue"</span></pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>In this example I’m using the storage account named pmcstorage77tier0 and as we can see below I don’t have any queues created yet, this screen shot snippet was taken from Azure Storage Explorer, that can be installed from <a href="https://storageexplorer.com/">here</a>.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image232.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb175.png" width="237" height="127"></a></p>
<p>&nbsp;</p>
<h3>Getting/Creating a queue</h3>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$queue = Get-AzureRmStorageQueueQueue -resourceGroup $resourceGroup -storageAccountName $storageAccountName -queueName $queueName</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>This is the result of the cmdlet below, it created a new queue since I didn’t had yet one named my-test-queue, notice that queue names cannot contain capital letters and spaces.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image233.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb176.png" width="1522" height="205"></a></p>
<p>&nbsp;</p>
<p>If we look at the <a href="https://portal.azure.com">https://portal.azure.com</a> you can see that now I do have a new queue in my storage account:</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image234.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb177.png" width="1388" height="434"></a></p>
<p>&nbsp;</p>
<h3>Adding a message to the queue</h3>
<p>In order to add messages to the queue we need to define a hash table, it can be in a separate object or directly defined in the cmdlet as you can see:</p>
<h4>Example 1</h4>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Add-AzureRmStorageQueueMessage -queue $queue -message @{<span style="color: #006080">"type"</span>=<span style="color: #006080">"copy"</span>;<span style="color: #006080">"vhdname"</span>=<span style="color: #006080">"newvhd.vhd"</span>;<span style="color: #006080">"sourceStorageAccount"</span>=<span style="color: #006080">"pmcstorage05"</span>;<span style="color: #006080">"subscription"</span>=<span style="color: #006080">"mysubscription"</span>}</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image235.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb178.png" width="1891" height="59"></a></p>
<p>&nbsp;</p>
<h4>Example 2 </h4>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$message = @{<span style="color: #006080">"type"</span>=<span style="color: #006080">"copy"</span>;</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">             <span style="color: #006080">"vhdname"</span>=<span style="color: #006080">"newvhd01.vhd"</span>;</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">             <span style="color: #006080">"sourceStorageAccount"</span>=<span style="color: #006080">"pmcstorage05"</span>;</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">             <span style="color: #006080">"subscription"</span>=<span style="color: #006080">"mysubscription"</span>}</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">&nbsp;</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">Add-AzureRmStorageQueueMessage -queue $queue -message $message</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image236.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb179.png" width="796" height="147"></a></p>
<p>&nbsp;</p>
<p>The effect behind the scenes is that this hash table will become a json string in the queue so you can easily consume it in whatever application you need.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image237.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb180.png" width="813" height="255"></a></p>
<p>&nbsp;</p>
<p>Details of message 1</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image238.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb181.png" width="317" height="556"></a></p>
<p>&nbsp;</p>
<h3>Peeking messages from the queue</h3>
<p>Peek process in a queue allows you to get the message without de-queuing it, useful when you need to just inspect values inside of it, we do have two cmdles for this process, one that peeks the first available message (Invoke-AzureRmStorageQueuePeekMessage) or one to get the all messages in the queue (Invoke-AzureRmStorageQueuePeekMessageList).</p>
<p>&nbsp;</p>
<h4>Example 1 – Peeking a single message</h4>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$message = Invoke-AzureRmStorageQueuePeekMessage -queue $queue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Result</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image239.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb182.png" width="782" height="342"></a></p>
<p>&nbsp;</p>
<h4>Example 2 – Peeking all messages</h4>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$messageList = Invoke-AzureRmStorageQueuePeekMessageList -queue $queue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Result</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image240.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb183.png" width="875" height="578"></a></p>
<p>&nbsp;</p>
<h3>De-queuing messages from the queue</h3>
<p>This process is a little different because this is the regular queue operation, it hides the message as soon as it is de-queued for processing for example.</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$message =  Invoke-AzureRmStorageQueueGetMessage -queue $queue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Result</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image241.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb184.png" width="790" height="332"></a></p>
<p>&nbsp;</p>
<p>Please notice the DequeueCount property of the message, stating that it was de-queued one time. Now if we perform a peek to get all messages we just see the second message added because it was not de-queued. You can verify because the message ID is different as well.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image242.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb185.png" width="719" height="309"></a></p>
<p>&nbsp;</p>
<h3>Clearing queue from all messages</h3>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Clear-AzureRmStorageQueue -queue $queue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Result</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image243.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb186.png" width="992" height="148"></a></p>
<p>&nbsp;</p>
<p>if you don’t want to be asked for confirmation you can just add <strong>–Confirm:$false </strong>to the end of the line.</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Clear-AzureRmStorageQueue -queue $queue -Confirm:$false</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image244.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb187.png" width="700" height="43"></a></p>
<p>&nbsp;</p>
<h3>Removing messages from the queue</h3>
<p>In this situation we have two ways to preform this, one is by passing the CloudQueueMessage object which is obtained by using the Invoke-AzureRmStorageQueueGetMessage cmdlet or if you know the message id and the popReceipt values you can use them directly. Notice that you can only delete a message if you de-queue it first.</p>
<p>&nbsp;</p>
<h4>Example 1 – Passing CloudQueueMessage object as argument</h4>
<p>&nbsp;</p>
<p>Adding a test message to queue</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Add-AzureRmStorageQueueMessage -queue $queue -message @{<span style="color: #006080">"type"</span>=<span style="color: #006080">"copy"</span>;<span style="color: #006080">"vhdname"</span>=<span style="color: #006080">"vhd01.vhd"</span>;<span style="color: #006080">"sourceStorageAccount"</span>=<span style="color: #006080">"pmcstorage05"</span>;<span style="color: #006080">"subscription"</span>=<span style="color: #006080">"mysubscription"</span>}</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image245.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb188.png" width="1885" height="47"></a></p>
<p>De-queuing de message</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$message =  Invoke-AzureRmStorageQueueGetMessage -queue $queue</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image246.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb189.png" width="780" height="336"></a></p>
<p>&nbsp;</p>
<p>Removing the message based on the CloudQueueMessage object</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Remove-AzureRmStorageQueueMessage -queue $queue -message $message</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image247.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb190.png" width="813" height="79"></a></p>
<p>&nbsp;</p>
<p>Notice that after deleting it I tried to de-queue the message but nothing came out because I deleted the message.</p>
<p>&nbsp;</p>
<h4>Example 2 – Passing message ID and popReceipt as argument</h4>
<p>&nbsp;</p>
<p>Adding another test message in the queue</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Add-AzureRmStorageQueueMessage -queue $queue -message @{<span style="color: #006080">"type"</span>=<span style="color: #006080">"copy"</span>;<span style="color: #006080">"vhdname"</span>=<span style="color: #006080">"vhd02.vhd"</span>;<span style="color: #006080">"sourceStorageAccount"</span>=<span style="color: #006080">"pmcstorage05"</span>;<span style="color: #006080">"subscription"</span>=<span style="color: #006080">"mysubscription"</span>}</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>De-queuing message</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$message =  Invoke-AzureRmStorageQueueGetMessage -queue $queue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Displaying message contents</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image248.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb191.png" width="794" height="338"></a></p>
<p>Those red highlighted properties are the ones we will pass in the next cmdlet to delete the message.</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Remove-AzureRmStorageQueueMessage -queue $queue -messageId <span style="color: #006080">"969f7550-982d-49d5-bff8-26324adcf587"</span> -popReceipt <span style="color: #006080">"AgAAAAMAAAAAAAAAgi9WalsU0wE="</span></pre><!--CRLF--></div></div>
<p>Of course I could use the $message object I already as <strong>$message.id </strong>and <strong>$message.popReceipt </strong>but my idea was to show how the actual values looks like.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image249.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb192.png" width="1651" height="67"></a></p>
<p>As a side note, message only gets the popReceipt when you de-queue it.</p>
<p>&nbsp;</p>
<h3>Updating a message and placing it back to the queue</h3>
<p>Sometimes all you need is to update the message content, this operation exemplifies how to perform this operation.</p>
<p>&nbsp;</p>
<p>Adding a test message to the queue</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Add-AzureRmStorageQueueMessage -queue $queue -message @{<span style="color: #006080">"type"</span>=<span style="color: #006080">"copy"</span>;<span style="color: #006080">"vhdname"</span>=<span style="color: #006080">"vhd03.vhd"</span>;<span style="color: #006080">"sourceStorageAccount"</span>=<span style="color: #006080">"pmcstorage05"</span>;<span style="color: #006080">"subscription"</span>=<span style="color: #006080">"mysubscription"</span>}</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>De-queuing the message</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$msg = Invoke-AzureRmStorageQueueGetMessage -queue $queue</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image250.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb193.png" width="1881" height="334"></a></p>
<p>&nbsp;</p>
<p>In this example we are changing the VHD name property of the JSON string with a random name, but first we need convert this JSON string into a PowerShell object to make things easier.</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$msgObj = $msg.AsString | ConvertFrom-Json</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image251.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb194.png" width="576" height="140"></a></p>
<p>Changing the property content</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$msgObj.vhdname = [<span style="color: #0000ff">string</span>]::format(<span style="color: #006080">"{0}.vhd"</span>,[guid]::NewGuid().guid)</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image252.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb195.png" width="931" height="136"></a></p>
<p>&nbsp;</p>
<p>Updating the message object </p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">$msg.SetMessageContent(($msgObj | ConvertTo-Json -Depth 100))</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image253.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb196.png" width="857" height="329"></a></p>
<p>&nbsp;</p>
<p>Updating the message in the queue</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Update-AzureRmStorageQueueMessage -queue $queue -message $msg</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image254.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb197.png" width="767" height="55"></a></p>
<p>&nbsp;</p>
<p>Making the message visible again in the queue and peeking the queue to check the changes made, notice that the popReceipt is null meaning the message is ready to get de-queued again.</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Update-AzureRmStorageQueueMessage -queue $queue -message $msg -visibilityTimeout 0</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">Invoke-AzureRmStorageQueuePeekMessage -queue $queue</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">&nbsp;</pre><!--CRLF--></div></div>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/08/image255.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/08/image_thumb198.png" width="1010" height="338"></a></p>
<p>&nbsp;</p>
<p>Well, that’s it for this post, I hope you enjoy this new PowerShell module and that it helps you build great PowerShell scripts using Azure Storage Queues.</p>
<p>&nbsp;</p>
<p>Regards</p>
<p>&nbsp;</p>
<p>Paulo</p>]]></content:encoded>
    </item>
    <item>
      <title>Adding an Azure Virtual Machine that uses managed disk into an availability set–manual process</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/adding-an-azure-virtual-machine-that-uses-managed-disk-into-an-availability-set-manual-process</link>
      <pubDate>Sat, 01 Apr 2017 00:02:32 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=2555</guid>
      <description><![CDATA[Hi Everyone,  UPDATE (08/19/2017): The PowerShell Module described below now supports both Managed...]]></description>
      <content:encoded><![CDATA[<p>Hi Everyone, </p> <p><font color="#ff0000"><strong>UPDATE (08/19/2017)</strong></font>: The PowerShell Module described below now supports both Managed and&nbsp; Unmanaged Disks, so there is no need anymore to use this manual process unless you want to understand what happens behind the scenes of the module. </p> <p>This blog post walks you through the manual process of adding an Azure virtual machine that uses managed disk to an availability set using a manual process purely inside the Azure portal (<a href="https://portal.azure.com">https://portal.azure.com</a>). Note that if you have virtual machines using <strong>unmanaged</strong> disks that needs to be included in an availability set, you can use a PowerShell module posted at the TechNet Gallery using this <a href="https://gallery.technet.microsoft.com/Azure-RM-Availability-Set-39e19d01?redir=0">link</a>.</p> <p>This blog assumes you have a great understanding of what is an availability set, if you don’t know what this is, please refer to <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/infrastructure-availability-sets-guidelines">Azure availability sets guidelines for Windows VMs</a> and <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/manage-availability?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json">Manage the availability of Windows virtual machines in Azure</a>. It also assume that you have the concepts of managed disks in Azure, if not, please refer to <a href="https://docs.microsoft.com/en-us/azure/storage/storage-managed-disks-overview">Azure Managed Disks Overview</a>.</p> <p>Finally we need the following items already deployed in Azure:</p> <ul> <li>Availability set aligned to be used with managed disks  <li>The virtual machine using managed disks that is not yet associated with an availability set</li></ul> <p>&nbsp;</p> <p>This example also assumes that you don’t have any data disk attached to your virtual machine, if that’s the case you need to change the dataDisks in a similar way I do with the osDisk property.</p> <p>&nbsp;</p> <p>Steps</p> <ol> <li>Sign in at <a href="https://portal.azure.com">https://portal.azure.com</a> <br> <li>Export the current template definition of you live resource (virtual machine in this case)<br> <ol> <li>At the top navigation bar of Azure Portal, click in the search field and type “resource explorer”  <li>Click on “resource explorer”<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image3.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb3.png" width="1233" height="188"></a><br><br> <li>Easiest way to navigate over your resources is expanding Subscriptions-&gt;Subscription Name-&gt;Providers-&gt;Microsoft.Compute-&gt;virtualMachines-&gt;<strong>VM Name</strong><br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image4.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb4.png" width="1923" height="889"></a><br><br> <li>On the details pane, where the template shows up, copy all its template contents and save it locally with notepad or any tool you may find appropriate.  <li>Close “Resource Explorer”<br></li></ol> <li>Delete your virtual machine (yes, as of the day this article was written you can delete the virtual machine in Azure and the disks gets preserved)<br> <li>Create a new deployment<br> <ol> <li>Click on “+ New”, at the search field, type “template deployment” and press enter<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image5.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb5.png" width="390" height="323"></a><br><br> <li>Select “Template Deployment” from the “Everything” blade and click “Create”<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image6.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb6.png" width="1235" height="427"></a><br><br><br> <li>At the “Custom deployment” blade, click “Edit template”. This will bring a bring a blank template structure.<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image7.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb7.png" width="815" height="223"></a><br><br><br> <li>At line 5, between the square brackets “[]”, paste the template you saved in the file.<br><br><strong>Blank template</strong><br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image8.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb8.png" width="1150" height="254"></a><br><br><strong>Template after content was pasted<br></strong><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image9.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb9.png" width="1652" height="971"></a><br><br><br> <li>Delete the line that contains “vmId” property, in this guide this is line 7<br> <li>Replace the contents of imageReference:<br> <ol> <li>From<br><br> <div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"imageReference"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"publisher"</span>: <span style="color: #006080">"OpenLogic"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"offer"</span>: <span style="color: #006080">"CentOS"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"sku"</span>: <span style="color: #006080">"7.3"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"version"</span>: <span style="color: #006080">"latest"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">},</pre><!--CRLF--></div></div><br>
<li>To<br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"imageReference"</span>: <span style="color: #0000ff">null</span>,</pre><!--CRLF--></div></div><br><br></li></ol>
<li>Replace the contents of osDisk:<br>
<ol>
<li>From<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"osDisk"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"osType"</span>: <span style="color: #006080">"Linux"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"name"</span>: <span style="color: #006080">"centos02"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"createOption"</span>: <span style="color: #006080">"FromImage"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"caching"</span>: <span style="color: #006080">"ReadWrite"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"diskSizeGB"</span>: 31</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">},</pre><!--CRLF--></div></div><br>
<li>To<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"osDisk"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">  <span style="color: #006080">"createOption"</span>: <span style="color: #006080">"Attach"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">  <span style="color: #006080">"osType"</span>: <span style="color: #006080">"Linux"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">  <span style="color: #006080">"managedDisk"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"id"</span>: <span style="color: #006080">"&lt;Resource ID of your OS Disk&gt;"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">  }</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">},</pre><!--CRLF--></div></div><font style="background-color: #ffff00">Where &lt;Resource ID of your OS Disk&gt; needs to point to the resource ID of the currently existing OS Disk, which can be obtained by searching for the disk in the search field of the top navigation pane and copying the Resource ID property (note that you need to open a new tab on your internet browser)</font><br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image10.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb10.png" width="1229" height="405"></a><br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image11.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb11.png" width="921" height="702"></a><br><br><br></li></ol>
<li>Replace the content of “osProfile”<br>
<ol>
<li>From<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"osProfile"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"computerName"</span>: <span style="color: #006080">"centos02"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"adminUsername"</span>: <span style="color: #006080">"pmcadmin"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    <span style="color: #006080">"linuxConfiguration"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">        <span style="color: #006080">"disablePasswordAuthentication"</span>: <span style="color: #0000ff">false</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    <span style="color: #006080">"secrets"</span>: []</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">},</pre><!--CRLF--></div></div><br>
<li>To<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"osProfile"</span>: <span style="color: #0000ff">null</span>,</pre><!--CRLF--></div></div><br><br></li></ol>
<li>Insert the new element for the <strong>Availability Set</strong>. For that, go to the line where it starts with “provisioningState”, Insert a line before “provisioningState” and paste the following element (including the extra comma)<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"availabilitySet"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">  <span style="color: #006080">"id"</span>: <span style="color: #006080">"&lt;Resource ID of the Availability Set&gt;"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">},</pre><!--CRLF--></div></div><br>To obtain the resource Id: 
<ol>
<li>At the top navigation pane, click the search icon 
<li>Type the availability set name at the search field 
<li>Select the availability set 
<li>Click “Properties” 
<li>Copy the Resource Id by clicking at the copy icon (<a href="https://msdnshared.blob.core.windows.net/media/2017/04/image15.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb15.png" width="27" height="25"></a>)<br><br></li></ol>
<li><font style="background-color: #ffff00">Notice that if your VM have any installed extension, you need to remove them from this template otherwise the deployment may fail, you can always add the extensions back later, dealing with extensions is out of scope of this blog post.</font><br>
<li>Just after the very last property of your template, in my case “name”, which is the virtual machine name, add a comma at the end of the “name” line and add the following line (you must have a comma before this new “apiVersion”, otherwise validation will fail.<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #006080">"apiVersion"</span>: <span style="color: #006080">"2016-04-30-preview"</span></pre><!--CRLF--></div></div><br>
<li>Your template code should be similar to this<br><br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">{</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">  <span style="color: #006080">"$schema"</span>: <span style="color: #006080">"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">  <span style="color: #006080">"contentVersion"</span>: <span style="color: #006080">"1.0.0.0"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">  <span style="color: #006080">"parameters"</span>: {},</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">  <span style="color: #006080">"resources"</span>: [</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">      <span style="color: #006080">"properties"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">        <span style="color: #006080">"hardwareProfile"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">          <span style="color: #006080">"vmSize"</span>: <span style="color: #006080">"Standard_A1"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">        },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">        <span style="color: #006080">"storageProfile"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">          <span style="color: #006080">"imageReference"</span>: <span style="color: #0000ff">null</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">          <span style="color: #006080">"osDisk"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">            <span style="color: #006080">"createOption"</span>: <span style="color: #006080">"Attach"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">            <span style="color: #006080">"osType"</span>: <span style="color: #006080">"Linux"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">            <span style="color: #006080">"managedDisk"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">              <span style="color: #006080">"id"</span>: <span style="color: #006080">"/subscriptions/&lt;GUID&gt;/resourceGroups/TEST03-RG/providers/Microsoft.Compute/disks/centos02"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">            }</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">          },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">          <span style="color: #006080">"dataDisks"</span>: []</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">        },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">        <span style="color: #006080">"osProfile"</span>: <span style="color: #0000ff">null</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">        <span style="color: #006080">"networkProfile"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">          <span style="color: #006080">"networkInterfaces"</span>: [</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">            {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">              <span style="color: #006080">"id"</span>: <span style="color: #006080">"/subscriptions/&lt;GUID&gt;/resourceGroups/test03-rg/providers/Microsoft.Network/networkInterfaces/centos0287"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">            }</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">          ]</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">        },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">        <span style="color: #006080">"availabilitySet"</span>: {</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">          <span style="color: #006080">"id"</span>: <span style="color: #006080">"&lt;Resource ID of the Availability Set&gt;"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">        },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">        <span style="color: #006080">"provisioningState"</span>: <span style="color: #006080">"Succeeded"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">      },</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">      <span style="color: #006080">"type"</span>: <span style="color: #006080">"Microsoft.Compute/virtualMachines"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">      <span style="color: #006080">"location"</span>: <span style="color: #006080">"westus"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">      <span style="color: #006080">"id"</span>: <span style="color: #006080">"/subscriptions/&lt;GUID&gt;/resourceGroups/test03-rg/providers/Microsoft.Compute/virtualMachines/centos02"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">      <span style="color: #006080">"name"</span>: <span style="color: #006080">"centos02"</span>,</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">      <span style="color: #006080">"apiVersion"</span>: <span style="color: #006080">"2016-04-30-preview"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    }</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">  ]</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">}</pre><!--CRLF--></div></div><br>
<li>Click “Save”<br><br>
<li>Select the same exact resource group where your virtual machine existed at the “Resource group” field and same location if available to choose, then click “I agree to the terms and conditions stated above” and click “Purchase”<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image12.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb12.png" width="897" height="718"></a><br><br><br></li></ol></li></ol>
<p>If any errors come up, you can always click in the notification icon at the top navigation pane and select the failed deployment:</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image13.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb13.png" width="841" height="441"></a></p>
<p>&nbsp;</p>
<p>This will bring the failed deployment blade</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image14.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb14.png" width="586" height="694"></a><br><br>Then just click on “Redeploy” button so you can edit the template and fix any issues.</p>
<p>&nbsp;</p>
<p>Again, if you have virtual machines using <strong>unmanaged</strong> disks that needs to be included in an availability set, you can use a PowerShell module that I developed and poste at the TechNet Gallery using this <a href="https://gallery.technet.microsoft.com/Azure-RM-Availability-Set-39e19d01?redir=0">link</a>.<font style="background-color: #ffff00"></font><br><br><br>That’s it for this blog and I hope this helps.</p>]]></content:encoded>
    </item>
    <item>
      <title>Sample bash script executing Azure CLI 2.0 commands, which can be executed on Linux (tested on Ubuntu) or Bash on Ubuntu on Windows 10</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/sample-bash-script-executing-azure-cli-2-0-commands-which-can-be-executed-on-linux-tested-on-ubuntu-or-bash-on-ubuntu-on-windows-10</link>
      <pubDate>Thu, 02 Mar 2017 18:31:43 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=2365</guid>
      <description><![CDATA[Hello everyone, this blog post directs you to a sample bash script that uses Azure CLI 2.0 that...]]></description>
      <content:encoded><![CDATA[<h3><font size="1">Hello everyone, this blog post directs you to a sample bash script that uses Azure CLI 2.0 that performs some deployment operations on Azure. There is a counterpart script based on PowerShell that can be found at </font><a href="https://gallery.technet.microsoft.com/Azure-Resource-Manager-6514f9ca?redir=0"><font size="1">https://gallery.technet.microsoft.com/Azure-Resource-Manager-6514f9ca?redir=0</font></a><font size="1">.</font></h3> <p>Basically this bash script with Azure CLI 2.0 deploys the following components:  <ul> <li>1 x Resource Group  <li>1 x Storage Account  <li>2 x Virtual Networks  <li>1 x Network Security Group  <li>2 x Linux Virtual Machines, one in each virtual network </li></ul> <p>This script requires JQ and Azure CLI 2.0 installed in your Linux/Bash on Ubuntu on Windows.  <p>If you want to use Bash on Ubuntu on Windows 10, please refer to <a href="https://msdn.microsoft.com/en-us/commandline/wsl/install_guide">this</a> documentation in order to enable it.  <h2>Installing Azure CLI 2.0 on Bash on Ubuntu on Windows</h2> <p>Azure CLI 2.0 is a new version of Azure Xplat CLI, and it is used to manage Azure (Resource Manager mode only) through command line on Windows, Linux and OS X.  <ul> <li>Updating Python to the latest version (minimum supported is 2.7.6)  <ul> <li>To check installed version: python –version,  <li>Execute the following steps to update to the latest version if needed:</li></ul> <div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo add-apt-repository ppa:fkrull/deadsnakes-python2.7</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">sudo apt-get update </pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo apt-get install python2.7</pre><!--CRLF--></div></div>
<li>
<p>Install other dependencies<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo apt-get update &amp;&amp; sudo apt-get install -y libssl-dev libffi-dev python-dev</pre><!--CRLF--></div></div></li></ul>
<p>&nbsp; <ul>
<li>
<p>Install Azure CLI 2.0<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo su</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">curl -L https://aka.ms/InstallAzureCli | bash</pre><!--CRLF--></div></div><br>When asked type the following answers:<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">/usr/lib/azure-cli</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">/usr/bin</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">y</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">/etc/bash.bashrc</pre><!--CRLF--></div></div></li></ul>
<p>&nbsp;</p>
<ul>
<li>
<p>Exit bash and open it again</p></li></ul>
<p>&nbsp; <h2>Installing Azure CLI 2.0 on Ubuntu 16.10</h2>
<ul>
<li>
<p>These steps assumes you installed a VM based on Ubuntu 16.10 from Azure marketplace, perform upgrade on existing packages<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo apt-get update</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">sudo apt-get upgrade –y</pre><!--CRLF--></div></div></li></ul>
<p>&nbsp;&nbsp;&nbsp; <ul>
<li>
<p>Install dependencies<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo apt-get update &amp;&amp; sudo apt-get install -y libssl-dev libffi-dev python-dev build-essential</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">sudo su</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">curl -L https://aka.ms/InstallAzureCli | bash</pre><!--CRLF--></div></div><br>
<li>
<p>When asked type the following answers:<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">/usr/lib/azure-cli    </pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">/usr/bin</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">y</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">/etc/bash.bashrc</pre><!--CRLF--></div></div><br>
<li>
<p>Logoff of this session and open session again</p></li></ul>
<p>&nbsp; <p>&nbsp; <p>For more information about Azure CLI 2.0 please refer to <a href="https://docs.microsoft.com/en-us/cli/azure/overview">https://docs.microsoft.com/en-us/cli/azure/overview</a>. 
<h4><br><br></h4>
<h2>Installing JQ</h2>
<p>jq is a json command-line json processor which helps querying (it also transforms) json strings to extract information. 
<ul>
<li>
<p>On Bash on Ubuntu on Windows 10 prompt execute the following steps: 
<ul>
<li>
<p>Install dependencies<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo apt-get install build-essential libtool autoconf gcc –y</pre><!--CRLF--></div></div><br>
<li>
<p>Download and extract oniguruma and jq sources<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">curl -L https:<span style="color: #008000">//github.com/kkos/oniguruma/releases/download/v5.9.6_p1/onig-5.9.6_p1.tar.gz -o ./onig-5.9.6_p1.tar.gz</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">curl -L https:<span style="color: #008000">//github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz -o jq-1.5.tar.gz</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">tar -xvzf ./onig-5.9.6_p1.tar.gz</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">tar -xvzf ./jq-1.5.tar.gz</pre><!--CRLF--></div></div><br>
<li>
<p>Install oniguruma<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">cd onig-5.9.6</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">./configure &amp;&amp; make &amp;&amp; sudo make install</pre><!--CRLF--></div></div><br></li></ul>
<ul>
<li>
<p>Install jq<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">cd jq-1.5</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">./configure &amp;&amp; make &amp;&amp; sudo make install</pre><!--CRLF--></div></div><br></li></ul>
<li>
<p>To install on full Ubuntu 16.10 execute the following:<br><br></p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo apt-get install jq -y</pre><!--CRLF--></div></div><br></li></ul>
<p>For more information on jq, please refer to <a href="https://stedolan.github.io/jq/">https://stedolan.github.io/jq/</a>. 
<h4>&nbsp;</h4>
<p>&nbsp;</p>
<h2>Running the script</h2>
<p>The script can be manually downloaded from <a title="https://github.com/paulomarquesc/AzureCLI2.0BashDeployment" href="https://github.com/paulomarquesc/AzureCLI2.0BashDeployment">https://github.com/paulomarquesc/AzureCLI2.0BashDeployment</a> or you can download directly using curl:</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">curl -O https://raw.githubusercontent.com/paulomarquesc/AzureCLI2.0BashDeployment/master/azuredeploy.sh</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Change the file properties to be able to be executed as a script:</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">chmod 700 ./azuredeploy.sh</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Authenticate to azure with az login (follow the steps to sign on using a browser and entering your Azure AD or MSA account that you use to manage Azure resources):</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az login</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>Basic Script syntax:</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">./azuredeploy.sh -s &lt;subscription name&gt; -r &lt;resource group name&gt; -l &lt;location&gt;</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Hope that this blog post gives you a good visibility on how to use Azure CLI 2.0 and bash. This script was tested on Ubuntu 16.10 and Bash on Ubuntu on Windows 10 environments.</p>
<p>&nbsp;</p>
<p>Regards</p>
<p>&nbsp;</p>
<p>Paulo</p>]]></content:encoded>
    </item>
    <item>
      <title>Deploying a virtual machine based on a generalized custom image using the Azure Portal</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/deploying-a-virtual-machine-based-on-a-generalized-custom-image-using-the-azure-portal</link>
      <pubDate>Fri, 17 Feb 2017 21:12:12 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=2356</guid>
      <description><![CDATA[Hello everyone, Just to close the discussion started on Creating an Ubuntu Server 16.10 generalized...]]></description>
      <content:encoded><![CDATA[<p>Hello everyone,</p> <p>Just to close the discussion started on <a href="https://blogs.technet.microsoft.com/paulomarques/2017/02/11/creating-an-ubuntu-server-16-10-specialized-image-on-azure-and-deploying-a-new-vm-based-on-this-image-using-azure-cli-2-0/">Creating an Ubuntu Server 16.10 generalized image on Azure and Deploying a new VM based on this image using Azure CLI 2.0</a>, where we deployed an Ubuntu VM from the Azure Marketplace, then customized its image and deployed other VM based on this generalized image by using Azure CLI 2.0, here is a quick follow up with a complement option, which is deploying a VM from from that same image but now from the portal.</p> <p>This portal option is easier than the process described in my previous article, please just follow these steps in order to perform this deployment:</p> <ol> <li>From the Azure Portal (<a href="https://portal.azure.com">https://portal.azure.com</a>), click on “More Services”<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image313.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb267.png" width="483" height="772"></a><br><br></li> <li> Type images in the search textbox and click “Images” result<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image314.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb268.png" width="667" height="772"></a><br><br><br></li> <li>If you followed the steps I outlined in the mentioned blog post, you will have at least one image listed at the Images blade, click on the image name<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image315.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb269.png" width="1028" height="472"></a><br><br><br></li> <li>Click on “+ Create VM” <br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image316.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb270.png" width="1028" height="580"></a><br><br><br></li></ol> <p>Follow the regular steps to complete the VM deployment similar to the steps you take with a regular Azure Marketplace image.</p> <p><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image317.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb271.png" width="812" height="772"></a><br><br><br><br>That’s it for this quick and simple post, I just think that this is a really cool feature that I had to blog about it <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none;border-left-style: none;border-bottom-style: none;border-right-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/2017/02/wlEmoticon-smile2.png">.</p> <p>&nbsp;</p> <p>Regards</p> <p>&nbsp;</p> <p>Paulo</p>]]></content:encoded>
    </item>
    <item>
      <title>Executing Custom Script Extension using Azure CLI 2.0 on an Azure Linux Virtual Machine</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/executing-custom-script-extension-using-azure-cli-2-0-on-an-azure-linux-virtual-machine</link>
      <pubDate>Mon, 13 Feb 2017 22:51:25 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=2245</guid>
      <description><![CDATA[Hello Everyone, This blog post shows an end-to-end scenario for executing a bash script remotely on...]]></description>
      <content:encoded><![CDATA[<p>Hello Everyone,</p> <p>This blog post shows an end-to-end scenario for executing a <strong>bash </strong>script remotely on an Azure Linux VM. I put this together because out there we have documentation for the commands individually but no end-to-end example, here I show how to obtain the storage account key, how to check if a container exists and create one if it doesn’t and execute the script securely without public access turned on.  <p>The following steps will guide through running a bash script through the Custom Script Extension for Linux. <p>It is also assumed that you have Azure CLI 2.0 installed in a management computer by following the steps outlined <a href="https://docs.microsoft.com/en-us/cli/azure/install-az-cli2">here</a> to perform the installation, all command line instructions below assumes you are executing them on Linux <strong>bash, </strong>I’m using <strong>Bash on Ubuntu on Windows 10 </strong>to write this post. <p>&nbsp; <h2>Steps</h2> <p>&nbsp; <ol> <li>We need to obtain the storage account key which is our authentication method to a storage account since we need to upload the script and tell the Custom Script Extension to download the script from that location when it gets executed inside the virtual machine. This key later is used for other operations.<br></li> <div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">key=$(az storage account keys list --account-name pmcstorage100 --resource-group Azure-Work-Week-RG --query <span style="color: #006080">'[0].value'</span> --output tsv)</pre><!--CRLF--></div></div><br>
<li>The script needs to be located in a container within the storage account, so we need to check if a container exists<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az storage container show --name scripts --account-key ${key} --account-name pmcstorage100</pre><!--CRLF--></div></div><br>This is the output when the tested exists:<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/clip_image0016.png"><img title="clip_image001" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="clip_image001" src="https://msdnshared.blob.core.windows.net/media/2017/02/clip_image001_thumb3.png" width="934" height="283"></a><br><br><br>If that container does not exists a message “The specified container does not exist” will be displayed:<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/clip_image00151.png"><img title="clip_image001[5]" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="clip_image001[5]" src="https://msdnshared.blob.core.windows.net/media/2017/02/clip_image0015_thumb1.png" width="935" height="58"></a><br><br><br>If you need to test this in a script, follows a bash code snippet that exemplifies one of the ways to achieve it:<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">RESULT=$(az storage container show --name scripts1 --account-key ${key} --account-name pmcstorage100)</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><span style="color: #0000ff">if</span> [ <span style="color: #006080">"$RESULT"</span>  == <span style="color: #006080">""</span> ]</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">then</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    echo <span style="color: #006080">"Container does not exist"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"><span style="color: #0000ff">else</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    echo <span style="color: #006080">"Container exists"</span></pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">fi</pre><!--CRLF--></div></div><br></li>
<li>If the tested container does not exist, the following command line will create it (notice that access is private)<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az storage container create --name <span style="color: #006080">"scripts01"</span> --account-name pmcstorage100 --account-key ${key} --<span style="color: #0000ff">public</span>-access off</pre><!--CRLF--></div></div><br></li>
<li>Next step is to upload the file, notice that we keep reusing $key variable that contains the storage account key that is required<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az storage blob upload --container-name scripts01 --file ./script01.sh --name script01.sh --account-key ${key} --account-name pmcstorage100</pre><!--CRLF--></div></div><br></li>
<li>Another important step is to build the Protected Settings JSON string, which will be used by the Custom Script Extension to download the file or files from the storage account<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">protectedSettings=<span style="color: #006080">'{"storageAccountName":"pmcstorage100","storageAccountKey":"'</span>${key}<span style="color: #006080">'"}'</span></pre><!--CRLF--></div></div><br></li>
<li>Finally, we execute the Custom Script Extension, passing several arguments, one of then is the setting JSON string (which can be built in other ways) where we indicate the URL(s) of the file(s) to download and the one that will be executed, plus the protected settings which contains the storage account key<br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az vm extension set --publisher Microsoft.Azure.Extensions --name CustomScript --version 2.0 --settings <span style="color: #006080">'{"fileUris": ["https://pmcstorage100.blob.core.windows.net/scripts01/script01.sh"], "commandToExecute":"./script01.sh"}'</span> --<span style="color: #0000ff">protected</span>-settings $protectedSettings --vm-name Ubuntu-VM-04 --resource-group linux-test-rg</pre><!--CRLF--></div></div><br>Output<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image240.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb219.png" width="1554" height="446"></a><br><br></li></ol>
<h2>Side note</h2>
<p>&nbsp;</p>
<p>If you’re like me that is just learning how to work with Linux and Bash, here is an example on how to obtain a shared access signature token:</p>
<p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white"># Getting next day date and time <span style="color: #0000ff">in</span> UTC <span style="color: #0000ff">for</span> expiry date of the SAS Token</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">dateVar=$(TZ=UTC date +<span style="color: #006080">"%Y-%m-%dT%H:%MZ"</span> -d <span style="color: #006080">"+1 days"</span>)</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">&nbsp;</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"># Obtaining the SAS token</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sas=$(az storage container generate-sas --name scripts --expiry ${dateVar} --permissions rl --account-name pmcstorage100 --account-key ${key} --output tsv)</pre><!--CRLF--></div></div></p>
<p>This is not directly related to what we did in this post but may be useful one day if you need to generate AdHoc SAS tokens. For more information about these tokens, please refer to <a href="https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1">Using Shared Access Signatures (SAS)</a>.</p>
<p><br><br>That is it for this blog, thanks for stopping by.</p>
<p>&nbsp;</p>
<p>Regards</p>
<p>Paulo</p>]]></content:encoded>
    </item>
    <item>
      <title>Creating an Ubuntu Server 16.10 generalized image on Azure and Deploying a new VM based on this image using Azure CLI 2.0</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/creating-an-ubuntu-server-16-10-specialized-image-on-azure-and-deploying-a-new-vm-based-on-this-image-using-azure-cli-2-0</link>
      <pubDate>Sat, 11 Feb 2017 06:06:25 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=2175</guid>
      <description><![CDATA[Hello Everyone,  This step by step guide will show you how to prepare a generalized image from an...]]></description>
      <content:encoded><![CDATA[<p>Hello Everyone,  <p>This step by step guide will show you how to prepare a generalized image from an Ubuntu 16.10 image from the marketplace, using the newest managed disks that were released on 02/08/2017.  <p>&nbsp; <p>Generalized virtual machines are nothing more than a virtual machine installed from the Azure Marketplace then manually customized and prepared to become an image, if it is based on Windows, that means executing Sysprep as a final step, if it is Linux-based, that means de-provisioning the Linux agent (the Azure agent) as a final step.  <p>&nbsp; <p>In order to follow this guide, please deploy a new Ubuntu 16.10 virtual machine using managed disks instead of unmanaged disks (the old way with storage accounts), through the portal or any other deployment method, for this example, I customized the image by installing XRDP on it, by following the steps outlined in <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-use-remote-desktop?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json">this</a> document.  <p>&nbsp; <p>It is also assumed that you have Azure CLI 2.0 installed in a management computer by following the steps outlined <a href="https://docs.microsoft.com/en-us/cli/azure/install-az-cli2">here</a> to perform the installation, all command line instructions below assumes you are executing them on Linux <strong>bash </strong>only. I’m using <strong>Bash on Ubuntu on Windows 10 </strong>to write this post.  <p>&nbsp; <h2>Creating the generalized image from specialized image</h2> <p>&nbsp; <ol> <li>After you have your master Ubuntu virtual machine configured the way you need, please execute the following commands in order to make it available to be used as an image, this needs to be accomplished inside your virtual machine.<br><br> <div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">sudo waagent -force -deprovision</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">export HISTSIZE=0</pre><!--CRLF--></div></div><br>
<li>From a management computer (where Azure CLI 2.0 is installed) shutdown your specialized virtual machine<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az vm deallocate --resource-group linux-test-rg --name ubuntu-vm-01</pre><!--CRLF--></div></div><br>
<li>Generalize the virtual machine from Azure perspective<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az vm generalize --resource-group linux-test-rg --name Ubuntu-VM-01</pre><!--CRLF--></div></div><br>
<li>Still from the management computer, create an image from the generalized virtual machine, must be in the same resource group as your master virtual machine.<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az image create --resource-group linux-test-rg --name UbuntuMasterImage01 --os-type Linux --source Ubuntu-VM-01 --location eastus</pre><!--CRLF--></div></div><br></li></ol>
<h2>Deploying a new VM from image using managed disks</h2>
<ol>
<li>Obtain the image id<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az image list --query <span style="color: #006080">'[].{name: name, id: id}'</span> </pre><!--CRLF--></div></div>
<p><br>Result<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image219.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb198.png" width="1338" height="144"></a><br><br></p>
<li>Create the VM based on the generalized image <br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az vm create \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --image /subscriptions/&lt;GUID&gt;/resourceGroups/LINUX-TEST-RG/providers/Microsoft.Compute/images/UbuntuMasterImage01 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --admin-username azureuser \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --admin-password Test@2017-123! \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --<span style="color: #0000ff">public</span>-ip-address-dns-name tstubuntudemo01 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --resource-group linux-test-rg \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --location eastus \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --name Ubuntu-VM-03 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --vnet-name vnet \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --subnet subnet01 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --size standard_a1_v2 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --os-type linux \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --authentication-type password \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --os-disk-name Ubuntu-VM-03-osdisk</pre><!--CRLF--></div></div><br></li></ol>
<h2>Adjusting the automatically created Network Security Group</h2>
<p>The customization made to this image was enabling RDP service on Ubuntu, since the <strong>az vm create </strong>command also creates a network security group by default, we need to change it to allow port 3389 which is the one that RDP uses. 
<p>&nbsp; <p>The following steps will guide you through adding a new security rule to the existing NSG: 
<ol>
<li>To obtain the NSG associated with this new virtual machine, first let's get the ID of the network adapter<sub></sub><br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az vm show --resource-group linux-test-rg --name Ubuntu-VM-03 --query <span style="color: #006080">'networkProfile.networkInterfaces[0].id'</span> --output tsv</pre><!--CRLF--></div></div><br>Result<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image220.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb199.png" width="1310" height="48"></a><br><br>
<li>Getting the network security group id<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az network nic show --ids /subscriptions/&lt;GUID&gt;/resourceGroups/linux-test-rg/providers/Microsoft.Network/networkInterfaces/Ubuntu-VM-03VMNic --query <span style="color: #006080">'networkSecurityGroup.id'</span> --output tsv</pre><!--CRLF--></div></div><br>Result<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image221.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb200.png" width="2068" height="44"></a><br><br>
<li>Getting the network security group name<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az network nsg show --ids /subscriptions/&lt;GUID&gt;/resourceGroups/linux-test-rg/providers/Microsoft.Network/networkSecurityGroups/Ubuntu-VM-03NSG --query <span style="color: #006080">'name'</span> --output tsv</pre><!--CRLF--></div></div><br>Result<br><br><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image222.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb201.png" width="1915" height="44"></a><br><br><br>
<li>Adding the network security rule to the existing NSG<br><br>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;max-height: 200px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">az network nsg rule create --resource-group linux-test-rg \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --nsg-name Ubuntu-VM-03NSG \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --name allow-rdp \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --protocol tcp \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --direction inbound \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --priority 300 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --source-address-prefix <span style="color: #006080">"*"</span> \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --source-port-range <span style="color: #006080">"*"</span> \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --destination-address-prefix <span style="color: #006080">"*"</span> \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4">    --destination-port-range 3389 \</pre><!--CRLF--><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">    --access allow</pre><!--CRLF--></div></div><br></li></ol>
<p>Since <strong>XRDP</strong> does not come installed by default, this demonstrates that the new virtual machine came from the specialized image that you just created. 
<p>&nbsp; <p><a href="https://msdnshared.blob.core.windows.net/media/2017/02/image223.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb202.png" width="910" height="764"></a>&nbsp; <p>&nbsp; <p>If you want to expand this scenario and execute a post deployment script on this newly deployed virtual machine, please refer to the post <a href="https://blogs.technet.microsoft.com/paulomarques/2017/02/13/executing-custom-script-extension-using-azure-cli-2-0-on-an-azure-linux-virtual-machine/">Executing Custom Script Extension using Azure CLI 2.0 on an Azure Linux Virtual Machine</a>.
<p>&nbsp; <p>I hope you have enjoyed this short post and have fun creating your own custom images in Azure.</p>
<p>&nbsp;</p>
<p>For more information, please refer to the following documents:</p>
<p>&nbsp; <p><a href="https://docs.microsoft.com/en-us/azure/storage/storage-managed-disks-overview?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json">Azure Managed Disks Overview</a> 
<p><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-quick-create-cli">Create a Linux VM using the Azure CLI 2.0 Preview (az.py)</a> 
<p><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-add-disk">Add a disk to a Linux VM</a> 
<p><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/virtual-machines-linux-snapshot-copy-managed-disk">Create a copy of a VHD stored as an Azure Managed Disk by using Managed Snapshots</a> 
<p><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-upload-vhd">Upload and create a Linux VM from custom disk by using the Azure CLI 2.0 (Preview)</a> 
<p>&nbsp; <p>See you in the next post!</p>
<p>&nbsp;</p>
<p>Paulo</p>]]></content:encoded>
    </item>
    <item>
      <title>Working with Azure Storage Tables from PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/working-with-azure-storage-tables-from-powershell</link>
      <pubDate>Tue, 17 Jan 2017 19:09:55 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=1795</guid>
      <description><![CDATA[Hello, AzureRmStorageTable got a major update, now it is v2.0 and you can find a newer version of...]]></description>
      <content:encoded><![CDATA[Hello, AzureRmStorageTable got a major update, now it is v2.0 and you can find a newer version of this post at my new blog: <a href="https://paulomarquesc.github.io/working-with-azure-storage-tables-from-powershell">https://paulomarquesc.github.io/working-with-azure-storage-tables-from-powershell </a>]]></content:encoded>
    </item>
    <item>
      <title>Using an Azure Resource Manager Template to domain join an existing Windows VM to an Existing Domain</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/using-an-azure-resource-manager-template-to-domain-join-an-existing-windows-vm-to-an-existing-domain</link>
      <pubDate>Thu, 08 Sep 2016 00:38:50 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=1665</guid>
      <description><![CDATA[Hello everyone, &nbsp; In this quick article I show how we can use custom template deployment to...]]></description>
      <content:encoded><![CDATA[<p>Hello everyone,</p> <p>&nbsp;</p> <p>In this quick article I show how we can use custom template deployment to domain join a Windows virtual machine on Azure to an existing domain that the virtual machine has access without the need to logon to the VM.</p> <p>&nbsp;</p> <p>For this template to work we do have some prerequisites that must be met:</p> <ol> <li>Virtual machine to join to a domain must exist beforehand  <li>An Active Directory Forest must exist and a Domain Controller must be accessible by the virtual machine either on-premises or in Azure  <li>The user that is required in this template must have the necessary rights to join computers to an Active Directory Domain  <li>Domain DNS Name must be resolved by the virtual machine</li></ol> <p>&nbsp;</p> <p>Details about some of the parameters that will be presented to us when using this template:</p> <ol> <li>location - current location of the exising virtual machine. E.g. West US.  <li>dominJoinUserName - this parameter must be in domain\username notation, where domain is the NetBios name of the domain. E.g. contoso\myAdmin  <li>ouPath - This is an optional parameter that allows you to join this virtual machine into a specific OU instead of the default Computers container. E.g. OU=MyCorpComputers,DC=Contoso,DC=com</li></ol> <p>&nbsp;</p> <p>This deployment uses the “Deploy to Azure” button of the Azure Quickstart Templates that brings the custom template deployment blade on Azure Portal (<a href="https://portal.azure.com">https://portal.azure.com</a>).</p> <p>&nbsp;</p> <p>In order to domain join a virtual machine, please follow these steps:</p> <p><a href="https://msdnshared.blob.core.windows.net/media/2016/09/image242.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2016/09/image_thumb189.png" width="1028" height="579"></a></p> <p><a href="https://msdnshared.blob.core.windows.net/media/2016/09/image243.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2016/09/image_thumb190.png" width="1028" height="604"></a></p> <p>&nbsp;</p> <ol> <li>Go to the following Azure quick start template (201-vm-domain-join-existing)<br><a href="https://azure.microsoft.com/en-us/documentation/templates/201-vm-domain-join-existing/">https://azure.microsoft.com/en-us/documentation/templates/201-vm-domain-join-existing/</a></li> <li>Click “Deploy to Azure” button</li> <li>Type the virtual machine name in “VM (string)” field on “Parameters blade”</li> <li>Type the location name (e.g. “East US”) in “LOCATION (string)” field</li> <li>Type “domain\username” in “DOMAINJOINUSERNAME (string)”, this is a user that has rights to domain join a computer on Active Directory domain, make sure you match the domain name and username with a valid user in the domain that has rights to perform computer domain join operation.</li> <li>Type the user’s password in “DOMAINJOINUSERPASSWOD (securestring)”</li> <li>Type domain FQDN in “DOMAINFQDN (string)”</li> <li>Click “OK”</li> <li>Back to “Custom deployment” blade, make sure you select “Use existing” at Resource group section and select the resource group where the virtual machines is located in the combo box</li> <li>Click “Review legal terms” on “Purchase” blade</li> <li>Click “Purchase”</li> <li>Click “Create” on “Custom deployment”</li></ol> <p>&nbsp;</p> <p>That’s it for this post, simple and fast, we don’t even need to logon to the computers in order to domain join them <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none;border-left-style: none;border-bottom-style: none;border-right-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/2016/09/wlEmoticon-smile1.png">.</p> <p>&nbsp;</p> <p>Regards</p> <p>&nbsp;</p> <p>Paulo</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure Deployments - Speeding up PowerShell DSC by testing locally before using it in an Azure Resource Manager template or from a PowerShell deployment script</title>
      <link>https://docs.microsoft.com/archive/blogs/paulomarques/azure-deployments-speeding-up-powershell-dsc-by-testing-locally-before-using-it-in-an-azure-resource-manager-template-or-from-a-powershell-deployment-script</link>
      <pubDate>Wed, 06 Jul 2016 18:35:40 GMT</pubDate>
      <dc:creator><![CDATA[Paulo Marques (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/paulomarques/?p=1605</guid>
      <description><![CDATA[&nbsp; Hi Everyone, As you may know, Azure Virtual Machines relies on Virtual Machine Extensions to...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p>Hi Everyone,</p> <p>As you may know, Azure Virtual Machines relies on Virtual Machine Extensions to perform some critical functionality, PowerShell DSC is one of them and it allows us to execute post installation tasks or to keep existing virtual machines in a state that we require them to be. This blog post shows some quick steps to help testing your DSC configuration locally, just before you add it to the Azure Resource Manager template or in a PowerShell deployment script, which saves time and troubleshooting gets a little bit easier. For more information about available extensions, please refer to this <a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-extensions-features/">article</a>.</p> <p>This example shows the steps to execute locally a configuration file that installs an MSI file (Azure PowerShell Module).</p> <p>&nbsp;</p> <ol> <li>In a computer with Powershell 4.0 or greater, copy you DSC configuration file (xyz.PS1) to a folder, e.g. C:\DscTest  <li>Copy any executable or MSI files to the same folder if you’re using it (in this case I’m installing Azure-Powershell.1.5.1.msi, all available module versions can be downloaded from <a href="https://github.com/Azure/azure-powershell/releases">this</a> GitHub link.)  <li>Rename your &lt;xyz&gt;.PS1 file to localhost.ps1  <li>Install any necessary DSC Modules to C:\Program Files\WindowsPowerShell\Modules  <li>Edit the localhost.ps1 file with Powershell ISE and add the configuration name to the end of the file (must be after the closing curly bracket), like the example below<br><a href="https://msdnshared.blob.core.windows.net/media/2016/07/image255.png"><br><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2016/07/image_thumb227.png" width="501" height="219"><br><br></a> <li>Execute this file from ISE  <li>You will notice that a MOF file will be created in a folder with the same name as the configuration file and the MOF file will be named localhost.mof, for example:<br><br><a href="https://msdnshared.blob.core.windows.net/media/2016/07/image256.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2016/07/image_thumb228.png" width="1129" height="177"></a><br><br> <li>To execute the DSC just run this cmdlet<br><br> <div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Start-DscConfiguration -Path C:\DscTest\InstallAzurePowershell -ComputerName localhost -Force -wait -Verbose</pre><!--CRLF--></div></div><br>Note: the –path argument is the path where your localhost.ps1 resides plus the configuration folder name<br><br>
<li>This is the resultant output that you can use to identify issues and make necessary corrections, in this example everything is fine and we are good to implement this configuration to our deployment scripts or Azure Resource Manager template.<br><br><a href="https://msdnshared.blob.core.windows.net/media/2016/07/image257.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2016/07/image_thumb229.png" width="1710" height="561"></a><br><br>
<li>If you identify any issue with your DSC configuration, just fix your PS1 file and execute steps 6 through 8 again to test it, so it get a new MOF file with the updated configuration.</li></ol>
<p>&nbsp;</p>
<p><strong>Troubleshooting</strong></p>
<p>When executing DSC on step 8 you get the following error message</p>
<p><font color="#ff0000">The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the <br>destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig".<br>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ConnectionError: (root/Microsoft/...gurationManager:String) [], CimException<br>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : HRESULT 0x80338012<br>&nbsp;&nbsp;&nbsp; + PSComputerName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : localhost</font></p>
<p>&nbsp;</p>
<p>Enable WinRM with the following cmdlet:</p>
<div id="codeSnippetWrapper" style="font-size: 8pt;overflow: auto;cursor: text;border-top: silver 1px solid;font-family: 'Courier New', courier, monospace;border-right: silver 1px solid;width: 97.5%;border-bottom: silver 1px solid;padding-bottom: 4px;direction: ltr;text-align: left;padding-top: 4px;padding-left: 4px;border-left: silver 1px solid;margin: 20px 0px 10px;line-height: 12pt;padding-right: 4px;background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;line-height: 12pt;padding-right: 0px;background-color: #f4f4f4"><pre style="border-top-style: none;font-size: 8pt;overflow: visible;border-left-style: none;font-family: 'Courier New', courier, monospace;width: 100%;border-bottom-style: none;color: black;padding-bottom: 0px;direction: ltr;text-align: left;padding-top: 0px;border-right-style: none;padding-left: 0px;margin: 0em;line-height: 12pt;padding-right: 0px;background-color: white">Enable-PSRemoting</pre><!--CRLF--></div></div>
<p>&nbsp;</p>
<p>That’s it for this quick article.</p>]]></content:encoded>
    </item>
  </channel>
</rss>