azure - 使用旧配置的 Windows Azure 缓存服务

标签 azure azure-caching

最奇怪的事情。我正在切换到 SDK v1.7 和新的 ACS,成功登录后出现这个奇怪的错误。它似乎与 Azure 缓存服务的 SessionState 提供程序有关。

我没有使用预览版,但我使用的是 SDK 1.7,并且我使用的是启用了预览版功能的 Windows Azure 帐户。

这就像 ACS/Cache Service SDK 深处的某些东西被搞乱了。

这是我的缓存配置:

  <dataCacheClients>
    <dataCacheClient name="default">
      <tracing sinkType="DiagnosticSink" traceLevel="Verbose" />
      <hosts>
        <host name="[[newCacheNamespace]].cache.windows.net" cachePort="22233" />
      </hosts>
      <securityProperties mode="Message">
        <messageSecurity authorizationInfo="[[secret]]">
        </messageSecurity>
      </securityProperties>
    </dataCacheClient>
    <dataCacheClient name="SslEndpoint">
      <tracing sinkType="DiagnosticSink" traceLevel="Verbose" />
      <hosts>
        <host name="[[newCacheNamespace]].cache.windows.net" cachePort="22243" />
      </hosts>
      <securityProperties mode="Message" sslEnabled="true">
        <messageSecurity authorizationInfo="[[secret]]">
        </messageSecurity>
      </securityProperties>
    </dataCacheClient>
  </dataCacheClients>

这是我的 session 状态提供程序配置:

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
    <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" dataCacheClientName="default" />
  </providers>
</sessionState>

以下是我收到的错误:

Server Error in '/' Application.
--------------------------------------------------------------------------------

The remote name could not be resolved: '[[oldCacheNamespace]]-cache.accesscontrol.windows.net' 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote name could not be resolved: '[[oldCacheNamespace]]-cache.accesscontrol.windows.net'

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[WebException: The remote name could not be resolved: '[[oldCacheNamespace]]-cache.accesscontrol.windows.net']
   System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data) +1243
   System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data) +179
   Microsoft.ApplicationServer.Caching.AcsHelpers.GetToken(String serviceNamespace, String acsHostName, String issuerName, String issuerKey, String appliesTo) +523

[DataCacheException: ErrorCode<ERRCA0030>:SubStatus<ES0001>:ACS request for token failed. One of the reasons could be an invalid authorization token.]
   Microsoft.ApplicationServer.Caching.AcsHelpers.GetToken(String serviceNamespace, String acsHostName, String issuerName, String issuerKey, String appliesTo) +1875
   Microsoft.ApplicationServer.Caching.ClientAcsSecurity.get_Token() +242
   Microsoft.ApplicationServer.Caching.CacheResolverChannel..ctor(CacheResolverCommunicatorType communicatorType, IDuplexSessionChannel innerChannel, DataCacheSecurity dataCacheSecurity) +559

[CommunicationException: ErrorCode<ERRCA0030>:SubStatus<ES0001>:ACS request for token failed. One of the reasons could be an invalid authorization token.]
   Microsoft.ApplicationServer.Caching.CacheResolverChannel..ctor(CacheResolverCommunicatorType communicatorType, IDuplexSessionChannel innerChannel, DataCacheSecurity dataCacheSecurity) +833
   Microsoft.ApplicationServer.Caching.CacheResolverChannelFactory`1.System.ServiceModel.Channels.IChannelFactory<TChannel>.CreateChannel(EndpointAddress to) +274
   Microsoft.ApplicationServer.Caching.EndPointIdentityChannelFactory`1.System.ServiceModel.Channels.IChannelFactory<TChannel>.CreateChannel(EndpointAddress to) +186
   Microsoft.ApplicationServer.Caching.WcfClientChannel.CreateChannel(EndpointID endpoint) +557
   Microsoft.ApplicationServer.Caching.ChannelContainer.CreateChannel() +153

[DataCacheException: ErrorCode<ERRCA0017>:SubStatus<ES0006>:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.)]
   Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody) +693
   Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCacheProperties(RequestBody request, SimpleSendReceiveModule sendRcvModule) +1194
   Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +701
   Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
   Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +356
   Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +447
   Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +315
   Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout) +59
   System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext) +182
   System.Web.SessionState.SessionStateModule.CompleteAcquireState() +374
   System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +2007
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +477
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +312

最佳答案

这是一个老问题,但将来可能有人会遇到这个问题。

修复方法是:

  1. 删除 元素。
  2. 相反,添加此元素:

    < autoDiscover isEnabled="true"identifier="[[newCacheNamespace].cache.windows.net"/>

就是这样

关于azure - 使用旧配置的 Windows Azure 缓存服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11728809/

相关文章:

Azure 建议 API 的参数

azure - 在 Debian9 上安装 Azure IoT Edge

azure - Sql-Azure 上的重复超时

azure - 无法从本地计算机 ping 到 azure vnet

asp.net-mvc - 提供者必须实现类 'System.Web.SessionState.SessionStateStoreProviderBase'

azure - 连接到 Azure Redis 缓存

azure - 将开发测试实验室虚拟机移动到另一个开发测试实验室

asp.net - 多个实例使用共置缓存但无法访问,需要良好的命名缓存实现

azure - 无法加载文件或程序集 Microsoft.ApplicationServer.Caching.Core

c# - 在 Azure 缓存中存储大于 8MB 的对象的技术