Tuesday, November 8, 2011

Deploying Windows Azure Application to Compute Emulator & Evaluating role configuration change in Compute Emulator (dev fabric)










Deploying Windows Azure Application to Compute Emulator

&

Evaluating role configuration change in Compute Emulator (dev fabric)

In earlier days if I wanted to see how the application is going to behave after we tweak the configuration values in .cscfg file I used to deploy them on azure to evaluate the code which deals with role environment change though it is time consuming and few bucks for azure usage. Later I found a way to evaluate all my code which deals with role environment change in local compute emulator (dev fabric) and started making most use out of it. There are plenty of azure command line tools availale, but at first cut I found this “csrun” tools as very handy. Here are the ways to deploy your cloud application to compute emulator, change configuration values and evaluate it.

To evaluating the role environment change events, we need to deploy the application either using csrun.

For this I have used an application called cloudplay, which has 1 worker role, 1 ASP.Net web role and 1 ASP.Net MVC 3 worker role.

In that worker role I have a setting called ‘setting1’ and will be this value as Trace Information in regular interval, this has been used to reflect changes happening in configuration file.

Deploying the application through CSRUN :

1. Open Windows Azure Command Prompt in Administrator Mode ( StartàAll Programs à Windows Azure SDK v1.5 àWindows Azure SDK Command Prompt )

2. Change the directory to where your csx and cscfg files are located

3. Once changed the directory execute the below command

csrun /run:cloudplay.csx;serviceconfiguration.cspkg /launchbrowser

Note: You can skip the /launchbrowser flag if you don’t have web role in the cloud service.

4. Look for the command prompt for deployment Id and note it down. (Shown above in the image)

5. Now open the Compute Emulator UI and see the instance count of ‘worker’ and trace information written as ‘arun’.


Note : I tried deploying it through VS and updated the configuration through CSRUN, it doesn’t work.

After the successful deployment we could modify the configuration anytime, for making the change and bringing them online refer the below steps.

1. After the successful deployment open the ServiceConfiguration in any text editor.


2. Modify any configuration setting’s value, save it. (For better understanding , change the role instance count of any role)

a. Preferably modify the setting1 value, save it. ( Here I have changed both instance count of ‘Worker’ and value of setting1.

3. Go to command prompt again, ensure you are in the same directory of service configuration file.

(If you are not in service configuration directory, you need to use the full path)

4. Now run the below command.

csrun /update:101;Serviceconfiguration.cscfg

5. Look the command prompt for configuration update messages

6. Open the compute emulator UI, and look new value of setting1 getting written into it. (If you modified the role instance count instead of modifying the setting1 , please look for the newly modified number of instance ).

Notice, after the updating the configuration now worker has 2 instances and its printing ‘arunprasad’ instead ‘arun’.

Likewise, you will be able to modify any configuration setting value.