The high availability afforded by Windows Server 2012 Failover Clustering is a key ingredient for managing and maintaining business critical applications.  To gain familiarity with What’s New in Failover Clustering in Windows Server 2012, this article will step through an overview of new capabilities along with a Step-by-Step Guide on building a simulated Failover Cluster study lab in the Cloud on the Windows Azure platform.

NOTE: Failover Clustering is not currently supported on the Windows Azure cloud platform for PoC, Pilot and Production workloads.  The intent of this Step-by-Step guide is to provide an easy option for evaluating and studying the configuration and management of Failover Clustering in a simulated cloud-based lab environment to prepare for later on-premise installation and also prepare for the MCSA on Windows Server 2012 certification exams.

What’s New in Failover Clustering in Windows Server 2012?

Watch this video to learn the new capabilities of Failover Clustering in Windows Server 2012, including continuous availability, scale-out file server, cluster aware updating and expanded support for Cluster Shared Volumes (CSVs).  These clustering capabilities are supported on Windows Server 2012 Standard Edition, Windows Server 2012 Datacenter Edition and the FREE Hyper-V Server 2012 ( for Hyper-V Host and VM clustering ).

Download this presentation for offline viewing.

Read: What’s New in Failover Clustering in Windows Server 2012

Lab Scenario

In this Step-by-Step Guide, you will work through the process of building a Windows Server 2012 Failover Cluster study lab on the Windows Azure cloud platform.  This failover cluster will leverage the work completed in the prior Step-by-Step Guides listed in the Prerequisites below to integrate a simulated cluster with an existing Active Directory and iSCSI storage infrastructure.

image
Lab Scenario: Windows Server 2012 Failover Cluster

This lab scenario will also serve as the basis for future Step-by-Step Guides, where we will be adding additional member servers and on-premise connectivity to this same Virtual Network in the Windows Azure cloud.

Prerequisites

The following is required to complete this Step-by-Step Guide:

Let’s Get Started!

In this Step-by-Step Guide, you will complete the following exercises to configure a Windows Server 2012 Failover Cluster in a cloud-based study lab environment:

  • Deploy Cluster Node VMs on Windows Azure
  • Configure Cluster Node VMs for High Availability on Windows Azure
  • Prepare VMs and Install Failover Clustering Feature
  • Create a New Failover Cluster
  • Build a Continuously Available Clustered File Server Role
  • Export / Import Lab Virtual Machines

Estimated Time to Complete: 120 minutes

Exercise 1: Deploy Cluster Node VMs on Windows Azure

