Configure Azure Cache (<dataCacheClients>...) of WebRole in cscfg file?

946 Views Asked by At

Currently, I have my Azure Cache configuration

<dataCacheClients>
  <dataCacheClient name="default">
    ...

inside my Web.config of my Azure WebRole. I would like to be able to easily modify the Azure Cache settings after the cspkg package has been created, i.e. I would like to move the configuration into the cscfg file.

I don't think that's possible without hand-coding all the possible configuration options of Azure Caches (and then interpreting those options and setting the configuration programmatically in the DataCacheFactory). Am I overlooking something?

2

There are 2 best solutions below

1
On

in webrole (RoleEntryPoint derived class) onstart, you could overwrite web.config caching part with the relevant settings from your .cscfg file

also add eventhandler to the environment changing (RoleEnvironment.Changing += RoleEnvironmentChanging;) with e.Cancel = true so that the webrole restarts when ever you change .cscfg @ the management portal

2
On

One walkarround is to rename your .cspkg file to .zip file. Then unzip the file and take a look to the files. You will find .cssx files (the larger files) representing each webrole / working role. rename to .zip and expand. Then you will find a "approot" folder. Your dlls, webconfig, etc are there. You can mess with the webconfig and zip+rename the way back.

It's not elegant at all, but sometimes is the best way to figure out what exactly are you publishing.