Search code examples
azureasp.net-identityasp.net-coreazure-web-app-serviceasp.net-identity-3

Deploy WebApp to Azure with Zero downtime from VS2015


I'm trying to publish my web app from VS without no downtime. If you search in Google, you find the official documentation speaking about using slots and do a swap later.

This is a good approach, but I have other problem when I do the swap, logins are lost (look this question: link).

Relevant information in the link:

Session is not linked to Authentication, you're attempting to solve it in the wrong way.

All forms authentication tickets and cookies are encrypted and signed using the data protection layer. The problem you are encountering is due to the encryption keys not being saved, and applications being isolated from each other.

How can I do that? In AWS I had rolling updates...

For more information, I'm using ASP.NET Core with Identity 3.0

Thanks!!


Solution

  • What you're seeing is an azure limitation right now. While Azure Web Sites will share the key ring it sees swap slots as separate applications.

    There are a couple of things to try.

    First, set a common application name. This will help because every application which shares the keyring is isolated by default; but if they share the application name they can share keys

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDataProtection();
        services.ConfigureDataProtection(configure =>
        {
            configure.SetApplicationName("my application");
        });
    }
    

    If that's not enough for azure (I am honestly unsure if hot swaps end up using Azure Web App's shared key folder) you can combine that with using Azure Data Tables for storing the encryption keys - https://github.com/GrabYourPitchforks/DataProtection.Azure/tree/dev

    Between those two it should get the encryption keys used to protect identity cookies shared between your apps.