Azure(免费F1 WebApp)会话管理 [英] Azure (Free F1 WebApp) Session Management

查看:80
本文介绍了Azure(免费F1 WebApp)会话管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免费的F1 WebApp ASP.NET是否有可用于演示配置的快速,廉价,可靠的会话状态机制?

我知道Windows Azure会话管理已在SO上进行了很多讨论,但是这个特殊的配置问题似乎无处可寻.

I know Windows Azure Session management is discussed a lot on SO, but this particular configuration issue seems to slip through the cracks.

可用的配置选项似乎是:

The available configuration options seem to be:

  • InProc模式:不建议在云中使用,但对于单个实例Azure F1 WebApp,从理论上讲,它对于演示网站应该是可靠的.但是,我的经验是,会话会意外地超时,并且与web.config文件中的设置无关.

  • InProc mode: Not recommended in the cloud but for a single instance Azure F1 WebApp it should, in theory, be reliable for demonstration websites. However, my experience is that the sessions time out unpredictably and have no bearing on the settings in the web.config file.

Azure Redis缓存:推荐但不支持Free F1 WebApp;需要升级付费计划.(参考: https://azure.microsoft.com/en-gb/定价/详细信息/缓存/)

Azure Redis Cache: Recommended but not supported for Free F1 WebApps; an upgrade to paid plan is required. (Reference: https://azure.microsoft.com/en-gb/pricing/details/cache/)

Azure SQL:不推荐或不支持.**如果您已经在运行Azure SQL服务器,这似乎是一个可行的选择.参考: https://azure.microsoft.com/en-gb/blog/using-sql-azure-for-session-state/.不幸的是,我发现无法找到经修改的InstallSqlState.sql,并且所有下载链接均失败(示例: https://support.microsoft.com/zh-CN/kb/2006191 ).**通用Web提供商可以提供解决方案(参考:blog/IntroducingSystemWebProvidersASPNETUniversalProvidersForSessionMembershipRolesAndUserProfileOnSQLCompactAndSQLAzure.aspx ),但目前尚不清楚-至少对我来说-它们是否提供会话管理支持以及SQL Server连接支持.

Azure SQL: Not recommended or supported. ** This would seem to be a viable option if you already have an Azure SQL server running. Reference: https://azure.microsoft.com/en-gb/blog/using-sql-azure-for-session-state/ . Unfortunately I have found the amended InstallSqlState.sql impossible to find and all links to downloads fail (Example: https://support.microsoft.com/en-us/kb/2006191). ** Universal Web Providers may offer a solution (Refernce:http://www.hanselman.com/blog/IntroducingSystemWebProvidersASPNETUniversalProvidersForSessionMembershipRolesAndUserProfileOnSQLCompactAndSQLAzure.aspx) but it is unclear - at least to me - whether these offer Session management support as well as SQL Server connection support.

Azure表存储:一个潜在的选择,但由于所有链接都断开了,因此似乎是一种过时的解决方案.(参考:

Azure Table Storage: A potential option, but seems to be an out-of-date solution as all links are broken. (Reference:https://www.simple-talk.com/cloud/platform-as-a-service/managing-session-state-in-windows-azure-what-are-the-options/). I've never used Azure Tables so this seems esoteric.

StateServer:免费的F1 Webapp无法使用.大概需要一个虚拟机.

StateServer: Not possible with a Free F1 webapp. Presumably a virtual machine would be required.

自定义:是的,这可以工作.** Redis Cache是​​一个自定义会话管理器,因此我认为可以使用另一个.**替代的AppFabric(参考: ASP.NET会话状态提供程序在Azure中)似乎不再受支持,而是一种付费解决方案.**也许还有其他尚未研究的自定义解决方案可用.

Custom: Yes, this would work. **Redis Cache is a custom session manager, so I presume another one could be used. **The alternative AppFabric (Reference: ASP.NET session state provider in Azure) no longer seems to be supported and was a paid solution. **Perhaps there is an alternative custom solution available I haven't researched yet.

Azure缓存服务和基于角色的缓存:2016年11月30日停用.(参考:

Azure Cache Service and Role Based Cache: Retired November 30, 2016.(Reference:https://azure.microsoft.com/en-gb/documentation/articles/cache-faq/#which-azure-cache-offering-is-right-for-me).

在我看来,最根本的是没有.如果有人可以证明我的看法,我将不胜感激.

The bottom line seems to me that there isn't. I would really appreciate it if someone could prove otherwise.

我整天都在思考和修改.到目前为止,我的发现是:

I've been thinking about and tinkering with this throughout the day. My findings so far are:

1)升级到D1 WebApp服务计划可以大大提高会话状态管理的可靠性,但是仍然容易发生不可预测的情况.正如Hrvoje Hudo在下面指出的那样,您无法期望免费"或共享"的可靠性.

1) Upgrading to the D1 WebApp service plan improves the reliability of the session-state management considerably but it is still prone to unpredictability. As Hrvoje Hudo points out below you can't expect reliability with Free or Shared.

2)安装ASP.NET通用提供程序似乎是一种解决方案.我使用MSVC2013创建了一个新的MVC WebApp项目,选择了Azure托管,键入:

2) Installing ASP.NET Universal Providers would seem to be a solution. I created a new MVC WebApp project using MSVC2013, selected Azure hosting, typed:

install-package Microsoft.Aspnet.Providers 

在软件包管理控制台中的

中添加了:Session ["Time"] = DateTime.Now.ToString()到主页索引"视图,并在about视图中使用

in the package management console, added: Session["Time"]=DateTime.Now.ToString() to the Home Index view and referenced it in the about View using:

ViewBag.Message = Session["Time"] 

并将web.config更新为:

And updated the web.config to:

<sessionState mode="Custom" customProvider="DefaultSessionProvider"  timeout="1">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=Whatever" connectionStringName="DbaseName"/>
  </providers>
</sessionState>

发布网站时,默认的数据库是在Azure SQL Server上创建的,这要归功于publish scripts.json,其中包含我的所有配置设置并将它们交换进来,并且在数据库上创建了dbo,session表.

When I publish the website the default database is created on my Azure SQL Server, courtesy of the publish scripts.json containing all my config settings and swapping them in, and a dbo,session table is created on the database.

浏览到该网站后,新会话将在数据库表上创建-我可以使用MS Management Studio 2013查看它们-超时(60s +)后将其删除.

Browsing to the website, new sessions are created on the database table - I can see them using MS Management Studio 2013 - and deleted after they time out (60s+).

我将网站降级为免费"(以确保默认情况下未将其配置为更高的计划,而MSVC曾经这样做),并且一切似乎仍然正常.这似乎是我想要的.

I downgraded the website to Free (to be sure it wasn't configured to a higher plan by default, which MSVC used to do) and everything still seems to work. This seems to be what I was looking for.

3)Azure表.这些还无法解决!如果有人知道一个好的如何"教程,我很乐意看一下.

3) Azure Tables. Can't get my head around these yet! If anyone knows of a good "how to" tutorial I'd love to look at it.

经过一天的浸泡测试,我现在90%的人相信ASP.NET Universal Providers是实现快速&的方法.使用免费的Azure Web App进行可靠的会话.我不能说它是免费的,因为必须为SQL Server付费(Basic =〜£4pm参见:

After a day's soak testing I'm now 90% convinced ASP.NET Universal Providers is the way to go for quick & reliable sessions using a Free Azure Web App. I can't says it's free, as the SQL Server must be paid for (Basic = ~£4pm See: https://azure.microsoft.com/en-gb/pricing/details/sql-database/) , but it's certainly not expensive, and if you're using an SQL Server anyway - like me - it makes sense.

推荐答案

没有银色项目"会话状态,这就是为什么您拥有所有这些选项,选择最适合您的需求和业务案例的原因.对于免费的Web应用程序,您不能期望获得可靠的服务,Azure会定期重新启动您的应用程序池,并且有很多限制,因此默认InProc可能会成为问题-但是您仍在使用免费层.因此,由于您想节省几块钱-花费时间来编写自己的文件,该文件使用Azure存储(表或Blob,我将使用表)或其他某种存储机制.

There's no "silver bullet" session state, that's why you have all those options, chose what fits best with your requirement and business case. For Free web app you can't expect reliable service, Azure will restart your app pool regularly and there are lot of limits, so default InProc can be an issue - but again you're using Free tier. So since you want to save few bucks - invest time into writing your own, which uses Azure Storage (table or blob, I would use Table) or some other storage mechanism.

这篇关于Azure(免费F1 WebApp)会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