Posts Tagged ‘Appfabric’

If you are new to appfabric you may not know about Windows Server AppFabric Configuration Wizard.Hence I am posting this here :)The AppFabric Configuration Wizard enables you to configure the AppFabric hosting and caching features.You can invoke the AppFabric Configuration Wizard from the Installation results page of the AppFabric Setup Wizard or by clicking Start, All Programs, Configure AppFabric.

This gives you more information on the same


Once you are done with configuring caching features of AppFabric,you can manage those with the help of Caching Administration Windows PowerShell.Go to the Start Menu, click All Programs, Windows Server AppFabric, and then right click Caching Administration Windows PowerShell & select Run as administrator.Several commands are available to perform cluster-related operations & you can read more on those here

 Start-CacheCluster command as shown in image starts all cache services in the cluster.

If you remember some days ago I posted about Web Platform Installer (3.0)
which can help you in installations.If you havent downloaded yet,do it from here .

Once you are done with Web Platform Installer installation,choose Products tab & type Appfabric in the search box – select Windows Server AppFabric & click Install.You are done 🙂

The following Windows Firewall rules need to be configured to let the AppFabric Distributed Cache features to work.

  • Remote Service Management 
  •  Windows Server AppFabric: AppFabric Caching Service

 If you are new to Windows 7 & not sure about how to configure firewall rules,please take a look at the following article 

Hope this helps!

 When you choose XML as your Appfabric Caching Service provider,configuration information is stored in an XML file on a network file share.Make sure that you create a shared folder in your server & browse to this folder or type in a UNC server share for example, \\server\share

If you do not configure it this way & simply click on next in the wizard,later when you try starting the cache cluster windows powershell will not recognize any of the commands as you have not configured it completely.

Once you are done with all configurations,you will be able to see a xml file named ClusterConfig inside the folder mentioned with content similar as below

<?xml version="1.0" encoding="utf-8" ?>
- <configuration>
- <configSections>
  <section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
- <dataCache size="Small">
- <caches>
- <cache consistency="StrongConsistency" name="default">
- <policy>
  <eviction type="Lru" />
  <expiration defaultTTL="10" isExpirable="true" />
- <hosts>
  <host replicationPort="22236" arbitrationPort="22235" clusterPort="22234" hostId="1038108123" size="1010" leadHost="true" account="AMERICAS\WN7-3M563BS$" cacheHostName="AppFabricCachingService" name="WN7-3M563BS" cachePort="22233" />
- <advancedProperties>
- <securityProperties>
- <authorization>
  <allow users="Anupama_roy" />

This has set up a cache with name default in your machine.I have downloaded a sample from microsoft appfabric samples & this below code from that sample explains how to make use of the cache.Before that from Caching Administration Windows PowerShell,grant access to your account as below

Grant-CacheAllowedClientAccount Anupama_roy

After this,start the cluster using ‘Start-CacheCluster’ command

public class CacheUtil
  private static DataCacheFactory _factory = null;
  private static DataCache _cache = null;
  public static DataCache GetCache()

      if (_cache != null)
          return _cache;
      // Configure Cache Client
      //Define Array for 1 Cache Host
      List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>(1);
      //Specify Cache Host Details
      //  Parameter 1 = host name
      //  Parameter 2 = cache port number
      servers.Add(new DataCacheServerEndpoint("WN7-3M563BS", 22233));
      //Create cache configuration
      DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration();

      //Set the cache host(s)
      configuration.Servers = servers;

      //Set default properties for local cache (local cache disabled)
      configuration.LocalCacheProperties = new DataCacheLocalCacheProperties();
      //Disable tracing to avoid informational/verbose messages on the web page
      //Pass configuration settings to cacheFactory constructor
      _factory = new DataCacheFactory(configuration);
      //Get reference to named cache called "default"
      _cache = _factory.GetCache("default");

    return _cache;

Add below code to your webpage

  private DataCache m_cache = null;
  protected void Page_Load(object sender, EventArgs e)
            m_cache = CacheUtil.GetCache();
            Order order = new Order();
            order.Id = Convert.ToInt32(OrderId.Text);
            order.Description = OrderDesc.Text;
            order.Amount = OrderAmt.Text;
            order.Quantity = Convert.ToInt32(OrderQuant.Text);
            //Add data to the cache
            m_cache.Add(OrderId.Text, order);


Exception: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. Ensure that security permission has been granted for this client account on the cluster and that the AppFabric Caching Service is allowed through the firewall on all cache hosts.
Retry later.)

If you are configuring appfabric cache client (local cache) & run into above exception,make sure that you have granted permission to the account using Grant-CacheAllowedClientAccount command from windows powershell .For running Caching Administration Windows PowerShell , you must right-click the shortcut and select Run as administrator.

Grant-CacheAllowedClientAccount Anupama_roy

After this,start the cluster using ‘Start-CacheCluster’ command

It took some time for me to figure out what went wrong when my application threw this exception.Hope this saves your time!