locked
Shared Azure DataCache Instantiation RRS feed

  • Question

  • I'm creating a new MVC app to pull data from an Azure Data Cache. However, as soon as i try and instantiate a DataCache object, my code just hangs indefinitely. I don't get an error or timeout, it just sits there trying to create the new object.

    At the moment my code is literally no more than:

    public ActionResult Index()
    {
    DataCache cache = new DataCache();
    Debugger.break;
    }

    I've also tried instantiating it with:

    DataCache cache = new DataCache("default");

    and:

    DataCacheFactory cacheFactory = new DataCacheFactory();
    DataCache cache = cacheFactory.GetDefaultCache();

    but they all result in the same problem.

    In each instance the code never gets past the first statment, it always hangs indefinitely. If I pause the debugger in visual studio I can see it pausing on the new DataCache() line so that's definitely where execution has stalled.

    My web.config has the section added by NuGet when I imported the new azure caching package as follows:

    <dataCacheClients>
    <dataCacheClient name="default">
    <!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
    <!--To use the Windows Azure Caching Service, set identifier to be the endpoint of the cache cluster -->
    <autoDiscover isEnabled="true" identifier="{{REMOVED}}" />
    
    <!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />-->
    
    <!--Use this section to specify security settings for connecting to your cache. This section is not required if your cache is hosted on a role that is a part of your cloud service. -->
    <securityProperties mode="Message" sslEnabled="false">
    <messageSecurity authorizationInfo="{{REMOVED}}" />
    </securityProperties>
    </dataCacheClient>
    </dataCacheClients>




    I've double checked the values in the web.config match with those in the Azure portal and they're oK.

    Does anyone know the cause of this? I'm guessing its something quite basic given how new it is.

    Thanks

    Saturday, September 7, 2013 12:35 PM

Answers

All replies

  • Hi eldeejay,
    Thanks for posting!
    When we use Azure Data Cache, we not only configure the “dataCacheClients”, but also configure it in the “configSections”( http://msdn.microsoft.com/en-us/library/windowsazure/dn448829.aspx ). If you make sure the configure is right, we need to pay attention to your usage of azure cache (http://msdn.microsoft.com/en-us/library/windowsazure/dn386135.aspx ). In my experience, when we use cache, we need to configure the “DataCacheFactoryConfiguration” class. Also, this code sample (http://code.msdn.microsoft.com/Windows-Azure-Cache-fa61f9ee ) may help you. Please try it.
    Thanks.

    Will
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 9, 2013 7:04 AM
  • The hang is related to the performance counter initialisation.

    I've fixed this by running the ClientPerfCountersInstaller.exe that gets added to your project when you install the Azure Caching NuGet package.

    Open a command prompt with administrative privileges and cd to this folder. Then run the installer with the command:

    ClientPerfCountersInstaller.exe install

    After that my project ran without hanging.

    Thursday, April 17, 2014 10:24 AM