Question

We are trying to push data to Azure Service Bus Queue when a contact is created in "Dynamics CRM Online". We have implemented it using a plugin by registering it with Plugin Registration Tool. But somehow its throwing an error while saving the contact. Here is the code which we have implemented in plugin:

public void Execute(IServiceProvider serviceProvider)
    {
        try
        {                
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            Entity entity = (Entity)context.InputParameters["Target"];
            if (entity.LogicalName.Equals("account"))
            {
                QueueDescription qd = new QueueDescription("testQ");

                qd.MaxSizeInMegabytes = 5120;
                qd.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);

                string connectionString =
                    CloudConfigurationManager.GetSetting("Endpoint=sb://test.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=secretcode=");

                var namespaceManager =
                    NamespaceManager.CreateFromConnectionString(connectionString);
                if (!namespaceManager.QueueExists("testQ"))
                {
                    namespaceManager.CreateQueue("testQ");
                }

                QueueClient Client =
                    QueueClient.CreateFromConnectionString(connectionString, "testQ");

                BrokeredMessage message = new BrokeredMessage(entity);

                message.Properties["FirstName"] = "ABC";
                message.Properties["LastName"] = "Z";

                Client.Send(message);
            }
        }
        catch (Exception e)
        {
            throw;
        }
}

No correct solution

OTHER TIPS

How are you referencing the DLL? You must add a local reference (not GAC). Eg: C:\Program Files (x86)\Windows Azure platform AppFabric SDK\V1.0\Assemblies\NET4.0\Microsoft.ServiceBus.dll

Also, set "Copy Local" to true so that the assembly is packaged with your plugin.

You should look at the Dynamics CRM 2013 SDK examples at \SDK\SampleCode\CS\Azure If you haven't been updated to going to assume you've been upgraded to the Fall ’13 release you should look at the same location in the Dynamics CRM 2011 SDK. It won't work exactly as you have it - but you can meet all you requirements using the supported method.

You need to use the Azure Plugin functionality that is in Dynamics CRM. I would add the details but they are too long and best read with the pictures: http://blogs.msdn.com/b/crm/archive/2011/02/18/windows-azure-appfabric-integration-with-microsoft-dynamics-crm-step-by-step.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top