Friday 13 July 2012

Microsoft Dynamics CRM 2011 - Introduction to Windows Azure Integration

Microsoft Dynamics CRM 2011 has been integrated with the Windows Azure platform by coupling the Microsoft Dynamics CRM event execution pipeline to the Windows Azure Service Bus in the cloud. In essence, the Microsoft Dynamics CRM pipeline connects to the Windows Azure Service Bus enabling the data that has been processed as part of the current Microsoft Dynamics CRM operation to be posted to the bus. Windows Azure Service Bus solutions that are “CRM aware” can listen for and read the data that is posted on the service bus by Microsoft Dynamics CRM. The posted data is stored in a RemoteExecutionContext class instance that is an extended version of IExecutionContext passed at run-time to Microsoft Dynamics CRM asynchronous plug-ins. In addition to information on the requested operation that was processed by Microsoft Dynamics CRM, this class adds a OperationId property and a OperationCreatedOn property, which contain the same data as the AsyncOperationId and CreatedOn attributes of the related System Job (AsyncOperation) record. These additional properties facilitate sequencing and duplicate detection if the Windows Azure Service Bus post must be retried.

This integration between Microsoft Dynamics CRM 2011 and the Windows Azure platform provides a secure channel for communicating Microsoft Dynamics CRM run-time data to external cloud based line of business applications. This capability is especially useful in keeping disparate CRM systems or other database servers synchronized with Microsoft Dynamics CRM Online business data changes.

 

Identifying Key Elements of the Integration


The key elements that implement the integration between Microsoft Dynamics CRM 2011 and the Windows Azure platform are as follows.

Asynchronous Service 
The asynchronous service is responsible for posting the Microsoft Dynamics CRM remote execution context. Each post is performed by a system job of the asynchronous service. A user can view the status of each system job using the Microsoft Dynamics CRM Web application.
Asynchronous Plug-ins 
There are two kinds of asynchronous plug-ins supported by the integration feature: out-of-box (OOB) and custom. Synchronous plug-ins are not supported.
An Azure aware plug-in is provided with Microsoft Dynamics CRM 2011. This OOB plug-in executes in full trust with the Microsoft Dynamics CRM platform. When registered with Microsoft Dynamics CRM, the plug-in can notify the asynchronous service to post the current request’s context. A developer needs to register a step on this plug-in that identifies the target message and entity in order to enable the service bus posting functionality.
You can also write your own custom plug-in that is “Windows Azure aware”. The custom plug-in executes in partial trust mode in the sandbox and can call any Microsoft Dynamics CRM SDK methods. For a custom plug-in to initiate posting the Microsoft Dynamics CRM context to the bus, the plug-in code must include some standard lines of code that notifies the asynchronous service to post the request context. This code makes the plug-in “Windows Azure aware”.
Custom Workflow Activities 
Custom workflow activities can be written to post the current request’s data context to the Windows Azure Service Bus.
Windows Azure Service Bus 
The service bus relays the remote execution context between Microsoft Dynamics CRM 2011 and Windows Azure Service Bus solution listeners. The Access Control Service (ACS) manages claims based authentication security.
Windows Azure Solution 
For the CRM-Azure integration feature to work there must be at least one solution in an Windows Azure Service Bus solution account, where the solution contains one or more service endpoints. For a non-queued endpoint contract, a listener that is “CRM aware” must be actively listening on the endpoint for the Microsoft Dynamics CRM request on the service bus. For a queued endpoint contract, a listener does not have to be actively listening. A listener is made “CRM aware” by linking it to the Microsoft.Xrm.Sdk assembly so that type RemoteExecutionContext is defined.
The solution rules must be configured to allow the Microsoft Dynamics CRM 2011 remote execution context to be posted to the service bus. To enable this posting, ACS needs to recognize the Microsoft Dynamics CRM deployment as a supported issuer.
Important: To develop a solution listener for Windows Azure platform, you need to install the Windows Azure SDK on your development computer.

