Thursday, June 19, 2014

Setting up your PowerShell environment to manage your Microsoft Azure subscription.

The purpose of this blog post is to get someone new to Azure PowerShell up and going in little time.It will also be a quick reference for me as this is not something I do everyday and hence I have found myself doing the same research a few times. 

I will be walking you through setting up your workstation environment to use PowerShell to manage your Microsoft Azure environment. Please note that this is not the only way to do this but it is a quick way to get started. If you want to use your own security certificates you will have to follow some additional steps not covered here. 

Let's get started..

Installing the Windows Azure PowerShell Cmdlets

Download the Windows Azure PowerShell module from the Windows Azure Downloads page. On this page, you will find the Install link under the Windows Powershell section.

Download and execute the .exe file. After doing so, the Web Platform Installer comes up

Click next and take a moment to review the software prerequisites list. 

Click on I accept to proceed and start the installation. 

After the installation finishes you can close the web Platform Installer.

Establishing a secure connection between your PowerShell environment and Windows Azure

  • Open your preferred PowerShell scripting environment or the PowerShell command line. I'll use the PowerShell ISE in this example.
  • Set the execution policy setting to "Remote Signed" which by default sets the execution policy for the Local Computer as scope. see more_about_execution_policies for more details.
         PS C:\> Set-ExecutionPolicy RemoteSigned
  • Export the publishing settings from your Windows Azure subscription:

          From PowerShell Execute the Get-AzurePublishSettingsFile command. 

This command will open a browser window. If you are not already logged into the Windows Azure Portal you will be directed to the sign in page and after entering your credentials the save file window comes up. 

Take a note of the path and file name where you save the publishing settings file.

Please note that this method automatically generates management certificates for each subscription as shown below.  You can verify this by going to the "Settings" section in the Windows Azure management portal. You should now see all the Management Certificates associated with your subscriptions.

Alternatively to exporting your publishing settings, you can use the Set-AzureSubscription command to set up your subscriptions information and connection configuration. 

  • Execute the Import-AzurePublishSettingsFile command in PowerShell to import the publishing settings  into PowerShell by refferencing the publishing settings file downloaded in a prior step. The command should look like this: 
          Import-AzurePublishSettingsFile 'FilePath\PublishingFileName'

The command completes.

You can inspect the files created under %user%\AppData\Roaming\Windows Azure Powershell

Test your connection

Our last step is to verify we now have connectivity to our Windows Azure environment.

Execute the following PowerShell Command: Get-AzureSubscription

Verify that all the subscriptions for which you are an administrator are listed.

That's it. You are now ready to unleash the power of PowerShell and Microsoft Azure. Have fun!

Recommended Resources:

Monday, July 22, 2013

Building a Hyper-V Windows Server in under 3 seconds

I find myself building VMs almost on a daily basis. If I am not building a proof of concept or a demo for a client, I am testing different configurations or architectural approaches to solutions, testing new features of SQL Server, Cumulative Updates etc... Whatever the reason might be, creating a new VM always takes valuable time.

Back in April I blogged about using Hyper-V as your virtualization platform for a lab environment. I walked through building a template Virtual Server and then creating a base drive to be used to build new machines from. Using a combination of base and differential drives reduces the time that it takes to provision a new VM dramatically as you don't have to install the operative system every time. However, it still takes a few minutes to walk through the Hyper-V manager wizards to create your differential disk and new machine. Let's see how to take things to the next level by using two simple PowerShell commands to build your differential disk and Virtual Server.

Assumptions: For these commands to work you must already have a base drive to be used as the parent drive for the differential disk. For step by step instructions creating a base drive check my previous blog post Setting Up a Virtual Server Lab With Hyper-V.

Let's get started...

The goal here is to avoid going through the Hyper-V manager and use PowerShell commands to provision your new VM. See the script below.

Let's take a look at the few lines that initialize the variables that we are going to use as parameters.

#Set variables
$Name = "VMName" #This is the Hyper-V name of the Virtual Machine
$ParentPath = "D:\Hyper-V\Virtual Hard Disks\WS2012Base.vhdx" #Path to the base drive
$DiskPath = "H:\Hyper-V\"+$Name+"\"+$Name+".vhdx" #Path for the differential drive, I use my SSD for this
$VMPath = "D:\Hyper-V\"+$Name+"\" #Path for the Virtual Machine definition files

Then we execute the command to create the differential disk using the variables initialized above.

#Create new differential disk
New-VHD -ParentPath $ParentPath -Path $DiskPath -Differencing -SizeBytes 60GB  

And lastly, we run the command to create the VM using the differential disk created in the previous step.

#Create VM
New-VM -VHDPath $DiskPath -ComputerName "localhost" -MemoryStartupBytes 4GB -Name $Name -Path $VMPath -SwitchName "External Network"

Here it is without the comments:

$Name = "VMName" 
$ParentPath = "D:\Hyper-V\Virtual Hard Disks\WS2012Base.vhdx" 
$DiskPath = "H:\Hyper-V\"+$Name+"\"+$Name+".vhdx" 
$VMPath = "D:\Hyper-V\"+$Name+"\"

New-VHD -ParentPath $ParentPath -Path $DiskPath -Differencing -SizeBytes 60GB  

New-VM -VHDPath $DiskPath -ComputerName "localhost" -MemoryStartupBytes 4GB -Name $Name -Path $VMPath -SwitchName "External Network"


I typically start the VMs with 4GB of RAM and 60GB of maximum disk space so I hard coded those values in the command. Of course you can substitute those values with additional variables and initialize them in the first step.

In my system, running these two PS commands take 2 to 3 seconds and I am ready to go. That is it! Talk about time savings.

Check out the New-VHD and  New-VM TechNet documentation pages for more information and additional options regarding these two Hyper-V commands.

Sunday, July 7, 2013

SQL Saturday #226 - South Florida

For the second time, I had the pleasure and honor to be part of the organizer's board for SQL Saturday - South Florida 2013. To be part of such a great community event was without a doubt one of the best professional experiences I've had. I worked closely with so many great people including speakers, sponsors, volunteers, fellow organizers and of course the attendees. The networking opportunities were incredible.  It was great to hear so many success stories from people having one thing in common. They all attended SQL Saturday at one point during the last few years and have since then found a path to professional excellence and their ideal jobs. 

This year we set a new record for the number of registrations. We were 2 registrations shy of 800. That is right! 798 registrations. I put together a quick video using Geoflow that shows the registrations by zip code over time.


SQL Saturday #226 - South Florida from Luis Figueroa on Vimeo.

I also had the pleasure of hosting one of the sessions. In this presentation I provided an overview of SQL Server Master Data Services 2012 titled Getting started with MDS 2012.

I have posted the slides in slideshare and embedded a link below.

Lastly, if you are a data professional or you just have an interest in the field, I would like to invite you to become part of the PASS community. Getting involved is easy, visit to get started.     If you are in South Florida, you can attend any of the local chapter meetings:

I look forward to seeing everyone once again at SQL Saturday - South Florida 2014!

If you are interested in attending one of my presentations please visit my whereabouts page for information on upcoming speaking engagements.

Luis Figueroa

Thursday, April 4, 2013

Setting Up a Virtual Server Lab With Hyper-V

For years I had used VMware as my hypervisor of choice for virtual labs but I recently switched to Hyper-V. The last few weeks I have been getting familiar with how things work in Microsoft's virtualization environment and decided to write a quick step by step on how to get a virtual lab up and running. Before I get started with that I would like to share some of the reasons why I decided to switch.

  • Hyper-V is now included with Windows 8 Pro and Enterprise editions (No need to spend extra money for cutting edge virtualization technology on my laptop or workstation)
  • Hyper-V has matured now to a point where it can now make a great case for enterprises to adopt this technology over any other virtualization platform so I would expect to see more enterprises running their private clouds on Hyper-V. See Hyper-V competitive advantage datasheet
  • I am a Microsoft Certified Professional / Trainer and I work for a Microsoft Gold Partner. There is a great deal of support offered to IT professionals focused on Microsoft technologies and many of the demos / labs are available in the form of Hyper-V virtual machines. It would not be worth it to take the extra time to recreate such resources from scratch using a different virtualization technology.
  • I see I great deal of opportunities derived from the Azure IaaS offering and it's ability to run Hyper-V machines. I can create a Virtual Server and run it on my laptop, the Data Center or upload it to the cloud. 
  • I can browse a VHD as if it were just another disk. 
  • I can boot my windows computer from a VHD

Now, back to the original subject. Let's get started.

Enabling Hyper-V

First things first, right? if you have not already enabled Hyper-V in your windows 8 Pro or Enterprise OS you can do so by executing the following PowerShell command:

enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Thursday, October 4, 2012

Recap of SQL Saturday #151 Orlando - September 29, 2012

This last Saturday September 29, I had the opportunity to speak at SQL Saturday in Orlando. It was such a great experience from many different levels. I guess I will start with the speaker’s dinner. I arrived on Friday afternoon and after checking in at the hotel, I worked on the final details of my presentation. I then headed down to Liam Fitzpatrick's Irish Restaurant on Market Promenade Avenue where the speaker’s dinner was taking place.

Friday, April 6, 2012

SSIS 2012 Project Versions

Did you know that when you deploy projects to the SSIS catalog in SSIS 2012, the previous version of the project is kept in the server?
All you have to do to access the version history is right click in the name of the project and click on “Versions”. Assuming of course that you are using the new project deployment mode. This feature is not available if you use the package deployment mode.

Saturday, February 19, 2011

How does the SQL Server engine guarantees that Change Data Capture has extracted the necessary transactions from the transaction log file before log truncation occurs.

As you know Change Data Capture harvests transactions from the log file. I was wondering what happens when the log file gets truncated during transaction log backups or when an automatic checkpoint takes place on a database in simple recovery mode causing log truncation. What if the CDC job has not harvested those records in the portion of the log to be truncated. I had the feeling that the SQL Engine ensured that this would not happen but I wanted to understand the internals of this process. turns out, with all the information available about CDC it was hard to find a straight answer on this. But I did.