ASP.NET Core

Moving Off Windows Server 2016? Take Your Data Protection Keys With You

Mitchel Sellers Mitchel Sellers
ASP.NET Core

Windows Server 2016 reaches end of extended support on January 12, 2027, and ASP.NET Core apps that move to new servers or Azure can lose their Data Protection key ring and sign every user out. The post shows how to find where the keys live today, give them a machine-independent home, and make the cutover uneventful.

Key points

  • Default key locations: App Service %HOME% folder, %LOCALAPPDATA% protected by DPAPI, IIS HKLM registry, or memory only.
  • For IIS-hosted apps the application discriminator is the physical site path, so moving folders also breaks existing payloads.
  • Keys have a 90-day lifetime and rotate automatically; older keys stay in the ring so old data stays readable.
  • On Azure: PersistKeysToAzureBlobStorage plus ProtectKeysWithAzureKeyVault, a versionless Key Vault key ID and ManagedIdentityCredential.
  • On-premises: PersistKeysToDbContext with IDataProtectionKeyContext and ProtectKeysWithCertificate, with the certificate installed on every server.
  • A production startup guard throws when KeyManagementOptions.XmlRepository is null; SetApplicationName changes the discriminator.

Why it matters

Most teams never touched Data Protection because the defaults worked — until the machine underneath them changed. For IIS-hosted ASP.NET Core on Windows Server 2016 this is the migration item that appears in no checklist and fails silently: the app starts, users are simply logged out. One deployment now, in a quiet window, costs an hour; discovering it on cutover day costs a support queue.

Check your package set before copying the code — Microsoft.AspNetCore.DataProtection.AzureStorage and .AzureKeyVault are superseded by the Azure.Extensions packages — and look for your own code that stores protected payloads in a database. That case needs a project, not an hour.

Real-world use

  • A team moving an ASP.NET Core portal off Windows Server 2016 to a newer server or Azure App Service
  • A production App Service deployment where a staging-to-production slot swap signs users out
  • Apps whose own code stores protected values in a database and must re-protect them before the switch
  • Password reset and email confirmation links that have to survive a server change

This summary was generated by the agent from the original post on Mitchel Sellers. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message