Showing posts with label design pattern. Show all posts
Showing posts with label design pattern. Show all posts

Friday, March 29, 2013

How to enable MS Dynamics CRM 2011 to integrate with Windows Azure

Hi,

I'm writing this article to explain a good architecture design for integrating your Microsoft Dynamics CRM 2011 with windows azure.

Let's  say you have on-premise CRM 2011 instance, and you want to use Windows Azure Blob storage to store Customer's documents on the cloud. How would you do that ?

The example i'm giving is applicable to any other windows azure service such as: SQL Azure, Mobile Notification Service, AppFabric Features..etc.

Since Windows azure is a scalable Cloud platform, you can easily integration your CRM 2011 with the windows azure on the cloud in 4 main steps.

Before going through the details, I'd like to explain the architecture of the proposed solution.

MS CRM 2011 has a backend windows service called "CRM Asynchronous Service" this is the component that will be in charge to communicate with the windows azure through a service bus.

MS CRM 2011 has 2 types of plugins, out-of-the box (OOB) and custom plugins. The OOB plugins runs  with full trust but the custom plugins runs with partial trust, and we will develop a custom plugin to connect to a listener through azure service bus.

The solution has the following components:

1) Configure CRM to be Windows Azure Aware.

2) We need to configure a service bus on Azure with an endpoint to communicate with the CRM server.

3) A listener hosted in Windows Azure to communicate with the asyncrhounous service, specificially listening to CRM assembly "Microsoft.Xrm.Sdk" with RemoteExecuteContext defined. so we need to develop a listener and deploy it on windows azure.

4) A custom CRM Plugin to communicate with the Windows Azure Listener.


How To accomplish, configure and develop this solution:

1) To accomplish step 1 , "Configure CRM for Integration with Windows Azure" :
http://technet.microsoft.com/en-us/library/gg328249.aspx

2) To accomplish step 2, "Configure Windows Azure ACS on Azure" :
http://technet.microsoft.com/en-us/library/jj863635.aspx

3) How to write a windows azure listener:
http://technet.microsoft.com/en-us/library/gg309615.aspx

C# Sample code - Listener:
http://technet.microsoft.com/en-us/library/gg309657.aspx

4) To accomplish step 4, "How to write Azure Aware CRM Plugin":
http://technet.microsoft.com/en-us/library/gg328194.aspx

Note, if you want to develop a custom workflow activity:
http://technet.microsoft.com/en-us/library/gg327854.aspx

Registration step - FINAL:
http://technet.microsoft.com/en-us/library/gg328524.aspx


**Here is some sample code for all what i mentioned above "listeners & plugins":
http://technet.microsoft.com/en-us/library/gg334712.aspx

Note: you should be having CRM SDK and Windows Azure SDK 1.7 or higher to be able to exercise and develop the solution.

Hope this helps.


Reference:
-Azure Extensions for Microsoft Dynamics CRM 2011:
http://technet.microsoft.com/en-us/library/gg309276.aspx



 

Sunday, December 02, 2012

Asynchronous Programming in C# - async/await


Asynchronous Programming in C# - async/wait

Hi Folks,

I want to share with you an important enhancement in .NET framework 4.5. The asynchronous programming paradigm for .NET developers using new C# keywords async/await. Since I'm C# developer; I will be highlighting this new design pattern keywords in C# for asynchronous programming which is async/await which is supported only starting from .NET framework 4.5.

what's async/await for C#?

Async is a new modifier in C# 4.5. async specifies to the compiler that the method is executing in asynchronous mode and not synchronous.

For example - C# Code:

async Task Sum(int x, int y) {
// your method implementation.
}

The async method returns a Task object or doesn't return any objects and this case you will write void instead of Task object.

The async method doesn't allow input parameters by reference or output.

The  async method has to contain a line to call the async method by using await operator.

For example - C# Code:
private async void btnAdd_Click(object sender, RoutedEventArgs e)
{
     int x=10,y=15,z=0;
    // The complier will call Sum asynchronously and return the value in z.
    z=await Sum(x,y);
 }


An async method provides a convenient way to perform potentially long-running processing without blocking the caller's thread.

The caller of an async method can resume its work without waiting for the async method to finish which makes your application more responsive and user friendly.


Read more about async/await from MSDN:
http://msdn.microsoft.com/en-us/library/hh156513(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/hh156528.aspx

Hope this helps.

-ME