Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this blog I want to show how easy is to use the newly introduced Azure Functions from a PowerApps. Azure Functions provides a very convenient and easy way to develop custom logic called Functions that runs in the cloud and without the need to worry about the hosting solution at all. You can do things like processing data, integrating with other systems such as storage, queues and many other features on your favorite language C#, Node.JS, Python and more.
PowerApps provides a very convenient and simple way to create business mobile applications without the need to write any code that run on iOS, Android, Windows and Web, that allows you to easily integrate with many SaaS providers such as SharePoint, Dropbox, Google Drive, Facebook, OneDrive, Salesforce, Dynamics and many more, however, in some cases you might need to write some custom logic on the server-side to do some further processing. In this example I’ll show you how you can extend PowerApps to call an Azure Function.
To use an Azure Function from a PowerApp there are four simple steps
The first step is to create the Azure Function, for that just:
There are a few editors that can help you create your swagger such as https://editor.swagger.io/, however in this case it is a very simple REST API that only receives a “name” query string parameter, and the code to be able to call the API, so I just went and defined it in a JSON as below. Note that I used the title MyAzureFunction which is the way I will refer to inside PowerApps, and I called the operationId RunThis which will be name of the formula. You can use the example below as a starting point, just edit the “Host” to match your site, and the paths as needed.
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "MyAzureFunction"
},
"host": "azurefn.azurewebsites.net",
"paths": {
"/api/HttpTriggerCSharp1": {
"get": {
"description": "Calls my azure function over https",
"operationId": "RunThis",
"parameters": [
{
"name": "code",
"in": "query",
"description": "code",
"default": "h6ztu…[your code here]…i",
"type": "string"
}, {
"name": "name",
"in": "query",
"required": true,
"type": "string"
} ],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"title": "The response of the api.",
"type": "string"
}
}
}
}
}
}
}
To register a custom API in PowerApps simply navigate to https://web.powerapps.com/#/connections/available/custom/create
(or click Manage->Connections->New Connection->Custom->New Custom API … hurray for deep linking).
Click Next and Create.
To use the newly created Custom API, just:
In this simple example I show you how easy it is to add any HTTP API to a PowerApp, in our case we used the simplest Azure Function that returns “Hello “ + the value provided in the “name” query string parameter. Of course at this point you can now extend as you want the azure function to do much more interesting things like calculations, data gathering, integration to external systems, and more.
One final note: It is worth calling out is that one thing to consider is authentication, with this approach the "code" that is used to authorize is actually coming to clients which is not ideal if your API is not something you want to allow. For example using Fiddler someone could see the code and reuse. PowerApps supports protecting Custom APIs using Azure Active Directory and basic authentication but I'll keep that for a later post.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in