Hi everyone,
I created an Azure Function that is called from CRM via WebHook. It is linked with action in CRM. Calling the action new_APITest triggers the execution of the Function.
Fair enough, input parameters of the action are passed on to the Function. However, I do not know how to transfer the output parameters from the Function to the action.
Does anyone know the correct way to create the response of the Function? I've already tried some different approaches, but none has worked for me so far.
Is there a way to inject output parameters directly, without the need for creating a separate plugin?
Thank you.
-Sri
Solved! Go to Solution.
Thanks, @cchannon , This issue got resolved by creating the record at dynamics for output params which I am using for different logic and deleting that record, I don't think we can set the output parameter for the action within the azure function.
I might be mistaken here, but I am pretty sure the only supported mechanism for letting your azure-executing code push a response back to a plugin (and therefore, have the plugin await that Azure execution) is to use a two-way Relay, not the Webhook. The Webhook will fire and end - it will not await completion. Likewise for all the Service Endpoint types (queue, topic, one-way, Rest, Event Hub) EXCEPT two-way.
The two-way service endpoint uses an Azure Service Bus Relay, publishing a WCF contract, to give you an endpoint you can call to pass your pluginexecutioncontext to. Then, on the Listener side, you can instantiate a "remoteexecutioncontext" which mirrors the plugin one and it just happens pretty much magically. (really convenient, actually). Then, when you're done in that Function or Web Job or Console app or whatever, you can return a string to your plugin which has been quietly awaiting the whole time.
Getting this to work can be a bit tricky, but let me try to smooth it out for you:
If everything was set up correctly, your transaction should be able to push its full pluignexecutioncontext out to your console app, and you will see the transaction come in within a second or two. Now, this isn't the whole story - it is only how to push a message out to the relay and not how to reply. To get the reply you will need to follow the documentation instructions to create a Custom Plugin using a Service Endpoint, and then that plugin can await the call and get a string response back from your console app.
Best of luck - and let me know if you get tripped up anywhere. I am planning to write a blog on this for the community because it is really under-utilized, IMHO.
I want to call out one step up above in particular because it tripped me up for a while the first time I did this. When you run the console app, it actually registers the relay endpoint itself. This is how the the dynamic relay endpoints work: they only exist if there is a listener listening to them (very neat idea, actually). So once you've created the relay and the SAS, you are DONE in Azure. The Console app will create the actual endpoint just magically when it starts to listen.
Hi @DynamicsHulk - Did my response help resolve your issue? If so, please mark the solution for future visitors of your post, otherwise update us on how you resolved it!
Thanks, @cchannon , This issue got resolved by creating the record at dynamics for output params which I am using for different logic and deleting that record, I don't think we can set the output parameter for the action within the azure function.