I have been battling to get in-role, co-located caching (not dedicated) working in Azure.
In my MVC WebApi 2 project's web.config
:
<configSections>
<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
...
<dataCacheClients>
<dataCacheClient name="default" isCompressionEnabled="true">
<autoDiscover isEnabled="true" identifier="MyWebApiProject" />
<clientNotification pollInterval="300" />
<transportProperties maxBufferSize="1073741824" maxBufferPoolSize="1073741824"/>
</dataCacheClient>
</dataCacheClients>
Cache property setting on the role:
I got the following exception thrown in Azure:
Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode:SubStatus: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.). Additional Information : The client was trying to communicate with the server: net.tcp://MyWebApiProject:24233.
When I turn autoDiscover
off, like this:
<autoDiscover isEnabled="false" identifier="MyWebApiProject" />
Then I get a different exception:
Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode:SubStatus:Server collection cannot be empty.
I don't have any problems when running locally using the Compute Emulator.
Once I upgraded my Azure SDK from 2.2 to 2.3, this problem stopped occurring.