In this exercise, you will provision two new Windows Azure VMs running Windows Server 2012 on a common Windows Azure Cloud Service and Virtual Network.

  1. Login to the Windows Azure Management Portal.
     
    1. Sign in at the Windows Azure Management Portal with the logon credentials used when you signed up for your Free 90-Day Windows Azure Trial.
       
    2. Select Virtual Machines located on the side navigation panel on the Windows Azure Management Portal page.
       
  2. Deploy a VM running Windows Server 2012 for Cluster Node 1
     
    1. Click the +NEW button located on the bottom navigation bar and select Compute | Virtual Machines | From Gallery.
       
    2. In the Virtual Machine Operating System Selection list, select Windows Server 2012 and click the Next button.
       
    3. On the Virtual Machine Configuration page, complete the fields as follows:
       
      - Virtual Machine Name: XXXlabfs01
       
      - New Password and Confirm Password fields: Choose and confirm a new local Administrator password.
       
      - Size: Small (1 core, 1.75GB Memory)
       
      Click the Next button to continue.
       
      Note: It is suggested to use secure passwords for Administrator users and service accounts, as Windows Azure virtual machines could be accessible from the Internet knowing just their DNS.  You can also read this document on the Microsoft Security website that will help you select a secure password: http://www.microsoft.com/security/online-privacy/passwords-create.aspx.
       
    4. On the Virtual Machine Mode page, complete the fields as follows:
       
      - Standalone Virtual Machine: Selected
       
      - DNS Name: XXXlabfs.cloudapp.net
       
      - Storage Account: Select the Storage Account defined in the Getting Started steps from the Prerequisites section above.
       
      - Region/Affinity Group/Virtual Network: Select XXXlabnet01 – the Virtual Network defined in prior Step-by-Step Guides listed in the Prerequisites section above.
       
      - Virtual Network Subnets: Select Subnet-1 (10.0.0.0/23)
       
      Click the Next button to continue.
       
    5. On the Virtual Machine Options page, click the Checkmark button to begin provisioning the new virtual machine.
       
      As the new virtual machine is being provisioned, you will see the Status column on the Virtual Machines page of the Windows Azure Management Portal cycle through several values including Stopped, Starting (Provisioning), Running (Provisioning) and Running. When provisioning for this new Virtual Machine is completed, the Status column will display a value of Running and you may continue with the next step in this guide.
       
    6. After the new virtual machine has finished provisioning, click on the name ( XXXlabfs01 ) of the new Virtual Machine displayed on the Virtual Machines page of the Windows Azure Management Portal to open the Virtual Machine Dashboard page for XXXlabfs01.
       
    7. On the Virtual Machine Dashboard page for XXXlabfs01, make note of the Internal IP Address displayed on this page.  This IP address should be listed as 10.0.0.7
       
      If a different internal IP address is displayed, the virtual network and/or virtual machine configuration was not completed correctly.  In this case, click the DELETE button located on the bottom toolbar of the virtual machine details page for XXXlabfs01, and go back to the beginning of Exercise 1 to confirm that all steps were completed correctly. 
       
  3. Deploy a VM running Windows Server 2012 for Cluster Node 2.
     
    1. Click the +NEW button located on the bottom navigation bar and select Compute | Virtual Machines | From Gallery.
       
    2. In the Virtual Machine Operating System Selection list, select Windows Server 2012 and click the Next button.
       
    3. On the Virtual Machine Configuration page, complete the fields as follows:
       
      - Virtual Machine Name: XXXlabfs02
       
      - New Password and Confirm Password fields: Choose and confirm a new local Administrator password.
       
      - Size: Small (1 core, 1.75GB Memory)
       
      Click the Next button to continue.
       
      Note: It is suggested to use secure passwords for Administrator users and service accounts, as Windows Azure virtual machines could be accessible from the Internet knowing just their DNS.  You can also read this document on the Microsoft Security website that will help you select a secure password: http://www.microsoft.com/security/online-privacy/passwords-create.aspx.
       
    4. On the Virtual Machine Mode page, complete the fields as follows:
       
      - Connect to an Existing Virtual Machine: Selected
       
      - Virtual Machine to Connect: XXXlabfs01 ( XXXlabfs.cloudapp.net )
       
      - Storage Account: Select the Storage Account defined in the Getting Started steps from the Prerequisites section above.
       
      - Region/Affinity Group/Virtual Network: Select XXXlabnet01 – the Virtual Network defined in prior Step-by-Step Guides listed in the Prerequisites section above.
       
      - Virtual Network Subnets: Select Subnet-1 (10.0.0.0/23)
       
      Click the Next button to continue.
       
    5. On the Virtual Machine Options page, click the Checkmark button to begin provisioning the new virtual machine.
       
      As the new virtual machine is being provisioned, you will see the Status column on the Virtual Machines page of the Windows Azure Management Portal cycle through several values including Stopped, Starting (Provisioning), Running (Provisioning) and Running. When provisioning for this new Virtual Machine is completed, the Status column will display a value of Running and you may continue with the next step in this guide.
       
    6. After the new virtual machine has finished provisioning, click on the name ( XXXlabfs02 ) of the new Virtual Machine displayed on the Virtual Machines page of the Windows Azure Management Portal to open the Virtual Machine Dashboard page for XXXlabfs02.
       
    7. On the Virtual Machine Dashboard page for XXXlabfs02, make note of the Internal IP Address displayed on this page.  This IP address should be listed as 10.0.0.8
       
      If a different internal IP address is displayed, the virtual network and/or virtual machine configuration was not completed correctly.  In this case, click the DELETE button located on the bottom toolbar of the virtual machine details page for XXXlabfs02, and go back to the beginning of Exercise 1 to confirm that all steps were completed correctly. 

In this exercise, you completed the initial deployment of two VMs running Windows Server 2012.  These VMs will be used to form a Windows Server 2012 Failover Cluster in the remaining exercises of this Step-by-Step Guide.

Exercise 2: Configure Cluster Node VMs for High Availability on Windows Azure

