咨询Azure App Service维护过程中InProc会话的状态变化与数据留存机制
Great question—let’s unpack this clearly, tying together how App Service’s OS update process works and the nature of InProc session state.
First, a quick recap of the App Service OS update flow you referenced:
- Updates are rolled out to empty, unused instances in the region first
- Your app is migrated from its current instances to these freshly updated ones
- The now-empty old instances get updated afterward
What Happens to InProc Sessions?
Short answer: Yes, InProc sessions will be lost during this migration.
Here’s why:
- InProc session state is stored directly in the memory of the specific app instance handling your user’s request. It’s tightly bound to that single server’s process.
- When App Service migrates your app to a new updated instance, the new instance has no access to the memory of the old instance. Any session data stored there stays behind on the old instance, which will eventually be taken offline for updating.
Is There a Session Mirroring Mechanism?
Nope—App Service doesn’t offer any built-in session mirroring for InProc state. This makes sense for a few reasons:
- InProc is designed to be lightweight and fast, relying on in-memory storage without extra overhead. Mirroring across instances would add significant complexity and performance costs.
- The core assumption of InProc state is that it’s tied to a single instance. If you need session persistence across instance changes (whether from maintenance, scaling, or failover), InProc isn’t the right tool for the job.
What’s the Alternative?
If you need session data to survive instance migrations or maintenance, switch to a distributed session storage solution that’s decoupled from individual app instances. Popular options for Azure App Service include:
- Azure Redis Cache: Fast, in-memory distributed cache that’s ideal for session state. It’s highly available and works seamlessly with ASP.NET/.NET apps.
- Azure SQL Database: Stores session data in a relational database, good for scenarios where you need persistent, queryable session data.
- Azure Cosmos DB: A NoSQL option for global-scale, low-latency session storage.
Even beyond maintenance, using InProc state in multi-instance App Service environments is risky—load balancers can route users to different instances mid-session, causing unexpected session loss. Distributed storage eliminates this problem entirely.
内容的提问来源于stack exchange,提问作者Chris Pont

