Everyone in my company has its own cache in Azure and we want to take it away the cache settings from Web.config so we can stop using web.config transforms (Thats what we actually do).
So, I am trying to move the configuration of the Cache from web.config to code.
I found this, and tried and we get the cache in the cache variable. :
string host = xxx.cache.windows.net;
string authorizationToken = "mySecretToken";
DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
config.AutoDiscoverProperty = new DataCacheAutoDiscoverProperty(true, host);
config.SecurityProperties = new DataCacheSecurity(authorizationToken);
DataCacheFactory factory = new DataCacheFactory(config);
DataCache cache = factory.GetCache("default");
But I get this error:
ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.
and this is the stack trace:
[DataCacheException: ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.]
Microsoft.ApplicationServer.Caching.DataCacheFactory..ctor(DataCacheFactoryConfiguration configuration) +531
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFactoryFromConfiguration(DataCacheFactoryConfiguration config) +77
Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +273
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.CreateInternalProvider(IHttpRuntime httpRuntime, OutputCacheInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +399
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.GetInternalProvider() +315
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.Get(String key) +54
System.Web.Caching.OutputCache.Get(String key) +85
System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs eventArgs) +341
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
Does anybody know how to solve this?
Thanks in advance,
Jon
Aucun commentaire:
Enregistrer un commentaire