Category Archives: Virtual Machines

Automate finding a unique Azure storage account name (ARM)

When building ARM-based virtual machines in Azure with PowerShell, one important step involves creating a storage account. And because the storage account name must be unique within Azure, you first need to find an unused name. To accomplish this we can use the Get-AzureRmStorageAccountNameAvailability cmdlet.

This is great, but I may have to manually try several names before I stumble upon one that is unique. The last time I was working through this process I thought it would be helpful to let PowerShell find a unique name for me, retrying as needed until a usable name was determined. I looked around and to my surprise I could not find something that was already written to accomplish this. Continue reading

Azure Dev/Test Labs


There is almost universal agreement that Development and Test environments, or “DevTest” as it’s known, should be moved to the Cloud.

DevTest is probably the only workload that doesn’t have corporate issues slowing down its migration.  Aside from the security and backup of a company’s source code, there’s no reason for IT managers to balk nor are there regulatory or compliance rules that are stopping the march of DevTest to the Cloud.

That being said teams still need to get up and running with a brand new environment. They will have to build VMs, Virtual Networks etc in order to have a functional network.  This can stretch the abilities of the team as it requires quite a bit of experience working with infrastructure.

To solve these problems and let developers and testers do what they do best Microsoft has developed a turnkey solution for DevTest in the Cloud:  Azure DevTest Labs.

Azure DevTest Labs was designed with one goal is mind to enable development teams to leverage the strength and flexibility of the cloud without the complication of having to build from scratch all of the infrastructure to make that possible.

In this post I’m going to help you get up and running with Azure Dev/Test Lab.  Currently it is in preview, but you should be able to find information about it on their site here.

In my next post I will feature how to build a Linux VM with Docker in your new Lab. 





Create a DevTest Lab in Azure

Much like anything in Azure creating a DevTest Lab is fast and easy.  Azure takes care of the hard parts for development teams allowing them to get up in running almost immediately.

The DevTest Labs can be found in the Azure Marketplace and will require only a few inputs to consider prior to creation.  The first will be creating or choosing an Azure subscription that will be used to create the Lab and the second being the location.


Step by Step – Building an Azure DevTest Lab

In order to create the DevTest Lab use Microsoft or Organization account to login to the Azure Preview portal to start.

Open a browser and navigate to

Enter the account associated with a Microsoft Azure subscription.


 If the account is associated with an organization account and a Microsoft account there could be a prompt to choose which one to authenticate with for Microsoft Azure.


 After logging into the Azure Portal next create a New DevTest Lab in Azure

Click the +NEW button in the portal.


Click See all.


Click Everything and then type DevTest Labs and press enter.


 The Search will reveal the DevTest Labs link for you to click.


 This will bring up the DevTest Labs Page.  Click Create.


Then you will see the Create a DevTest Lab Blade.  Name the Lab: in the example the name ContosoDevTestLab was used.


Next Choose the Correct Subscription you wish to use for this DevTest Lab.  Please note that owners of the subscription will have full access to everything in the Lab.

Chose location for the DevTest Lab assign a Location for this lab in this case I have chosen East US. 

Click Auto Shutdown and ensure that the defaults are assigned to Enable On and Scheduled Shutdown 19:00.


Then click Create to start the process of building the DevTest Lab.


After completing these steps Azure will take care of the hard work of creating all of the resources required for the DevTest Labs.

Azure Dev/Test Labs has to be one of the coolest products I’ve seen from the Azure team to date!  It really is a fully functional environment right out of the box.

Make sure you look for the Next post where we get some Open Source Action happening in this lab!

Hope you enjoyed this post – @deltadan

Using Chef on Azure


Chef is a truly great piece of software and those that are working on DevOps most likely have run across it.  Along with software like Chef Dev/Test teams are going all in with the Cloud for their work using public cloud offerings such as Microsoft Azure.  My goal here is to help you get going quickly by combining your skills in Chef and using the Azure Marketplace server image.

