Saturday, February 22, 2014

Definitive steps to configure MSDTC on Azure virtual machines – without need of domain controller


MSDTC – Microsoft Distributed Transaction.

I had requirement to configure Azure Virtual machine with SQL Server 2008 R2 and One Azure Virtual machine as an application server having few sites hosted on it. Azure virtual machine app server hosted application should be able to connect to SQL server and run SQL queries with transactions. Unfortunately transaction queries were not working in my environment set up.

The problem is, for transaction to work between SQL server and application server you need to have MSDTC to be configured on both machines. Everywhere I read through many posts that for configuring MSDTC, settings related to AD DC (domain controller) is required. However my azure virtual machines were not in any domain neither any one of them was treated as DC.

Hence I tried to configure MSDTC on azure virtual machines without domain configuration and it was successful.
Following steps will guide through the steps required to enable MSDTC on Azure virtual machines. Please note that the azure virtual machines do not have any domain configured on them neither they are not part of any domain.

I have 2 azure virtual machines with following configuration –

1.     SQL Server 2008 R2

2.     Windows Server 2008 R2 – call it as app server

Now I need to configure MSDTC on SQL server and app server.

At first you need to configure Azure virtual network as per the guidelines mentioned at this post.

Then provision Azure virtual machines with above configuration using the steps mentioned at this post in the virtual network you created above.

Now RDP to both Azure Virtual machines from the steps mentioned in this post.

Then on SQL server make configuration settings mentioned on this post - http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-provision-sql-server/#SSMS

Then log in to App server and follow below steps.

***MSDTC configuration***

Select Open Control Panel -> System and Security -> Allow a program through windows firewall option as shown below.

Monday, February 10, 2014

Automated deployment of .rdl files to SQL Server 2012 Reporting Services using c# and Reporting web Service of SSRS 2012

I was searching for automated deployment of .rdl [report definition language] files on SSRS reporting server 2012. Everywhere I found the reporting service example which was prior to 2012. Following code illustrates how we can deploy .rdl files to SSRS 2012. 

SSRS 2012 report service has URL same as 2010. Therefore the report service URL will be as follows –

http://ServerNameHavingSQL2012:PortNumber/reportserver/reportservice2010.asmx

If you have hosted reporting service on default port 80 then you don’t need to provide PortNumber in above URL. I have written a class to make automated deployment of .rdl files. Let’s call it as RDLDeployer. I have added a public method which takes string parameter. This string parameter can be the path of .rdl file to be deployed on SSRS 2012.

First add reference of SSRS web service in your application. Then use following code to deploy the .rdl file on report server 2012.
Steps are as follows –

Sunday, February 9, 2014

How to call private method of one class in another class in C#


Sometimes you may want to call the private method declared in one class in another class in c#. Technically it is not possible to access private members of a class outside the class in c#. Either you will need to modify the access specifier of the class member from private to something else.  However if say you are not allowed to change the access specifier of private method but still want to provide a mechanism to enable calling of private method in another class? How can w achieve this in c#? It is very well possible in C# with the help of Delegates. 

Delegates are nothing but pointer to method. If you want to get value of private variable, we can declare a public property similarly if you want to call private method outside the declaring class we can use public property returning delegate (or pointer to the method).

Following construct depicts how delegates can be used to access private method outside a class. Let’s say I have a class A having private method as below –

Wednesday, January 22, 2014

Azure auto scaling based on CPU usage tutorial



Windows Azure has come up with built in Auto Scale feature on Azure Management Portal. Azure Auto Scale block can be used to perform this however one should use auto scale feature provided on Azure Management Portal itself.
An Azure hosted worker role can be auto scaled based on number of message in the Queue storage or based on CPU usage. If suppose you wish to autoscale the azure worker role based on CPU usage then to understand how it works I created following code. The code snippet given below actually performs heavy operations on Worker Role due to which the CPU usage on Azure Worker Role VM increases. Then the following screenshot depicts that how auto scale feature can be configured from Azure Management Portal.
Following code you can put within Run method within while loop having true condition -