4
votes

Azure app services have a testing in production setting, that allows you to route traffic to different slots, Scott Hanselman talks about it here

But - when I'm done, and I want to stop traffic from routing between different slots, how can I turn it off and disable it entirely, so that ALL traffic goes back to my production slot? Using the azure portal, I can route all 100% of traffic back to my "production" slot, but because it's cookie based (there is a cookie called x-ms-routing-name that sets the current slot that users are stuck to), it only works for new traffic - users that are already routed to another slot stay routed to it.

Is it possible to "turn off" this feature entirely and get all traffic back to my main production slot?

2

2 Answers

2
votes

there is a cookie called x-ms-routing-name that sets the current slot that users are stuck to

The x-ms-routing-name could let you to route requests to a specific slot.

To reroute users to a specific slot using it, you must make sure that the slot is already added to a Traffic Routing list.

You could use the following link in your web page to let uses opt out of your beta app:

<a href="<webappname>.azurewebsites.net/?x-ms-routing-name=self">Go back to production app</a>

The string x-ms-routing-name=self specifies the production slot.

Once the client browser access the link, not only is it redirected to the production slot, but every subsequent request will contain the x-ms-routing-name=self cookie that pins the session to the production slot.

For more details, you could refer to this article.

0
votes

If you have the "routing rules" parameter of an AppService configured, you will get the x-ms-routing-name header.

As a shortcut, you can remove the number 0 in the Azure Portal.

No header <-- This will remove the header completely

With header <-- This will enable the header, but never route to the other slot.

You can also null the whole section routingRules, e.g. via https://resources.azure.com.

      "type": "Microsoft.Web/sites/config",
      "location": "West Europe",
      "properties": {
        "routingRules": [
          {
            "actionHostName": "mysite-myslot.azurewebsites.net",
            "reroutePercentage": 4,
            "changeStep": null,
            "changeIntervalInMinutes": null,
            "minReroutePercentage": null,
            "maxReroutePercentage": null,
            "changeDecisionCallbackUrl": null,
            "name": "myslot"
          }
        ],

If you disable the setting completely, you have to wait about a minute. Then the AppService will start ignoring the x-ms-routing-name header, even if clients still have it pointing to your staging slot.