Search code examples
azureazure-caching

Authorization token passed by user Invalid. Azure Cache


Maybe I'm misunderstanding how to create a cache but none of the the IDs or Access keys is working on the to enable the azure cache. I've gone through the following tutorials:

http://msdn.microsoft.com/en-us/library/windowsazure/gg618003.aspx

http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_buildingappswithcacheservice_topic3#_Toc310505080

http://msdn.microsoft.com/en-us/library/windowsazure/gg618003.aspx

And about 1/2 a dozen different how to create a cache in azure pages and I'm still getting.

Authorization token passed by user Invalid.

I've got a website and cloud service with linked storage and nowhere can I find a url "yourcachename.cache.windows.net" or an Authentication Token in the manage Azure portal. Any suggestions would be greatly appreciated.


Solution

  • It turns out that I was getting confused between versions of Azure. I'm not sure what version this started in but I was working in 1.8 and I did not need an access key. Once I added the below sections to the web.config everything worked.

      <dataCacheClients>
        <dataCacheClient name="default">
          <autoDiscover isEnabled="true" identifier="{your cache worker role}" />
          <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
        </dataCacheClient>
      </dataCacheClients>
      <cacheDiagnostics>
    

    And then in order to get Sessions to work I needed to add this:

       <sessionState mode="Custom" customProvider="AFCacheSessionStateProvider">
          <providers>
            <add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState"/>
          </providers>
        </sessionState>