Call Azure Function From Dynamics PowerApps Portal

Quite often we come across scenarios in Dynamics or PowerApps Portal where we need to use custom server side code to fulfill any functionality which might not be possible to achieve using liquid Code or normal script.
In these scenarios we have options like using Flow/Workflow, Logic Apps, Azure Function or even companion Apps.
Here in this article I will be posting my experience of using or better to say that how we can call Azure function using Client side Script.

To call a azure function we need to first Create one.

Create a new Azure Function

  1. Go to and search for Function App
  1. Click on Add Button and then you will get a Create Function App screen
    in my case I’m using DemoAppAzureFunction.

You can click on create + Review Button an then Create button, after providing the required details

Then it will take some time to provision and to complete the deployment process.

Copy the storage account No from the first row in the List. This is required to connect your Visual Studio code with the Azure Function Resource.
Once your Azure App deployments complete you can click on Go to Resource Button.
A new overview screen will appear with all the details of your newly created Function App

Now Open your Visual Studio and Open a New Project after that select Azure Functions from Cloud in Visual C#

Do Sign in Visual Studio with the same account as your Azure Account.

You can then click on OK to create the new Azure function Project.
On Next Step you will get a Screen where you can enter your type of Azure Function Trigger (Select HTTP trigger) and then Select your storage Account from your Azure Subscription using browse option from the Storage Account drop-down.

on click of browse you will see the screen like below, where you can provide the location of your hosted azure app to the visual studio. This will help you to publish the code later.
You need to be a Sign in user on Visual Studio to perform this step with the azure account.

After this step you can click on OK And you will get your Azure OOB basic Code, Which you can deploy and test by hitting the URL.

You can run the code locally on Visual studio and you can debug your code
by hitting the localhost URL with your parameters

We can then Build and publish the code on Azure to test it from the browser.

To check your hosted code after publishing you can go back to Azure and click on the Function tab from the Left hand side navigation Link and there you will find the details of your Azure Function.

Now click on the function which you just created and then click on the Get Function URL button to get your Azure function URL.

You can then hit this URL on the Browser to get the response from the function.

Now to call this Azure function from your portal page using Jquery, you will have to add your page URL on the CORS of your Azure APP.
Suppose my Portal URL is

Now to call the Azure Function from my portal Page I will using the following Jquery Ajax code

			url: "",
      //If needed you can add parameters in your Query string
			dataType: 'json',
			type: "GET",
      //you can also pass your parameters as header(recommended)
			beforeSend: function(xhr){				
				xhr.setRequestHeader("UserId", "XXXXXX21-9XXd-ea11-aXXX-0XXXXXXXX7");
			success: function(result){
		}).fail(function($xhr) {  
                    var message = $xhr.responseJSON.message;

This way you can call and perform your server Side functionality from the Dynamics or PowerApps Portals.

Hope it Helps 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s