1
votes

My app service is

  • running on Azure
  • has authentication enabled (API Management - ClientId and Secret)
  • has a deployment slot called staging

Before we enabled the authentication we could run the following powershell command to swap staging and production slots:

Switch-AzureRmWebAppSlot -SourceSlotName "staging" -DestinationSlotName "production" -Name "app1" -ResourceGroupName "group1" -verbose -SwapWithPreviewAction ApplySlotConfig

Swap with preview allows us to verify the deployed code works with the production configuration settings before switching users over to the newly deployed version.

However, after we enabled authentication to protect our app, we now receive the following error using the SwapWithPreviewAction

Switch-AzureRmWebAppSlot : Swap with Preview cannot be used when one of the slots has site authentication enabled.
At line:3 char:19
+ ... e-Command { Switch-AzureRmWebAppSlot -SourceSlotName "staging" -Desti ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Switch-AzureRmWebAppSlot], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.DeploymentSlots.SwitchAzureWebAppSlot

Does anyone know if it is possible to run swaps with authentication enabled? If so, how?

1

1 Answers

1
votes

If you are using Authentication Authorization you can't 2 stage swap (aka swap with preview) however you should be able to do regular swap.

The main reason here is that Authentication/Authorization feature relies on having the right hostnames configured so that requests can be redirected back to the application after the authentication handshake.

This is also the reason why authentication/authorization is sticky to the slot.

EDIT I have included a screenshot that shows the error the API generates for this operation.

enter image description here