2
votes

The Problem: From CRM, we need to call a webservice and display the results using a webresource. I would like this call to be made using ajax so the UI is somewhat user friendly/responsive. The webservice is hosted in Azure and can either be an Http triggered function or an App Service web API.

I have seen many examples of creating services in Azure that can authenticate into and access CRM data. But I haven't been able to find examples where CRM authenticates into Azure. I am looking for something along these lines MSAL.js

1

1 Answers

1
votes

You can do this in js webresource using Ajax call to invoke Azure hosted REST api & consume that response in there.

Similar discussion in community

You can use MSAL.js to acquire token & use it in authorization header with the below sample code.

var _retrieveCategories = function () {
var urlPath = "xyz.azurewebsites.net/.../GetCategories”;
$.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) {
});
}