In this exercise, you will configure each Cluster Node VM for High Availability on Windows Azure by assigning each VM to a common Availability Set name.  By using a common Availability Set name for both VMs, Windows Azure will automatically place these VMs on separate underlying infrastructure components to eliminate single points-of-failure and increase application service availability, in this case for clustered roles running on each virtual machine node.

  1. Login to the Windows Azure Management Portal.
     
    1. Sign in at the Windows Azure Management Portal with the logon credentials used when you signed up for your Free 90-Day Windows Azure Trial.
       
  2. Configure a new Windows Azure Availability Set for VM XXXlabfs01.
     
    1. Select Virtual Machines located on the side navigation panel on the Windows Azure Management Portal page.
       
    2. On the Virtual Machines page, click on the name of VM XXXlabfs01 to navigate to the Virtual Machine Dashboard page for this Virtual Machine.
       
    3. On the Virtual Machines Dashboard page, click on the Configure button located on the top page navigation bar.
       
    4. On the Configure page, select the option to Create Availability Set in the drop-down menu for the Availability Set field.  Type XXXlabfs as the new Availability Set name in the text field provided.
       
    5. Click the Save button located on the bottom page navigation toolbar to save the new Availability Set definition. When prompted, click the Yes button to confirm this save operation.
       
      Note that as part of saving a new Availability Set assignment, a virtual machine may need to be placed on different underlying infrastructure components to isolate fault and update domains.  As part of this process, the virtual machine could be restarted.
       
      When this update has completed, you may continue with the next step in this exercise.
       
  3. Configure the same Windows Azure Availability Set for VM XXXlabfs02.
     
    1. Select Virtual Machines located on the side navigation panel on the Windows Azure Management Portal page.
       
    2. On the Virtual Machines page, click on the name of VM XXXlabfs02 to navigate to the Virtual Machine Dashboard page for this Virtual Machine.
       
    3. On the Virtual Machines Dashboard page, click on the Configure button located on the top page navigation bar.
       
    4. On the Configure page, select XXXlabfs in the drop-down menu for the Availability Set field.  
       
    5. Click the Save button located on the bottom page navigation toolbar to save the new Availability Set definition. When prompted, click the Yes button to confirm this save operation.
       
      Note that as part of saving a new Availability Set assignment, a virtual machine may need to be placed on different underlying infrastructure components to isolate fault and update domains.  As part of this process, the virtual machine could be restarted.
       
      When this update has completed, you may continue with the next exercise in this Step-by-Step Guide

In this exercise, you assigned each Cluster Node VM to a common Windows Azure Availability Set.  By completing this exercise, each VM is now placed on separate underlying cloud infrastructure to eliminate a single-point-of-failure between VMs.

Exercise 3: Prepare VMs and Install Failover Clustering Feature

In this exercise, you will join each Windows Server 2012 VM deployed in Exercises 1 & 2 to a common Windows Server Active Directory domain. You will also attach each VM to shared iSCSI storage and install the Failover Clustering feature.

NOTE: This exercise requires that all Step-by-Step Guides listed in the Prerequisites section above have been completed first.  Completion of these prior Step-by-Step Guides is required so that the Active Directory domain and shared iSCSI storage referenced in this exercise is configured and available.

COMPLETE THIS EXERCISE TWICE! Complete this exercise one time for virtual machine XXXlabfs01 and a second time for virtual machine XXXlabfs02 to prepare both virtual machines with the necessary requirements for forming a new failover cluster in Exercise 4. In this exercise, we’ll be using the notation of XXXlabfsYY where YY is either “01” or “02” to reflect the VM with which you are currently working.

  1. Login to the Windows Azure Management Portal.
     
    1. Sign in at the Windows Azure Management Portal with the logon credentials used when you signed up for your Free 90-Day Windows Azure Trial.
       
  2. Login to the Virtual Machine as a Local Administrator.
     
    1. Select Virtual Machines located on the side navigation panel on the Windows Azure Management Portal page.
       
    2. On the Virtual Machines page, click on the name of VM XXXlabfsYY to navigate to the Virtual Machine Dashboard page for this Virtual Machine.
       
    3. Click the Connect button on the bottom page navigation toolbar to open a Remote Desktop session to this virtual machine. 
       
    4. Login with the same local Administrator user credentials used when deploying this virtual machine above in Exercise 1. 
       
      After the Remote Desktop console session has initialized and the Server Manager tool has launched, continue with the next step in this exercise.
       
  3. Join the Virtual Machine to the contoso.com Active Directory domain.
     
    1. In the Server Manager tool, click Local Server in the left navigation pane to navigate to the Local Server page.
       
    2. On the Local Server page, click the WORKGROUP link to launch the System Properties dialog box.
       
    3. On the Computer Name tab of the System Properties dialog box, click the Change… button to launch the Computer Name/Domain Changes dialog box.
       
    4. In the Computer Name/Domain Changes dialog box, click the Domain: radio button and type contoso.com in the text field.  Click the OK button.
       
    5. In the Windows Security dialog box, type the Domain Administrator login credentials ( such as Administrator@contoso.com ) that you used when configuring this domain in the prior Step-by-Step Guides listed in the Prerequisites section of this article.  Click the OK button to authenticate.
       
    6. Once the domain join has been successfully completed, you will see a message box stating “Welcome to the contoso.com domain.” Click the OK button twice, then click the Close button to close the System Properties dialog box.
       
    7. When prompted, click the Restart Now button to restart the virtual machine.
       
      Monitor the restart progress of the virtual machine on the Virtual Machines page of the Windows Azure Management Portal.  When the restart has completed, the virtual machine status will display Running.  You may then continue with the next step in this exercise.
       
  4. Login to the Virtual Machine as a Domain Administrator.
     
    1. Select Virtual Machines located on the side navigation panel on the Windows Azure Management Portal page.
       
    2. On the Virtual Machines page, click on the name of VM XXXlabfsYY to navigate to the Virtual Machine Dashboard page for this Virtual Machine.
       
    3. Click the Connect button on the bottom page navigation toolbar to open a Remote Desktop session to this virtual machine. 
       
    4. Login with the same Domain Administrator user credentials ( Administrator@contoso.com ) used when deploying the contoso.com Active Directory domain in the prior Step-by-Step Guides listed in the Prerequisites section above
       
      After the Remote Desktop console session has initialized and the Server Manager tool has launched, continue with the next step in this exercise.
       
  5. Connect shared iSCSI storage to the Virtual Machine.
     
    1. In the Server Manager tool, click Tools on the top left menu bar and then select iSCSI Initiator from the drop-down menu.   
       
    2. When prompted to configure the Microsoft iSCSI service for automatic startup, click the Yes button.   
       
    3. In the iSCSI Initiator Properties dialog box, select the Targets tab and enter 10.0.0.6 in the Target: field.  Click the Quick Connect… button.   
       
    4. In the Quick Connect dialog box, confirm that the Progress Report text box reports Login Succeeded and click the Done button.
       
    5. In the iSCSI Initiator Properties dialog box, select the Volumes and Devices tab and click the Auto Configure button.  Confirm that two volumes appear in the Volume List box.
       
    6. Click the OK button to save these changes and close the iSCSI Initiator Properties dialog box.
       
  6. Install the File Server Role and Failover Clustering Feature.
     
    1. In the Server Manager tool, click Manage on the top left menu bar and then select Add Roles and Features from the drop-down menu to launch the Add Roles and Features Wizard.
       
    2. In the Add Roles and Features Wizard dialog box, click the Next button three times to advance to the Select Roles page.
       
    3. On the Select Roles page, expand File and Storage Services, then expand File and iSCSI Services and select the File Server role service.  Click the Next button to continue.
       
    4. On the Select Features page, select the checkbox for the Failover Clustering feature in the Features list.  When prompted, click the Add Features button to add all features that are required for Failover Clustering.
       
    5. Click the Next button and then click the Install button to begin the feature installation.
       
    6. When the feature installation has completed, click the Close button to close the Add Roles and Features Wizard.

You have completed this steps in this exercise on one virtual machine.  Before continuing with the next exercise, go back to the top of Exercise 3 and complete these same steps on your second cluster node virtual machine as well.

After you’ve completed this exercise on both virtual machines, you may continue to the next exercise.

Exercise 4: Create a New Failover Cluster

In this exercise, you will create a new Failover Cluster named XXXlabfsc using virtual machines XXXlabfs01 and XXXlabfs02 as individual cluster nodes.

