Multiple ways to call azure function in Dynamics 365.

Vikrant SarodeDyn365CE4 years ago27 Views

Nowadays, multiple organizations are storing their data everywhere, it is in Cloud or On-premise and it is increasing day by day with the help of internet connectivity. Organizations are asking their developers to respond with highly-scalable solutions. Solutions that often require developers to implement on-demand or scheduled batch jobs to reconcile transactions, ingest and process data, or react to events in real-time. To accomplish this huge demand we have Azure functions.

Azure Functions is a serverless compute service that lets you run event-triggered code without having to explicitly provision or manage infrastructure.

Today we will see how to call an azure function from the below components.

  1. JavaScript
  2. Plugin & Custom Workflow
  3. Power Automate
  • JavaScript: There are many scenarios where we need to execute complex logic from the client-side code.

You can use below jquery code in your JavaScript to trigger azure function and you can also pass the expected parameter in that request.

function TriggerAzurefunction()
{
var urlPath = "https:// functioncreatemultiplecontact20200723025939.azurewebsites.net/api/CreateMultipleBookings?code=XktEMAGwdjCXKIksnSKTdFKGP/iqo9WiJMYkTMObAa07bkBcYKrjaQ==&name=testname ";

if (typeof($) === 'undefined') {
$ = parent.$;
jQuery = parent.jQuery;
}

$.ajax({

url: urlPath,

type: "GET",

dataType: "json",

async: false,

crossDomain: true,

success: function (data, textStatus, xhr) {
	
	return JSHelper.toJson(data);

},

error: function () {

}

})

.done(function (data, status, jqxhr) {

});

}
  • Plugin & Custom workflow: Using webclient we can call azure function from Plugin, use below code to trigger azure function.
public void CallAzureFunction()
{
//create MemoryStream object to pass parameters
MemoryStream memoryStream = new MemoryStream();
var jsonObject = Encoding.Default.GetString(memoryStream.ToArray());

//creat web client object to call http request.
var webClient = new WebClient();

//Add required headers.
webClient.Headers[HttpRequestHeader.ContentType] = "application/json";

//Azure function URL you can query parameters as below 
var serviceUrl = "https:// orderscreate.azurewebsites.net/api/Function1?code=RUydvGtO6IHRLhWjagoKUYaa0WQfJcBXq39SYSEuYbQ==&OrderNo=" + OrderNumber + "&Orderid=" + Entity.Id.ToString();

//upload the data using Post method
string response = webClient.UploadString(serviceUrl, jsonObject);
}
  • Power Automate: In power automate it more easy to call azure function, it already have HTTP connector, you just need to provide function details in below properties,

1. URI: Provide azure function URL (you will get it in azure portal)

2. Headers: “code” and value, provide your azure function security code in header as shown below.

3. Queries: provide your parameters as per your requirement.

Check out my recent blog post:

  1. Audit History Using Azure Function
  2. Automate Microsoft’s Teams Meetings using Custom Connector in Power Automate.
  3. Sub-Grid Dependent On Another Sub-Grid.
  4. SharePoint Integration with Dynamics 356 using Power Automate.
  5. Dynamics CRM No-Code Low-Code Integrations using Power Automate (MS FLOW)
  6. Programmatically Create the Team’s Meeting.
  7. Invoke Power Automate on Creation of New Users in Azure AD
  8. Automate Microsoft’s Teams Meetings using Custom Connector in Power Automate.

Original Post https://vikrantsdynamicsblogs.wordpress.com/2020/07/27/multiple-ways-to-call-azure-function-in-dynamics-365/

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
March 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       
« Feb   Apr »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...