c# - Fault Tolarent Web Role Initialization in Azure -


i have webrole runs wcf service. role accesses storage, queue, , tables. therefore, have connection strings , other settings kept in configuration files (names, timetolive etc).

assuming config files can change during runtime, want able reinitialize these settings. let's have webrole read config values while starting:

public class webrole : roleentrypoint {   public override bool onstart()   {     string connstring = cloudconfigurationmanager.getsetting("storageconnectionstring");   } } 

i have wcf service called myservice:

public myservice() {   cloudstorageaccount storageaccount = cloudstorageaccount.parse(connstring);   cloudqueueclient queueclient = storageaccount.createcloudqueueclient(); } 

i initialize storage client inside default constructor. how can pass setting read role service? way can make initiate service specific settings , have test coverage.

note: passing settings parameters not sound option (see this).

i suggest move azure code class , reference through interface this

public interface istoragecreator{         cloudqueueclient getqueueclient();      }       public class azurestoragecreator:iazurestoragecreator{        public cloudqueueclient getqueueclient(){             string connstring = cloudconfigurationmanager.getsetting("storageconnectionstring");             cloudstorageaccount storageaccount = cloudstorageaccount.parse(connstring);             cloudqueueclient queueclient = storageaccount.createcloudqueueclient();             return queueclient;        }     } 

and add dependency wcf service through injection, doing way can test service , fake like.

cheers.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -