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.
This article walks you through creating a basic mock API for an asset management application using Azure Functions. The API exposes a single operation to return a list of assets. You'll also learn how to create a custom connector in Power Platform using API Management.
Note
Preview features aren’t meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.
This basic API provides a mock asset list and is ready for integration with Power Platform using a custom connector via API Management.
Prerequisites
Create a new Azure Function in the Azure portal
Go to the Azure portal.
Select Create a resource > Web > Function App.
Select Consumption.
Fill in the required details:
Detail Description Subscription Select your subscription Resource Group Create a new one or use an existing one Function App name Choose a unique name Runtime stack Node.js Region Choose a region close to you Select Review + create and then Create.
Once deployment is complete, go to your new Function App.
Select Create function.
If asked, select: Development environment: Develop in portal.
Select HTTP trigger as the template, give it the name
GetAssets, and set Authorization level to Anonymous because no authentication is required in this basic example.
Select Create to create the function.
In the Code + Test tab, replace the function code with the mock API code from the next section.
Select Save.
Implement the mock API
Edit GetAssets/index.js to return a mock list of assets:
module.exports = async function (context, req) {
context.res = {
// status: 200, /* Defaults to 200 */
body: [
{ id: 1, name: "Laptop", type: "Electronics", status: "Available" },
{ id: 2, name: "Projector", type: "Electronics", status: "In Use" },
{ id: 3, name: "Desk", type: "Furniture", status: "Available" },
{ id: 4, name: "Office Chair", type: "Furniture", status: "In Use" },
{ id: 5, name: "Monitor", type: "Electronics", status: "Available" },
{ id: 6, name: "Whiteboard", type: "Office Supply", status: "Available" },
{ id: 7, name: "Phone", type: "Electronics", status: "In Use" },
{ id: 8, name: "Tablet", type: "Electronics", status: "Available" },
{ id: 9, name: "Printer", type: "Electronics", status: "Maintenance" },
{ id: 10, name: "Filing Cabinet", type: "Furniture", status: "Available" }
]
};
};
Expose your function app via API management
In the Azure portal, search for and select API Management services.
Select + Create to create a new API Management instance. The Developer tier is free for development/testing.
Fill in the required details and deploy the instance.
Once deployed, open your API Management instance.
In the left menu, select APIs > + Add API > Function App.
Select your Function App and the
GetAssetsfunction.
Complete the wizard to import your function as an API operation.
After import, go to your API in API Management.
In the top menu, select Settings for your API.
Under Security, set Subscription required to Off. This removes the need for a subscription key (API key) when calling the API.
Save your changes.
Create a custom connector in Power Platform using API Management (from Azure portal)
In API Management Services In the left menu within APIs, select Power Platform.
Select Create a connector.
Select Your API:
Select your environment and display name and then select Create. The custom connector is created in your selected environment.
In Power Apps, go to Custom connectors to review, edit, and test your new connector.
Next steps
- Create a new code app using this custom connector with Power Apps SDK
- Expand the API with more operations as needed. Don't forget to update the connector with the new operations when you do.
- Secure your API if you move beyond development/testing.