Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

Microsoft Azure PowerShell API Commands

Tags: powershell, azure, ms-azure

Authenticate.

Add-AzureAccount

Websites

List all websites.

Switch-AzureMode AzureServiceManagement
Get-AzureWebsite
Create new website.
New-AzureWebsite –Name the-website-name
Create new website, with specified server farm (aka web hosting plan)
Coming soon.

List all websites, sort by compute mode then name, view as table. Use this to determine what sites are running in different compute modes (e.g. Free, Dedicated)

Get-AzureWebsite | Sort-Object { $.ComputeMode, $.Name } | format-table -Property Name, HostNames, ComputeMode –autosize
Set WebSite’s AppSettings (e.g. deployment project)
$settings = New-Object Hashtable;
$settings[“Project”] = “TheProjectName.csproj”;
Set-AzureWebsite the-website-name –AppSettings $settings
View Website’s AppSettings
(Get-AzureWebsite the-website-name).AppSettings

Delete a website, without confirmation.

Remove-AzureWebsite –Name some-name –Force

Resources

List all resources.

Switch-AzureMode AzureResourceManager
Get-AzureResource

List all resources, websites only, view as table.

Get-AzureResource | Where-Object { $_.ResourceType -eq 'Microsoft.Web/Sites' } | format-table

List all resource properties.

Get-AzureResource | Get-Member

Get Azure PowerShell API Version

$DebugPreference='Continue'
Get-AzureResourceGroup
$DebugPreference='SilentlyContinue'

Change the Website Hosting Plan (aka Server Farm) of a Website

Set-AzureResource 
    -Name the-website-name
    -ResourceGroupName 'Default-Web-WestUS' 
    -ResourceType 'Microsoft.Web/sites' 
    -ApiVersion '2014-04-01-preview' 
    -PropertyObject @{ 'ServerFarm' = 'Default1' }