Begin this exercise after establishing a Remote Desktop Connection session to virtual machine XXXlabfs01. Login as a Domain Administrator user account ( such as Administrator@contoso.com ).

  1. Launch the Failover Cluster Manager tool.
     
    1. In the Server Manager tool, click Tools on the top left menu bar and then select Failover Cluster Manager from the drop-down menu.
       
  2. Create and Validate the Initial Cluster Configuration.
     
    1. In the Failover Cluster Manager tool, click on the Create Cluster action in the Actions list located in the right-most pane to launch the Create Cluster Wizard.
       
    2. On the Before You Begin page of the Create Cluster Wizard, click the Next button to continue.
       
    3. On the Select Servers page of the Create Cluster Wizard, add both cluster nodes ( XXXlabfs01 and XXXlabfs02 ) to the Selected servers list. Click the Next button to continue.
       
    4. On the Validation Warning  page of the Create Cluster Wizard, accept all default values and click the Next button to continue. The Validate a Configuration Wizard will launch. 
       
    5. On the Before You Begin page of the Validate a Configuration Wizard, click the Next button to continue.
       
    6. On the Testing Options page of the Validate a Configuration Wizard, accept all default values and click the Next  button to continue.
       
    7. On the Confirmation page of the Validate a Configuration Wizard, review the list of validation tests to be performed by scrolling through the list.  When ready, click the Next button to run all validation tests.
       
    8. When the validation testing completes successfully, click the View Report button to review the results of the validation tests. 
       
      Note that validation warnings were issued during the testing for the Network Communication category.  Because we are building this simulated cluster with Windows Azure VMs, this warning is expected.  Typically, when clusters are deployed for PoC, Pilot and Production usage scenarios, separate network interfaces are used on each cluster node for cluster management, storage and client traffic.  Currently, Windows Azure Virtual Machines can be configured with only a single network interface for each VM.
       
      When done reviewing the Failover Cluster Validation Report, close the report window.
       
    9. On the Summary page of the Validate a Configuration Wizard, click the Finish button to close this wizard and return to the Create Cluster Wizard.
       
    10. On the Access Point for Administering the Cluster page of the Create Cluster Wizard, type XXXlabfsc in the Cluster Name field.  Click the Next button to continue.
       
    11. On the Confirmation page of the Create Cluster Wizard, accept all default values and click the Next button to begin creating the new Failover Cluster.
       
    12. On the Summary page of the Create Cluster Wizard, click the View Report button to view the results from creating the new Failover Cluster.  When done reviewing the Create Cluster Report, close the report window.
       
    13. On the Summary page of the Create Cluster Wizard, click the Finish button to close the wizard.
       
  3. Configure the Cluster IP Address Resource.
     
    NOTE: This task needs to be performed in the Windows Azure cloud-based lab environment because Dynamic IP Addresses are currently not supported on Windows Azure for Cluster Resources.
     
    1. In the Failover Cluster Manager tool, click on the Cluster Name ( XXXlabfsc.contoso.com ) in the left navigation pane.
       
    2. In the Summary of Cluster XXXlabfsc middle pane, scroll down to the Cluster Core Resources section.
       
    3. In the Cluster Core Resources section, expand the Cluster Name resource to show the associated IP Address cluster resource.
       
    4. Double-click on the IP Address cluster resource to display the IP Address Properties dialog box.
       
    5. In the IP Address Properties dialog box, set the following field values:
       
      - Static IP Address: Selected
       
      - Address: 10.0.0.100
       
      Click the OK button to save these changes.
       
    6. When prompted, click the Yes button to bring the new IP Address resource online within the cluster.

In this exercise, you configured Failover Cluster XXXlabfsc on the Windows Azure cloud platform using virtual machines for two individual nodes within this cluster.

Exercise 5: Build a Continuously Available Clustered File Server Role

In this exercise, you will configure a new Clustered File Server Role in the XXXlabfsc cluster with a Continuously Available File Share resource.

Begin this exercise after establishing a Remote Desktop Connection session to virtual machine XXXlabfs01. Login as a Domain Administrator user account ( such as Administrator@contoso.com ).

    1. Launch the Failover Cluster Manager tool.
       
      1. In the Server Manager tool, click Tools on the top left menu bar and then select Failover Cluster Manager from the drop-down menu. 
         
    2. Create a New Clustered File Server Role.
       
      1. In the Failover Cluster Manager tool, right-click on the Cluster Name ( XXXlabfsc.contoso.com ) in the left navigation pane.  Select Configure Role… from the pop-up menu to launch the High Availability Wizard.
         
      2. On the Before You Begin page of the High Available Wizard dialog box, click the Next button to continue.
         
      3. On the Select Role page of the High Availability Wizard dialog box, select the File Server role and click the Next button to continue.
         
      4. On the File Server Type page of the High Availability Wizard dialog box, select File Server for general use and click the Next button to continue.
         
      5. On the Client Access Point page of the High Availability Wizard dialog box, enter XXXlabfsc01 in the Name field and click the Next button to continue.
         
      6. On the Select Storage page of the High Availability Wizard dialog box, select the Cluster Disk in the available storage list and click the Next button to continue.
         
      7. On the Confirmation page of the High Availability Wizard dialog box, click the Next button to configure the Clustered File Server Role.  
         
      8. On the Summary page of the High Availability Wizard dialog box, click the View Report button to review the Cluster File Server Role configuration status report.  When done reviewing the report, close the window.
         
      9. On the Summary page of the High Availability Wizard dialog box, click the Finish button to close the wizard.
         
    3. Configure the Clustered File Server Role IP Address Resource.
       
      NOTE: This task needs to be performed in the Windows Azure cloud-based lab environment because Dynamic IP Addresses are currently not supported on Windows Azure for Cluster Resources.
       
      1. In the Failover Cluster Manager tool, expand the Cluster Name ( XXXlabfsc.contoso.com ) in the left navigation pane to show the Roles folder node.  Click on the Roles folder node to select it.
         
      2. In the Roles middle pane, select the Resources tab located at the bottom of the middle pane.
         
      3. On the Resources tab, expand the Server Name resource to show the IP Address resource located below it.
         
      4. Double-click on the IP Address cluster resource to display the IP Address Properties dialog box.
         
      5. In the IP Address Properties dialog box, set the following field values:
         
        - Static IP Address: Selected
         
        - Address: 10.0.0.101
         
        Click the OK button to save these changes.
         
      6. At the top of the Roles middle pane, right-click on the Clustered File Server Role ( XXXlabfsc01 ) and click Start Role from the pop-up menu to bring this role online.
         

 

  1. Add a Continuously Available File Share.
     
    1. In the Failover Cluster Manager tool, expand the Cluster Name ( XXXlabfsc.contoso.com ) in the left navigation pane to show the Roles folder node.  Click on the Roles folder node to select it.
       
    2. In the Roles middle pane, click on the Clustered File Server Role ( XXXlabfsc01 ) to select it.
       
    3. In the Actions right pane, click Add File Share to launch the New Share Wizard.
       
    4. On the Select the profile for this share page of the New Share Wizard dialog box, select SMB Share – Quick and click the Next button to continue.
       
    5. On the Select the server and path for this share page of the New Share Wizard dialog box, select XXXlabfsc01 in the Server list and the clustered storage volume in the Select by volume list.  Click the Next button to continue.
       
    6. On the Specify share name page of the New Share Wizard dialog box, enter Data01 in the Share name field and click the Next button to continue.
       
    7. On the Configure share settings page of the New Share Wizard dialog box, ensure that the checkbox option for Enable continuous availability is checked.  Click the Next button to continue.
       
    8. On the Specify permissions to control access page, accept the default values and click the Next button to continue.
       
    9. On the Confirm selections page, click the Create button to create the new continuously available file share.
       
    10. On the View results page, click the Close button to close this wizard.
       
  2. Confirm that the newly created file share ( \\XXXlabfsc01\Data01 ) is now available.
     
    1. In the Failover Cluster Manager tool, expand the Cluster Name ( XXXlabfsc.contoso.com ) in the left navigation pane to show the Roles folder node.  Click on the Roles folder node to select it.
       
    2. In the Roles middle pane, select the Shares tab located at the bottom of the middle pane.
       
    3. Verify that Data01 exists as a new file share in the list displayed and that the Continuous Availability setting is set to Yes.

In this exercise, you completed the configuration of a Clustered File Server Role and a Continuously Available File Share to learn the process for deploying business critical resources in a highly available Windows Server 2012 Failover Cluster.

Exercise 5: Export / Import Lab Virtual Machines