Describing a Microsoft Dynamics CRM to Service Bus Scenario


Let us now identify a scenario that implements those integration components identified previously. As a pre-requisite, ACS has been configured to recognize Microsoft Dynamics CRM as the supported issuer and the Windows Azure Service Bus solution configured with rules to allow Microsoft Dynamics CRM to post to the endpoint on which the listener is listening.

The following diagram shows the physical elements that make up the scenario.

Microsoft Dynamics CRM to Service Bus Scenario
Microsoft Dynamics CRM to Service Bus Scenario

The sequence of events as identified in this diagram are as follows:
  1. A listener is registered on a Windows Azure Service Bus solution endpoint and begins actively listening for the Microsoft Dynamics CRM 2011 remote execution context on the service bus.
  2. A user performs some operation in Microsoft Dynamics CRM 2011 that triggers execution of the registered OOB (out of the box) plug-in or a custom Windows Azure aware plug-in. The plug-in initiates a post, through an asynchronous service system job, of the current request context to the service bus.
  3. ACS authenticates the claims posted by Microsoft Dynamics CRM. The service bus then relays the remote execution context to the listener. The listener processes the context information and performs some business related task with that information. The asynchronous service is notified, by the service bus, of a successful post and sets the related system job to a completed status.

Establishing a Contract between Microsoft Dynamics CRM and a a Windows Azure Solution


For each solution endpoint, you configure a contract that defines the handling of these remote execution context ‘messages’ on the service bus and the security that should be used on that endpoint. Service bus messages are received at an endpoint using a queued contract, a one-way contract, a two-way contract, or a REST contract.

Queued:
A queued contract, also known as a “message buffer”, provides a message queue in the cloud where messages are stored in the cloud. With a queued contract, a listener does not have to be actively listening for messages on the endpoint. However, the queued messages and the endpoint will be removed from the service bus if not used for a pre-configured length of time that typically is less than 10 minutes. For queues, there is a destructive read and a non-destructive read. A destructive read reads an available message from the queue and the message is removed. A non-destructive read does not remove a message from the queue

One-way:
A one-way contract requires an active listener. If there is no active listener on an endpoint, the Microsoft Dynamics CRM post to the service bus fails. Microsoft Dynamics CRM will retry the post in exponentially larger and larger time spans until the asynchronous system job that is posting the request is eventually aborted and its status is set to Failed.

Two-way:
A two-way contract is similar to a one-way contract except that a string value can be returned from the listener to Microsoft Dynamics CRM.

REST:
A REST contract is similar to a two-way contract on a REST endpoint.

Identifying the kind of security a contract uses is part of the contract’s configuration. A contract can use Transport security, which uses Secure Socket Layer (https).

Claims authentication is used for secure access to the service bus. However, Microsoft Dynamics CRM and the service bus use different claims implementations. The claim used to authenticate to the service bus is generated within Microsoft Dynamics CRM and signed by the AppFabricIssuer certificate specified in the Microsoft Dynamics CRM configuration database.

Management and Notification of Run-time Errors


If an error occurred after a post was attempted to the service bus, check the status of the related system job in the Microsoft Dynamics CRM Web application for more information on the error. If the service bus is down or a listener/endpoint is not available, the current message being processed in Microsoft Dynamics CRM will not be posted to the bus. The asynchronous service will continue to try to post the message in an exponential pattern where it will try to post frequently at first and then at longer and longer intervals. For an internal Microsoft Dynamics CRM error, message posts are not attempted. For an external service bus or network error, the related system job will be in a Wait state.

My above blog is based on Microsoft's Official information.

I hope this blog about 'Microsoft Dynamics CRM 2011 - Introduction to Windows Azure Integration' was informative. Please feel free to leave your comments.

1 comment:

  1. Establishing a Contract between Microsoft Dynamics CRM and Windows,Identifying Key Elements of the Integration,Management and Notification of Run-time Errors this is very grate analysis it very useful for new and manatees. Thank you for publisher

    ReplyDelete