I was recently facing an issue : while trying to aumotate, through PowerShell, the switch between the two slots of an Azure WebSite, I had to update the AppSettings from each slots.
Considering I had a website which name was “MyWebSite”, I created a slot named “Secondary”.
If I was trying a
$MyWebSite = Get-AzureWebSite -name MyWebSite
a
$MyWebSite.AppSettings
returned empty. Weird.
I tried the same command with a website without deployment slots (named MyNonStagedWebSite) :
$MyOtherWebSite = Get-AzureWebSite -name MyNonStagedWebSite
a
$MyOtherWebSite.AppSettings
correctly returned all applicaiton settings from my website.
I finally discovered that when launched on a multi-staged website, the
Get-AzureWebSite -name MyNonStagedWebSitereturned a different return than if launched on a non-staged website, thanks to the Get-Member command :
$MyWebSite | Get-Memberreturned a TypeName : Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.[b]Site[/b]
while a
$MyOtherWebSite | Get-Memberreturned a TypeName : Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.[b]SiteWithConfig[/b]
That was because $MyWebSite was :
Name : MyWebSite(Secondary) State : Running Host Names : {MyWebSite-secondary.azurewebsites.net} Name : MyWebSite State : Running Host Names : {MyWebSite.azurewebsites.net}
So, I figured on the Get-AzureWebSite help page that there was a “-slot” parameter. Magically, a
$MyWebSite1 = Get-AzureWebSite -name MyWebSite -Slot Secondary
successfully returned a TypeName : Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.SiteWithConfig , and
$MyWebSite1.AppSettings
successfully returned application settings from my secondary slot. My last difficulty was to find what was the name of the “main” slot. It’s only by luck that I found that it was “Production”. So, a
$MyWebSite2 = Get-AzureWebSite -name MyWebSite -Slot Production
successfully returned a TypeName : Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.SiteWithConfig , and
$MyWebSite2.AppSettings
successfully returned application settings from my main slot.
I wanted to post it somewhere, as I did a lot of digging around on the web, and never found clearly those informations; I hope they’ll get seen by search engine, to prevent future fellow to lose some days on this, as I did.