Our Windows Server 2012 cloud-based lab is now functional, but if you’re like me, you may not be using this lab VM 24x7 around-the-clock.  As long as a virtual machine is provisioned, it will continue to accumulate compute hours against your Free 90-Day Windows Azure Trial account regardless of virtual machine state – even in a shutdown state!

To save our compute hours for productive study time, we can leverage the Windows Azure PowerShell module to automate export and import tasks to de-provision our virtual machines when not in use and re-provision our virtual machines when needed again.

In this exercise, we’ll step through using Windows PowerShell to automate:

  • De-provisioning lab virtual machines when not in use
  • Re-provisioning lab virtual machines when needed again.

Once you’ve configured the PowerShell snippets below, you’ll be able to spin up your cloud-based lab environment when needed in just a few minutes!

Note: Prior to beginning this exercise, please ensure that you’ve downloaded, installed and configured the Windows Azure PowerShell module as outlined in the Getting Started article listed in the Prerequisite section of this step-by-step guide.  For a step-by-step walkthrough of configuring PowerShell support for Azure, see Setting Up Management by Brian Lewis, one of my peer IT Pro Technical Evangelists.

  1. De-provision the lab. Use the Stop-AzureVM and Export-AzureVM cmdlets in the PowerShell snippet below to shutdown and export lab VMs when they are not being used.  
      
    NOTE: Prior to running this snippet, be sure to edit the first line to reflect the names of each of your VMs and confirm that the $ExportPath folder location exists.

    $myVMs = @("XXXlabfs02","XXXlabfs01")
    $myCloudSvc = "XXXlabfs"
     
    Foreach ( $myVM in $myVMs ) {
        Stop-AzureVM -ServiceName $myCloudSvc -Name $myVM
        $ExportPath = "C:\ExportVMs\ExportAzureVM-$myVM.xml"
        Export-AzureVM -ServiceName $myCloudSvc -name $myVM -Path $ExportPath 
    }

     
    After you've verified that all Export files were created in the folder location specified by $ExportPath, you can then de-provision your VMs with the following PowerShell snippet:
     
    $myVMs = @("XXXlabfs02","XXXlabfs01")
    $myCloudSvc = "XXXlabfs"
     
    Foreach ( $myVM in $myVMs ) { 
        Remove-AzureVM -ServiceName $myCloudSvc -name $myVM
    }

     
  2. Re-provision the lab. Use the Import-AzureVM and Start-AzureVM cmdlets in the PowerShell snippet below to import and start lab VMs when needed again.     
     
    $myVNet = "XXXlabnet01"
    $myVM1 = "XXXlabfs01"
    $myVM2 = "XXXlabfs02"
    $myCloudSvc = "XXXlabfs"
    $myStorageAccount = "XXXlabstor01"
     
    Get-AzureSubscription | Set-AzureSubscription -CurrentStorageAccount $myStorageAccount
     
    # Import $myVM1
     
        $ExportPath = "C:\ExportVMs\ExportAzureVM-$myVM1.xml"  
        Import-AzureVM -Path $ExportPath | New-AzureVM -ServiceName $myCloudSvc -VNetName $myVNet
        Start-AzureVM -ServiceName $myCloudSvc -name $myVM1
     
    # Import $myVM2
     
        $ExportPath = "C:\ExportVMs\ExportAzureVM-$myVM2.xml"  
        Import-AzureVM -Path $ExportPath | New-AzureVM -ServiceName $myCloudSvc 
        Start-AzureVM -ServiceName $myCloudSvc -name $myVM2
     

Completed! What’s Next?

The installation and configuration of a new simulated Windows Server 2012 Failover Cluster running on Windows Azure is now complete.  To continue your learning about Windows Server 2012, explore these other great resources:

  • Join the Windows Server 2012 “Early Experts” Challenge study group to learn more about Windows Server 2012! and prepare for MCSA Certification!
     
  • Learn more about Windows Azure Virtual Machines and Virtual Networks with this FREE Online Training!
     
  • Complete the other Hands-On Labs in the "Early Experts" Cloud Quest to request your certificate of completion ... Become our next "Early Expert"!

How are you using Windows Azure Virtual Machines and Virtual Networks?

Do you have an interesting or unique scenario that you are evaluating on the Windows Azure cloud platform?  Feel free to leave your comments, feedback and ideas below to share across our IT Pro community!