简体   繁体   English

在 Azure 的 Application Insights 中记录 session state Redis 的缓存

[英]Logging session state in Application Insights for Azure Cache for Redis

I'm working on ASP.NET web application connected to Azure. Is it possible to see not only common data about connected clients and expired keys, but also more detailed logs per session (some session state info as session ID, ect.) current data in Insights for Azure Cache for Redis I'm working on ASP.NET web application connected to Azure. Is it possible to see not only common data about connected clients and expired keys, but also more detailed logs per session (some session state info as session ID, ect.) current data in Azure 的见解 Redis 的缓存

在此处输入图像描述

I configured session state storing in the cache as in this topic , but can't find information I needed.我按照本主题配置了 session state 存储在缓存中,但找不到我需要的信息。

Check the below steps to view the Session Info in ASP.Net Application for Azure Cache for Redis.检查以下步骤以查看 Azure 的 Redis 的ASP.Net应用程序中的 Session 信息。

  • Created ASP.Net Application in Visual Studio.在 Visual Studio 中创建ASP.Net应用程序。
  • Copy the Hostname from Azure Redis Cache Properties .从 Azure Redis 缓存Properties复制Hostname

在此处输入图像描述

  • And Password (access Key) from Redis Cache => Access Keys => Primary Key .和来自 Redis Cache => Access Keys => Primary Key的密码(访问密钥)。

在此处输入图像描述

My Web.config file:我的Web.config文件:

'<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="***.redis.cache.windows.net,abortConnect=false,ssl=true,allowAdmin=true,password=***"/>

  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.8" />
    <httpRuntime targetFramework="4.8" />
    <sessionState mode="Custom" customProvider="MySessionStateStore">
      <providers>       
        <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="***.redis.cache.windows.net" accessKey="***" ssl="true" />
      </providers>
    </sessionState>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <system.webServer>
    <modules>
      <remove name="Session" />
      <add name="Session" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync, Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode" />
    </modules>
  </system.webServer>
</configuration>
  • Publish the Code to Azure App Service.将Code发布到Azure App Service。
  • Enable Application Insights while Publishing to Azure itself.发布到 Azure 本身时启用 Application Insights。

在此处输入图像描述

  • In your deployed Application make sure Application Insights is Enabled.在您部署的应用程序中,确保启用了Application Insights

在此处输入图像描述

  • You can see the No. of sessions in Application Insights => Sessions .您可以在Application Insights => Sessions中看到会话数。

在此处输入图像描述

  • If you click on View More Insights tab, we will get the below data.如果您单击“ View More Insights选项卡,我们将获得以下数据。

在此处输入图像描述

  • Click on View session timeline to get the session ID.单击View session timeline以获取 session ID。

在此处输入图像描述

在此处输入图像描述

Reference taken from MSDoc .参考资料取自MSDoc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM