When running the commands and doing as guides i have found says i can’t get it to swap slots.
Getting
Invoke-Expression : The term ‘Swap-AzureRmWebAppSlot’ is not recognized as the
18:19:03Error
name of a cmdlet, function, script file, or operable program. Check the
18:19:03Error
spelling of the name, or if a path was included, verify that the path is
18:19:03Error
correct and try again.
18:19:03Error
At C:\Octopus\Work\20161129171848-20\Octopus.AzureContext.ps1:86 char:2
18:19:03Error
18:19:03Error
+ CategoryInfo : ObjectNotFound: (Swap-AzureRmWebAppSlot:String)
18:19:03Error
[Invoke-Expression], CommandNotFoundException
18:19:03Error
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Co
18:19:03Error
mmands.InvokeExpressionCommand
18:19:03Error
18:19:03Fatal
The step failed: The remote script failed with exit code 1
I have the variable set to not use the default Octopus azurerm powershell scripts
Thanks for getting in touch.Could you please send us the following info so we can take a look:
A screenshot of your deployment process where we can see the Powershell script step that’s using the swap cmdlet.
The full script you are using on that step.
A full deployment log following the below instructions:
1) Add these 2 variables to your project http://docs.octopusdeploy.com/display/OD/Debug+problems+with+Octopus+variables
2) Create a new release (so the new variables take effect) and deploy it. If possible skip as many steps as you can and only leave step we are troubleshooting in order to avoid the noise in the log.
3) Send us the raw log of that deployment http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task
Sorry I wasn’t clear on my previous message -> Did you run Get-command Swap-AzureRmWebAppSlot from Octopus using an Azure Powershell Step? Please do it if you haven’t done it already.
Also please try adding import-module AzureRM.Websites -verbose at the top of your script and let me know if that works
I did do add Import-Module -Name “C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Websites\AzureRM.Websites.psd1” -Verbose
That loads the correct PS module. But still it does not work. If i run the same command on the server at the end it show’s this.
Add a variable called Octopus.Action.PowerShell.ExecuteWithoutProfile in your project and set its value to true. This will run all your powershell scripts without any code in the profile files that might be interfering with the module import.
Remove any kind of module import you added in your own code in that step. Let just try to use the one that Octopus runs and see what happens.
I ran this one through one of my teammates who mentioned he had a similar case with another user. On that other thread, Pawel recommended the user to manually install the latest version of the Azure tools on the VM, and then tell Octopus not to use the Azure tools that are bundled in with Calamari (so it is forced to use the ones that were just installed).
Now, Pawel also let me know that the Azure tools bundled in Calamari were updated in Octopus 3.5.6. So you might be able to fix this only by upgrading your Octopus Server to the latest version.
Summarizing:
A) Try to upgrade your Octopus Server to the latest version so your Calamari copy has the latest version of the Azure tools we bundled in.
B) If that doesn’t work, try what I said in the first paragraph:
manually install the latest version of the Azure tools on the VM, and then tell Octopus not to use the Azure tools that are bundled in with Calamari (so it is forced to use the ones that were just installed).
This steps would be 6 and 7 on Pawels comment: http://help.octopusdeploy.com/discussions/problems/49207-slot-swap-fails-with-message-switch-azurermwebappslot-run-login-azurermaccount-to-login#comment_41304347
I have also tried step B in doing import module from the latest azure package.
Import-Module “C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Websites\AzureRM.Websites.psd1”
And that does not work either. And i did find Pawel’s suggestion and i tried that. That variable is in my deployment module now.
I’m glad to hear you got it working! would you mind explaining a bit more what is it that fixed it for you? I’m sure It’ll help any other users running into a similar situation.