Skip to content

Instantly share code, notes, and snippets.

@MCKLMT
Last active August 29, 2015 13:56
Show Gist options
  • Save MCKLMT/9259994 to your computer and use it in GitHub Desktop.
Save MCKLMT/9259994 to your computer and use it in GitHub Desktop.
Gists for a blog post about Windows Azure Powershell command-line tool
# This command retreive the list of all available locations for a website
# Get-AzureWebsiteLocation
# Instanciate a new Website in the choosen Location
$website = New-AzureWebsite -Location "West Europe" -Name "MyNewShinyWebsite"
$serverLogin = "MCKLMT"
$serverPassword = ""
# Create a new server
$server = New-AzureSqlDatabaseServer -AdministratorLogin $serverLogin `
-AdministratorLoginPassword $serverPassword `
-Location "North Europe"
# Get your public Internet IP Address
$externalIP = (New-Object System.Net.WebClient).DownloadString("http://ipinfo.io/ip")
# Open the firewall for this specific IP
$server | New-AzureSqlDatabaseServerFirewallRule -RuleName "Open Firewall" `
-StartIPAddress $externalIP `
-EndIPAddress $externalIP
#Create a new database with Web Edition and 1 GB
$server | New-AzureSqlDatabase -DatabaseName "Northwind" -Edition Web -MaxSizeGB 1
Import-Module Azure
# Select this subscription as current for the current powershell session
Select-AzureSubscription -Current -SubscriptionName "Name of the subscription for this session"
# Or Instead
# Select this subscription as default for all sessions of this user
# Select-AzureSubscription -Default -SubscriptionName "Name of the subscription for this session"
# Filter the list by the name of one Cloud Service
Get-AzureVM -ServiceName "Name of the Cloud Service" `
| Where-Object {$_.Status -like "Ready*"} `
| ForEach-Object
{
# The "Force" switch allows the deallocation of last VM in a deployment.
Stop-AzureVM -ServiceName $_.ServiceName -Name $_.Name -Force
}
Import-Module Azure
# Open a popup to login to the account and save subscriptions in one line :)
Add-AzureAccount
Import-Module Azure
# Open a link to download the *.publishsettings
Get-AzurePublishSettingsFile
# Import the file. Change the path to the file :)
Import-AzurePublishSettingsFile -PublishSettingsFile "C:\MySavedPublishSettingsFile.publishsettings"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment