Azure Deployment Slot Switch cmdlet not working from PowerShell

Deadly 提交于 2020-01-06 05:08:31

问题


I can do this swap from the Portal, however it won't work from PowerShell

Switch-AzureRmWebAppSlot   -ResourceGroupName "z_test_amp_Resource_Group" -Name "z-test-amp-EXPERIMENT-TEST-APP" -DestinationSlotName "z-test-amp-EXPER-DEPLOY-SLOT-01" -SourceSlotName "production"

It gives the error:

The Resource 'Microsoft.Web/sites/z-test-amp-EXPERIMENT-TEST-APP/slots/production' under resource group 'z_test_amp_Resource_Group' was not found.

In the Portal Swap dialog it provides "production" in the Source DDL, and that works fine.

There is only one subscription involved.

In the PowerShell cmdlet I've tried:

-SourceSlotName "production"

-SourceSlotName z-test-amp-EXPERIMENT-TEST-APP

-SourceSlotName "z-test-amp-EXPERIMENT-TEST-APP"

In each case I get the same type of message: can't finds a slot by that name.

If I leave out the -SourceSlotName parameter it seems to accept everything else and then asks for the -SourceSlotName.

If I get a list of slots for the web app, using this:

Get-AzureRmWebAppSlot -ResourceGroupName z_test_amp_Resource_Group -name z-test-amp-EXPERIMENT-TEST-APP

it lists (lots of information and then finally) Name: z-test-amp-EXPERIMENT-TEST-APP/z-test-amp-EXPER-DEPLOY-SLOT-01

This looked like it might be the answer

Switch-AzureRmWebAppSlot no longer supports Production slot name

which says try this:

Switch-AzureRmWebAppSlot   -ResourceGroupName "z_test_amp_Resource_Group" -Name "z-test-amp-EXPERIMENT-TEST-APP" -SourceSlotName "z-test-amp-EXPER-DEPLOY-SLOT-01" 

but that leaving out the destination slot gives the error "TargetSlot must not be null"

And then including the -TargetSlot parameter like so:

Switch-AzureRmWebAppSlot   -ResourceGroupName "z_test_amp_Resource_Group" -Name "z-test-amp-EXPERIMENT-TEST-APP" -SourceSlotName "z-test-amp-EXPER-DEPLOY-SLOT-01" -TargetSlot production

results this error:

A parameter cannot be found that matches parameter name 'TargetSlot'.

Question: why is this not working / what is new correct syntax for this cmdlet?


回答1:


Answer given here: https://social.msdn.microsoft.com/Forums/en-US/774af941-d57b-47d4-8571-bab516f31633/deployment-swap-not-working-from-powershell?forum=windowsazurewebsitespreview

Apparently PowerShell wants both Source and Destination, but "production" only in the Destination.

Switch-AzureRmWebAppSlot   -ResourceGroupName "z_test_amp_Resource_Group" -Name "z-test-amp-EXPERIMENT-TEST-APP" -SourceSlotName "z-test-amp-EXPER-DEPLOY-SLOT-01" -DestinationSlotName "production"


来源:https://stackoverflow.com/questions/52336163/azure-deployment-slot-switch-cmdlet-not-working-from-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!