Creating a new SQL Azure Server and Firewall Rule with PowerShell
Creating SQL Azure Servers and Configuring firewall rules is surprisingly easy with the new Windows Azure PowerShell Cmdlets 2.0.
Step 1: Add the WAPPSCmdlets Snapin or Module
Add-PsSnapin WAPPSCmdlets
Step 2: Create a Few Needed Variables
$subscriptionid = "your subscription id" $cert = Get-Item cert:\CurrentUser\My\yourcertthumbprint $adminLogin = "sqlAzureLogin" $adminPassword = "sqlAzurePassword"
Step 3: Call the Cmdlets With Your Variables
$newServer = New-SqlAzureServer -AdministratorLogin $adminLogin -AdministratorLoginPassword $adminPassword ` -Location "North Central US" -Certificate $cert ` -SubscriptionId $subscriptionid $newServer | New-SqlAzureFirewallRule -RuleName "EveryBody" ` -StartIpAddress "0.0.0.0" -EndIpAddress "255.255.255.255"
Obviously, you would want to change the firewall rule if you did not want EVERY IP address to be able to connect to your server but you get the idea.
Categories: PowerShell, SQL Azure, Windows Azure
SQL Azure, Windows Azure PowerShell CmdLets