SQL Azure Powershell for Developers on the Run!

In my last post I Announced the Windows Azure Powershell Extensions a new project that I will be iterating over when I run into tasks that are common in everyday Windows Azure Scenarios.

Being a Developer on the run, going from City to City or Coffee shop to Coffee shop, the absolute first Extension came to me naturally. Quickly create firewall rules for where ever you are by using Add-RoamingFirewallRule, when you’re ready to go remove the setting with Remove-RoamingfirewallRule.

Let’s take a look at how to use these scripts. [If you haven’t already installed the Windows Azure Powershell Cmdlets, download the Windows Azure Powershell Cmdlets]

Adding Functions to your Powershell Profile

Functions are only helpful in powershell if their accessible, if it takes you too long to set up a script there’s a good chance you will never use it. Let’s take a brief look at making sure your Powershell environment is up and running.

Open Powershell.

Create a Powershell profile

new-item -path $profile -itemtype file -force
Notepad $profile

Now that your profile has been created, and opened in notepad it’s time to copy the Add-RoamingFirewallRule and Remove-RoamingFirewallRule functions from the Windows Azure Powershell Extensions Project on GitHub and paste them into the open notepad document. After you’ve finished save and close the file. Restart Powershell.

Using Add-RoamingFirewallRule & Remove-RoamingFirewallRule

Let’s first take a look at the help files that are provided with the script.

Get-Help Add-RoamingFirewallRule


Get-Help Remove-RoamingFirewallRule


You’ll notice that both Add-RoamingFirewallRule and Remove-RoamingFirewallRule both require an EnvironmentsCsv parameter which is a path to a CSV file containing Subscription and Management Certification information.

Creating the Subscription CSV File

The CSV file ensures that you don’t need to login to the Windows Azure Portal anytime you’re looking for your SubscriptionIds [Just keep the CSV file up-to-date]. The file requires the header in order to map to the internal variables in the function. The first value is the SubscriptionId for your Windows Azure Account, the second value is the Thumbprint for a Certificate [installed in CurrentUser\My] which has been uploaded as a Management Certificate using the Windows Azure Portal. Save this CSV file in a memorable location.


Adding SQL Azure Firewall Rules with Add-RoamingFirewallRule

To create a Roaming Firewall Rule you simply need to call Add-RoamingFirewallRule and pass in a Rule Name and a Path to the Subscription.csv file [created above].

Add-RoamingFirewallRule 'Starbucks' C:\WindowsAzure\Subscription.csv


After taking a look at the Windows Azure Portal you notice that a Firewall Rule will be created for every SQL Azure Server within each of the subscriptions that were defined in the CSV file.

Removing SQL Azure Firewall Rules with Remove-RoamingFirewallRule

To remove the setting once you’re done hanging out at Starbucks, simply call Remove-RoamingFirewallSetting passing in the same Rule name and the path to your Subscriptions.csv file.

Remove-RoamingFirewallRule 'Starbucks' C:\WindowsAzure\Subscription.csv


Magically the firewall rule disappears!

That’s a Wrap

I hope that this helps speed up your day when working with SQL Azure at different locations or encourages you to get out of the office from time to time. If you have any requests or notice a bug please file an issue on github.

Happy Clouding!

Announcing: Windows Azure Powershell Extensions

Update: Due to a number of the features being implemented in the PowerShell Cmdlets, this project was retired and removed from GitHub.

Recently, I have re-kindled my relationship with the command line. At some point during my day, everyday, I find myself opening up Powershell to either write a script to complete a repetitive task or check settings of my machine.

Powershell is a very powerful tool for your developer tool belt, even if you’re a Windows Azure Developer. Starting with Windows Azure SDK 1.3 Powershell peeked into the Azure space with Startup Tasks providing a way of digging deep into Windows to enable/install features/applications.

Enter Windows Azure Powershell Cmdlets

Originally, Ryan Dunn [formerly of the Microsoft (more specifically Windows Azure Evangelism team)] created a few Powershell Cmdlets to interact with the Windows Azure Management API.  With Ryan leaving the DPE Team and the Management API rapidly expanding it was a sad day for the Windows Azure Powershell Cmdlets.

Luckily a new face in the Windows Azure Team Michael Washam saw the gap and created the Windows Azure Powershell Cmdlets version 2.0. The new cmdlets Michael created offers an amazing range of functionality including managing Identity Providers in Windows Azure ACS, Creating SQL Azure Servers and Firewall Rules and a wide range of other functions against Windows Azure Compute and Storage.

For an overview of the Windows Azure Powershell Cmdlets, watch this video:

Adding to the Awesomesauce

With my newly re-kinkled love of the command line and an amazing list of Powershell Cmdlets for Windows Azure, I took it upon myself to start a project that will use these tools in real world scenarios.

Along with the love for the command line, I started using Git for source control on my laptop and for personal projects. What better way to share the Windows Azure Powershell Extensions than on GitHub.

Check out the Windows Azure Powershell Extensions

As I begin to add new functionality to the project, I’ll be sure to write some instructions on how to use the functions on this site. So be sure to keep an eye on the Project and my Blog.