Slot swap fails with message: "Switch-AzureRmWebAppSlot : Run Login-AzureRmAccount to login."

We have been having several deploy issues and have been working directly with Microsoft on them. They have identified the issues and have proposed workarounds for us pending Azure updates with the fixes for the issues being included. One of the workarounds is to use a multi-phase slot swap using the Switch-AzureRmWebAppSlot commandlet. I have upgraded the Windows management framework to 5.0 plus have installed the 2.3.0 modules AzureRM.Websites and AzureRM.profile. We now get the error “Switch-AzureRmWebAppSlot : Run Login-AzureRmAccount to login.” Running the same script from the powershell ISE it runs successfully.

Any ideas what is happening here that this is not functioning correctly from Octopus?

Please see attached screen shots below.

Hi Michael,

Thanks for getting in touch! I’ve followed you detailed report but I couldn’t reproduce your problem. The deployment worked for me.

Can you review my steps and compare them to your setup? If you already do what I do then please send me [the raw log] ( of your deployment. Also please add Get-Module -ListAvailable -Name Azure* to the top of your PowerShell script so we can verify that the correct Azure Modules are loaded.

  1. Downloaded the lastet version of Octopus: 3.5.2.
  2. Created a Web App in Azure
  3. Created a new slot called Staging
  4. Created an Azure acccount in Octopus that uses Service Principal authentication method
  5. Created a new deployment process and added “Run an Azure PowerShell Script”(content attached)
  6. The version of PowerShell modules in Octopus is a bit out of date so I installed the latest version using Web Platform Installer
  7. Added a new variable Octopus.Action.Azure.UseBundledAzurePowerShellModules and set its value to False to use the version of PowerShell modules I just installed
  8. Run the script and it succeeded (I attached the full log)

Please let me know how you go.



Pawel_Log.txt (67 KB)

Hi Pawel!

Thanks for your reply. I was just missing step 7 in your process below. Adding that variable resolved the issues I was seeing.


From: Pawel Pabich []
Sent: Thursday, November 24, 2016 3:29 PM
To: Kunze, Michael
Subject: Re: Slot swap fails with message: “Switch-AzureRmWebAppSlot : Run Login-AzureRmAccount to login.” [Problems #49207]

*** External Email ***

Hi Michael,

I’m glad you’ve solved your problem.