In this post I will provide detailed step-by-step instructions that will guide you through the installation of Chef Server on Microsoft Azure assuming an Azure subscription has already been created. The scenarios will cover the setup Chef Server 12, BYOL (Bring You Own License), install cookbooks and bootstrapping a Windows VM (virtual machine) node with an IIS Web Server installation Cookbook.





Microsoft Azure Subscription

Local workstation instructions are for a local Windows OS or you choose or a virtual machine configured with:

  • Text Editor – Most popular ones are Atom, Sublime Text, and Notepad++ for writing Chef code amongst others.
  • Free Telnet/SSH Client for Windows – Here I will use PuTTY

Note: This lab guide is written with detailed instructions how using Windows as the client.  Some actions will be different from other OS options.

As an option you can use your Microsoft Azure subscription to create a new virtual machine using the Windows Server 2012 R2 Datacenter image as a workstation for this lab.

Exercise 1: Environment Setup

In this exercise you will setup your Chef Server environment for use throughout the rest of the exercises. This will involve downloading some tools and sample code to your local workstation that will be need to complete all the steps.

Task 1: Creating the Chef Server 12, BYOL

Go to the Azure Preview portal (, after entering your credentials the following screen will be displayed.


Azure portal

To create the Chef Server, you need to get application from the Marketplace.

First click on +New, then click on Marketplace.


Navigating to the Marketplace

In the search box type in “chef” and hit enter.  Click Chef Server 12, BYOL.


Locating Chef Server 12 in the Marketplace

After clicking on Chef Server 12, BYOL, leave the default deployment model as Classic and click on Create.


Chef Server VM Creation

In the creation process of the Chef Server VM, enter Host Name, User name, and Password.

For the purpose of this exercise, we used:

  • Host Name = chefsrv
  • User name = demouser
  • Password   = demo@pass1

Click Resource Group on the Create VM blade

Click Create a new resource group on the Resource group blade

Use the name “AzureChefRG” on the Create resource group blade

Click on OK button which takes you back to Create VM blade


Creating Resource Group

*NOTE:  We left the default A4 Standard Pricing Tier just for the purpose of this exercise. This Pricing Tier is for Azure Infrastructure Costs, not the cost of Chef Server 12, BYOL application. But if you plan to deploy Chef Server in a development or production environment, then you should follow Chef’s System Requirements as if it were On-premises requirements.

At the Create VM blade click on Optional Configuration.

Click on Network.

Click Virtual Network, on the Virtual Network blade click on Create new virtual network.

On the Create a virtual network blade type AzureVNET for Name and click OK button, click OK on Network blade, click OK on Optional config blade and click on Create button on the Create VM blade.


Creating Virtual Network

One the next screen you’ll notice, that the cost to use Chef Server 12, BYOL is $0.00 USD, so click on the Purchase button to complete the installation of the VM.

Note: When you click on the Purchase button, it will take you back to the Azure Preview portal where you will the VM for Chef Server 12 being created.




















Buy blade for Chef Server, BYOL VM


Azure Portal creating Chef Server, BYOL VM

Once completed, it will display all the VM Settings and it should be up running automatically.


Screen details when Chef Server, BYOL VM completes

Task 2: Completing Chef Server Installation

When confirming that the Chef Server VM was successfully created and running, you will need to use a SSH and telnet client tool of your preference to establish a connection to the Chef Server.  You will need to connect use the external DNS name for the Chef Server.

For this lab demo we’ll use PuTTY, copy and paste the Host Name details and create a friendly name to save it under Saved Sessions.

To find the external URL of the Cloud Service where your Chef Server resides use the following steps:  Browse to

Click Resource Groups and then AzureChefRG


Once the Resource Group Loads click the Cloud Service icon and verify you see the Chef Server VM.  Then locate the Site URL that you will use to  connect to the Chef Server from the internet for the rest of this lab.  In our example here the Site URL is  


Find the SITEURL for the Cloud Service












PuTTY Configuration

Click the Yes button to get past the PuTTY Security Alert dialog box.









PuTTY Security Alert dialog box

Once you enter the User name and Password credential used during the creation of your VM, you will need update the hostname property of the Chef Server to the Site URL.  Enter the following command.


NOTE:  Make sure to use the site URL for the server name.

Once the Chef Server has been reconfigured then enter the setup syntax to complete the installation of Chef Server 12, BYOL.  (Replace the hostname with the SITE URL name that we used to connect to the puTTY session.



Command used to complete Chef Server setup

You will then be prompted to for your First Name, Last Name, Email, and Organization Name.  Complete these using your information, but for the organization make sure to type azurechef (no spaces and no capitals letters).






NOTE: You must use azurechef or the rest of this lab will not work properly.

Type Yes to accept the Chef License Agreement





Once Chef Server has finished installing, you get the following message.


Chef Server completion and important details

Exercise 2: Chef Server Configuration

Task 1: Setting up Organization details

Open a browser on your local workstation and go to the Chef Manage console using the SITE URL name of your Chef Server VM. Click on Continue to this website (not recommended) link.


Chef Manage console certificate warning screen

Enter credentials and click on the Sign In button.


Chef Server Sign In screen

Once logged into the Chef Management Portal click Administration and then click gear icon under Actions.  When the menus opens click Starter Kit.



Starter Kit dialog boxes

Now click on Download Starter Kit button and click on Proceed button.


Starter Kit dialog boxes

Note: This will download the Starter Kit to the Downloads folder on the local machine.

Browse to the “Downloads” folder on the machine being used for the lab.  Right click on the file and click on Extract All




In the Select Destination and Extract Files box point the zip file to the Root of the C:\users\<user-name> directory replacing the <user-name> with your user profile name that you are using for this lab.

Note:  This zip file will create a folder called chef-repo folder that will be extracted to your local workstation signed on Users folder











Users folder on workstation where chef-repo folder resides

Next you will install the CHEF client on the local machine.  Open a new browser window and go to  Choose the correct client based on the OS you are using.

Note:  The following install steps are provided for Windows.

Click Windows and then Downloads to get the Chef Client bits.



Double click on the chef-client MSI package file that was saved to your Downloads folder.

Click Next on the Chef Client Setup Wizard and accept the terms and click Next on the following screen.

Choose all of the available packages to install to your hard drive on the Customer Setup Screen of the Chef Client Setup Wizard.











Open Explorer in Windows and find the folder c:\users\<user-name>\chef-repo\.chef then review the files that were created which should include:

  • <cheforganizationname>-validator.pem
  • <chefuser>.pem
  • knife.rb

Open the knife.rb file and update the the chef_server_url to the SITEURL of the CHEF server.  Also add a new line with the following:

ssl_verify_mode :verify_none

The knife.rb file should look the following:


Browse to the following link: to download the file. Right click the file and extract the client.rb file into the c:\users\<user-name>\chef-repo\.chef folder.

28chef The folder will look like this once you have unzipped the file to the correct directory.


Files in .chef folder

15. Next, open the client.rb file with a text editor and change the URL for the Chef Server to the Site URL the where the Chef Server Resides. Ensure you update the [SITEURL] place holder.


Note:  If you are unable to download the file that contains the client.rb file you can create it using the text found in the box above making sure to change the name of the chef_server_url to the SITEURL of your Chef Server.  This should be placed into the c:\user\userid\chef-repo\.chef folder.

To find the external SITE URL of the Cloud Service where your Chef Server resides use the following steps:

Browse to

Click Resource Groups and then AzureChefRG


Once the Resource Group Loads click each Cloud Service until you find the Cloud Service that shows your Chef Server VM.  Then locate the Site URL that you will use to update the client.rb file.


Next confirm connectivity is working from local workstation SSL connections to the Chef Server using the knife tool. Open a PowerShell console window using Run as Administrator.  Execute the following steps commands:







Confirming SSL validity from PowerShell CLI

Troubleshooting the knife command

All knife commands needs to run from the chef-repo folder of the user’s home folder on the local workstation (C:\users\<user_name>\chef-repo\), so make sure you are running from that directory.

Also verify that the client.rb file and knife.rb file point to the external name of the cloud service that contains your Chef Server.

If you experience issues with the knife tool such as the following error then you need to ensure that you have started the PowerShell window by using the Run as Administrator or you may have to restart your machine to allow the environment variables to be set.



Exercise 3: Download and Install Cookbooks

Chef cookbooks can be manually downloaded from Chef Supermarket found at  This is repository of cookbooks is created and maintained by Chef’s Community.

In this exercise you will download and extract Cookbooks using the Chef Client Tools.

Task 1: Manual Download and Extraction of Cookbooks

Open a PowerShell console window using Run as Administrator.  The following steps must be executed in this window from the directory: C:\users\<user_name>\chef-repo

Download, Extract and then delete the IIS cookbook for Windows into the C:\users\<user_name>\chef-repo\cookbooks using the following commands.







Downloading cookbooks in Administrator PowerShell from Chef Supermarket

Task 2: Upload the Cookbook to Chef Server

From an Administrator PowerShell window, you will upload the IIS cookbook for Windows to the Chef Server using the following steps:

Note: Confirm you are in the chef-repo folder before beginning.




Uploading cookbooks to Chef Server

Open a browser to your Chef Server at http://[SITE URL] which will connect you to the Chef Manage console.  Once logged in click the Policy button to and confirm the cookbook has been uploaded successfully.


Chef Manage console to confirm cookbook uploaded

Exercise 4: Bootstrapping Chef Node in Azure

Now that Chef Server 12, BYOL is fully configured on Microsoft Azure, use the following steps to bootstrap a node using the Chef Client plugin extensions. The same steps are used to bootstrap either a Linux or Windows client node.

Task 1: Bootstrap Windows Client Node

From the Azure Preview portal click on New, Click on Compute, and then Click on Windows Server 2012 R2 Datacenter in the Marketplace.


Bootstrap Windows Client node

On the Windows Server 2012 R2 Datacenter blade, leave the default deployment model as Classic, click on Create button.




On the Create VM blade, type the Host Name, User name, and Password.  In this example the Hostname was chefwin, demouser and demo@pass1 respectively.

Click on Resource Group, select AzureChefRG.


Bootstrap Windows Client node

Back on the Create VM blade, click on Optional Configuration

Click OK

Click on Endpoints,

Add the following ports for HTTP (80) and HTTPS (443)


Opening Endpoint ports

On the Optional Configuration blade, select the following.

Click on Extensions

On the Extension blade, click on +Add extension,

On the New resource blade, click Chef Client.


Adding Windows Chef Extension

Click Create on the Windows Chef blade.

Click on the empty box or blue folder icon under the Validate Key (Required) then select the azurechef-validator.pem from the c:\users\<user-name>\chef-repo\.chef folder.

Click on the empty box or blue folder icon under the Client RB (Required) then select the client.rb from the c:\users\<user-name>\chef-repo\.chef folder.

In the Run List box, type learn_chef_iis which is one of the cookbooks uploaded in earlier steps.


Complete adding Windows Chef Extension

Click OK button on the Add Extension pane,

Click OK button on the Extensions pane

Click OK button on the Optional Config pane.

Click Create button on the Create VM pane.

Once the Windows Chef node has been successfully deployed, you will see it in Chef Manage console on the Nodes tab.

If you click on the Reports tab, then click on the Run History on the left column, you will notice that the cookbook learn_chef_iis from the Run List completed with a success status.


You will also be able to verify the installation by navigating to the website using the DNS name in a browser and see the default hello world webpage install by the learn_chef_iis cookbook:

Browse to

Click Resource Groups and then AzureChefRG

Next click the name chefwin VM and locate the DNS Name



Browse to http://< to see the application running.  In our case we browse to





Way to go!

Well that’s it you have used Chef to Configure a VM in Azure!

Resources for passing Azure Exam 70-533 from Opsgility

If you are just now getting started with Azure Certification it is useful to have a roadmap on how to learn the technology in order to pass the certification.

Our team of industry recognized Azure experts have built a lot of Azure training over the years, and in this case we’ve literally written the book on how to pass the exam.

In this post, I want to share some of our online courses that map directly to the objectives for the exam. Each of these courses will cover the objective topic (and then some), and also provides in-depth hands-on lab guides that you can practice in your own Azure subscription to get the hands-on practical experience to really learn the skills being taught.

Objective Online Course
Implement Websites
Implement Virtual Machines
Implement Cloud Services
Implement Storage
Implement an Azure Active Directory
Implement Virtual Networks

If you haven’t tried us out yet, you can start learning Azure with a free 7-day trial here, you can cancel at any time.

Setting Static IP addresses in a Microsoft Azure Virtual Network with PowerShell

I have finally had a chance to update the Windows Microsoft Azure PowerShell Guide.

The page is about the new functionality of assigning a static IP address to a virtual machine deployed in a Virtual Network.

Setting Static IP Address on Microsoft Azure Virtual Machine

Copy a Windows Azure Virtual Machine Between Subscriptions

While working on some recent training content focused on development and test I thought a great scenario would be to have a script that can copy a single Windows Azure Virtual Machine from a source subscription to a destination subscription. This script will also copy a virtual machine between data center locations. There are tons of scenarios where this can be useful for dev/test so I will not enumerate them all here :)

Using the Script

This script uses the Windows Azure PowerShell cmdlets so they must be installed prior to use. Also, both the source and destination subscription must be configured for PowerShell access prior to use. See the following for information on getting started with the Windows Azure PowerShell Cmdlets.

  # Copy a virtual machine to a different subscription (no VNET)
  .\vmcopy.ps1 -SourceSubscription "source subscription" ` 
             -DestinationSubscription "destination subscription" ` 
             -VirtualMachineName "existingvmname" ` 
             -SourceServiceName "sourcecloudservice" ` 
             -DestinationServiceName "destinationcloudservice" ` 
             -DestinationStorageAccount "destinationstorageaccount" ` 
             -Location "West US" 
  # Copy a virtual machine to a different subscription and specify an existing virtual network and subnet. 
  .\vmcopy.ps1 -SourceSubscription "source subscription" ` 
               -DestinationSubscription "destination subscription" ` 
               -VirtualMachineName "existingvmname" ` 
               -SourceServiceName "sourcecloudservice" ` 
               -DestinationServiceName "destinationcloudservice" ` 
               -DestinationStorageAccount "destinationstorageaccount" ` 
               -VNETName "DestinationVNET" ` 
               -SubnetName "DestinationSubnet"

The script can be downloaded from within the TechNet Script Center: Virtual Machine Copy Script.

If you find any issues with the script or would just like to make it better we have it posted in GitHub as well: GitHub – Virtual Machine Copy Script and are interested in pull requests for improvements.

Of course, if you would like deeper training on Windows Azure to learn how to write scripts like this yourself we would be happy to help :)

Windows Azure – Disk Cleanup with Virtual Machines

In the latest Windows Azure Portal and PowerShell updates Microsoft has added some great functionality to manage disk cleanup with virtual machines.

Prior to these updates managing the cleanup of virtual machine disks was fairly painful. You either had to delete each disk one by one from the portal or use PowerShell code with some complex filtering and polling mechanism to remove them.

Deleting an Individual Virtual Machine and Disks from the Portal

In the portal when you select an individual virtual machine and on the bottom of the screen select Delete you are given two new options.

  • Keep the attached disks (doesn’t delete any disks)
  • Delete the attached disks (deletes all attached disks OS and Data)

delete vm windows azure portal

Deleting an Individual Virtual Machine and Disks from PowerShell

The equivelant functionality for the “Delete the attached disks” option from PowerShell is to append the -DeleteVHD parameter onto a call to Remove-AzureVM.

  Remove-AzureVM -ServiceName $serviceName -Name $vmName -DeleteVHD

Deleting all Virtual Machines and Disks in a Cloud Service from the Portal

If you need to remove all of the virtual machines and underlying disks in a specific cloud service you are covered too.
In the portal simply click CLOUD SERVICES on the left menu and find the cloud service hosting your virtual machines.

In the portal select a cloud service that contains virtual machines and on the bottom of the screen select Delete you are given three options.

  • Delete the cloud service and its deployments (deletes cloud service, all of the virtual machines (in the cloud service) and all disks attached to the virtual machines)
  • Delete all virtual machines (deletes all of the virtual machines (in the cloud service) but retains the disks)
  • Delete all virtual machines and attached disks (deletes all of the virtual machines in the cloud service and all of the disks but does not delete the cloud service)

portal delete cloud service and disks

To accomplish each of the tasks from PowerShell is straightforward.

Delete the cloud service and its deployments – equivalent PowerShell Code

Remove-AzureService -ServiceName $serviceName -DeleteAll

Delete all virtual machines (but not the cloud service or disks)

Remove-AzureDeployment -ServiceName $serviceName -Slot Production

Delete all virtual machines and attached disks (but not the cloud service)

Remove-AzureDeployment -ServiceName $serviceName -Slot Production -DeleteVHD

PowerShell for the rest
Finally, if you need to clean up disks that are no longer attached to virtual machines the PowerShell cmdlets come to the rescue.

Get-AzureDisk | where { $_.AttachedTo -eq $null } | select diskname, medialink

To delete an individual disk.

Remove-AzureDisk "disk name" -DeleteVHD

If you want to delete all of the disks that are not attached (be careful of this one – ensure you know what you are deleting before executing!).

Get-AzureDisk | where { $_.AttachedTo -eq $null } | Remove-AzureDisk -DeleteVHD

The ease of use of Windows Azure is getting better every day. What used to be a complex task (deleting disks after VM deletion) is now simplified without taking away the power that is available to the command line user. The Windows Azure team(s) are doing an amazingly good job of tackling tasks that were once difficult and making them much more manageable.

Bootstrapping a PowerShell DSC Pull Server and Client

Script Sample

This post describes a set of PowerShell scripts that can automatically provision a PowerShell DSC Pull Server and Client using Windows Azure Virtual Machines.

The scripts can be downloaded from here: Bootstrap PowerShell DSC in Windows Azure.
If you find bugs feel free to fork, fix and submit a pull request.

Before continuing

If you are brand new to Windows PowerShell DSC I recommend a slight detour from this post to watch the TechEd 2013 Introductory Session. Once you watch the TechEd session you should then read this blog post on how to configure a DSC Pull Server: Push and Pull Configuration Modes.

Ok, I feel better. You now should not only know what a DSC pull server is but you will likely appreciate the script more because it takes all of the complexity of putting together a DSC Pull Server and Client and wraps it up in two simple scripts. Not that I am saying you shouldn’t know how to do this on your own but if you need to quickly spin up an environment for a demo, testing or whatever it is nice not to have to reconstruct an environment from scratch each time.


The scripts have a dependency on the Windows Azure PowerShell Cmdlets. So read this article to configure them if you haven’t already.

Creating a Pull Server

$subscription = "opsgilitytraining"
$serviceName = "mypullsvc"
$vmNamePull = "pullsrv"
$vmSize = "Small" 
$Location = "West US"
.\create-pull-srv.ps1 -SubscriptionName $subscription `
   -ServiceName $serviceName -Name $vmNamePull -Size $vmSize `
    -Location $location

What the script does:

  • Provisions a Server 2012 R2 VM in the “mypullsvc” cloud service in the West US data center. The VM name is “pullsrv”.
  • Creates a self-signed SSL certificate that is used to connect to the pull server and for encrypting stored passwords and automatically deploys it to the new virtual machine.
  • Uploads and executes the DSC Pull Server resource provider written by the PowerShell team.
  • Uploads a file that contains a helper function called SetConfiguration. This helper executes your DSC configuration file, generates a deterministic GUID based on the configuration name (so you don’t have to have a table of GUIDs handy) and creates the .mof files + checksums. Basically, all of the nasty work to create a DSC configuration in a pull server environment.
  • Once the server is provisioned login to the Pull Server via RDP.

    # if you don't want to leave your PowerShell session
    Get-AzureRemoteDesktopFile -ServiceName $serviceName -Name $vmNamePull -Launch

    Open the example configuration file C:\DSCScript\WebServer.ps1 in PowerShell_ISE and Hit F5. This will create your first bare bones configuration named WebServer on the pull server.

    Creating a Pull Client

    Note: The scripts have been designed to only allow deploying the client into the same cloud service as the pull server

    $vmNameClient = "pullclient"
    $configName = "WebServer"
    .\create-pull-client.ps1 -SubscriptionName $subscription `
       -ServiceName $serviceName -Name $vmNameClient -Size $vmSize `
       -CertificatePath .\PSDSCPullServerCert.pfx -PullServer $vmNamePull `
       -ConfigurationName $configName

    What the script does:

    • Provisions a Server 2012 R2 VM in the “mypullsvc” cloud service in the West US data center. The VM name is “pullclient”.
    • Deploys the previously created certificate PSDSCPullServerCert.pfx and also adds this cert to the LocalMachine\Root (trusted root authority) so it can be used with SSL.
    • Configures the client to point to the pull server using the DSC configuration name specified in -Configuration. The pull server has an example WebServer configuration that simply installs IIS that can be specified here.

    Testing the configuration

    Once the server is provisioned login to the Pull Client via RDP.

    # if you don't want to leave your PowerShell session
    Get-AzureRemoteDesktopFile -ServiceName $serviceName -Name $vmNameClient -Launch

    After patiently waiting 30+ minutes the configuration should be downloaded to your client VM. To validate this launch PowerShell and run:


    If all goes well you should see the following:
    PowerShell DSC

    Forcing DSC Configuration
    As of now there is no DSC cmdlet to force the client to pull a configuration. However, DSC is setup using scheduled tasks so you can force the task to run which will have your client check to see if it is up to date and if not apply the configuration.

    Get-ScheduledTask "Consistency" | Start-ScheduledTask


    There you have it. Two simple scripts that can quickly get you up and running with PowerShell DSC.
    If you are interested in learning more about PowerShell DSC or Windows Azure in general for yourself or your organization we provide on-site or open enrollment Windows Azure and PowerShell Training.

Updating SQL Server AlwaysOn IP in Windows Azure

When deploying SQL Server AlwaysOn Availability Groups into Windows Azure with the listener enabled the configuration can break if the public IP address of the cloud service the SQL VMs are deployed into changes.

Cloud Service IP

The IP address of the cloud service hosting your SQL VMs can change if you shut down all the SQL Nodes at the same time using the Portal or PowerShell (and not using the -StayProvisioned flag in Stop-AzureVM). If this happens you will no longer be able to connect to the SQL Server through the listener until it is updated with the new IP of the cloud service when the VMs are restarted. This is a very common scenario with Dev/Test and proof of concepts because you may spin up the SQL servers but need to shut them down when not in use.

To make this easier from a DevOps perspective I have written a PowerShell script and published it to the TechNet Script Center that will update the listener IP address to the current IP Address of the cloud service.

Using the Script

The script does use the Windows Azure PowerShell cmdlets for automation so ensure they are setup and configured first.

Install and configure the Windows Azure PowerShell Cmdlets

Next you will need to enable CredSSP authentication since the script automates the other SQL nodes from the primary.

Enable CredSSP on your client machine for delegation before executing the script.

enable-wsmancredssp -role client -delegatecomputer “*”

This command will fail if your client machine is connected to any networks defined as “Public network” in “Network and Sharing Center.” of if PowerShell remoting has not previously been enabled with Enable-PSRemoting.

Run GPEdit.msc You must also enable delegating of fresh credentials using group policy editor on your client machine. Computer Configuration -> Administrative Templates -> System -> Credentials Delegation and then change the state of “Allow Delegating Fresh Credentials with NTLM-only server authentication” to “Enabled.” Its default state will say, “Not configured.”

Enable CredSSP on the primary SQL Server Node

enable-wsmancredssp -role client -delegatecomputer "*"

Install the WinRM certificate for the primary SQL Node

Download the script from the TechNet Script center:

Install WinRM Certificate for Windows Azure VMs

Example that installs the WinRM certificate (this allows secure remote PowerShell to the SQL Server VM)

$subName = "my subscription"
$cloudService = "MySQLAOCloudService"
$vmName = "SQLAO-01"
.\InstallWinRMCertAzureVM.ps1 -SubscriptionName $subName -ServiceName $cloudService -Name $vmName

Update the SQL Always On Listener IP

Download the SQL AlwaysOn IP Update script from the TechNet script center:

Update SQL Server Always On Listener IP Address in Windows Azure

Example of using the script to update a SQL AlwaysOn Availability Group.
The UpdateSQLAlwaysOnVIP.ps1 script will get the current IP address of the cloud service. Log in to the first SQL Node (SQLAO-01), update the IP cluster resource IP address and restart the SQL Nodes.

$avgroup = "SQLAG"
$nodes = "SQLAO-01", "SQLAO-02", "SQLAO-03"
.\UpdateSQLAlwaysOnVIP.ps1 -SubscriptionName $subName -ServiceName $cloudService -AvailabilityGroupName $avgroup -Nodes $nodes

SQL Always On References

Try out Server 2012 R2 RTM in Windows Azure

It was announced today that MSDN/TechNet subscribers can now download Server 2012 R2 and Windows 8.1 RTM.. Fantastic news if you have access to MSDN or TechNet :)

As of 9/9/2013 Server 2012 R2 RTM is not available as an image in Windows Azure. You can either wait for them to add it OR if you have access to the RTM bits you can add it yourself.

Step 1: Login to MSDN or TechNet and download the ISO

Step 2: Download the Convert-WindowsImage.ps1 PowerShell script to convert the ISO from MSDN/TechNet into a bootable VHD.

Step 3: Mount the ISO to your machine (double click it in Win8)

Step 4: Run the following to create the VHD:

 .\Convert-WindowsImage.ps1 -SourcePath "E:\sources\install.wim" -Edition ServerStandard -VHDPath D:\Server2012R2.VHD

Step 5: Use the Windows Azure PowerShell Cmdlets to Upload the VHD

Add-AzureVHD -Destination "https://<yourstorage>" -LocalFilePath "D:\Server2012R2.VHD" -NumberOfUploaderThreads 5

Step 6: Register as an image.

Add-AzureVMImage -ImageName "Server2012R2" -OS Windows  -MediaLocation "https://<yourstorage>"

Now, back in the portal or from PowerShell you can provision a new Server 2012 R2 VM from your very own custom image. My bet is the Windows Azure team will have an RTM Image of Server 2012 R2 in the Image Gallery and avoid the need for these steps but until then you can try out 2012 R2 in the cloud :)