How to Create a custom connector for PowerApps and Flows.
Let’s review the prerequisites needed to create a custom connector.
- A Web API solution which is hosted on your local IIS machine with access to the web API through the domain api.contoso.com
- An app registered in azure app registrations (https://portal.azure.com) with a Client ID and Client Secret configured in web API solution (More Info: Refer) These details will be used in creating the custom connector
- Register another app in Azure AD similar to the details above. Copy the Client ID and Client secret of this app
Creating a custom connector for PowerApps and Flows
Open the PowerApps web app in Office 365
Select Data, then choose Custom Connectors
Select the Create custom connector button and then choose on Create from blank from the dropdown
Provide a meaningful Custom Connector Name (Fig.2)
- Select Continue
- Select the General tab and fill in the details of the form
- Ensure the Host is pointed to the desired web API endpoint
Navigate to Security tab and fill in the details (Fig.4):
- Select OAuth 2.0 as the authentication type
- Select Identity Provider as Azure Active directory
- Paste the Client Id and Client Secret which were copied earlier (Mentioned as a prerequisite)
- Keep the Login URL as it is
- Enter Tenant ID and Resource URL
- Enter Scope as User.Read
Note: Ensure the APP URI property for Custom Web API azure app in Azure portal is entered for the Resource URL field
Navigate to Definition tab:
Click on + New Action
In the General form (Fig.5)
Write a Summary
Write the description of an Action
Enter Operation ID which is unique for all actions
Enter Request information: (Fig.6&7)
- Click + Import from Sample
- Choose a Verb (I chose GET)
- Enter API URL (ex: /api/Employee)
- Pass the Headers (optional) and select Import
Go to Response section: (Fig.8)
- Select + Add default Response
- Enter Actual data which was in the Body section and select Import
- Once importing is completed, specifying each property name can be done in the response section
Select Update Connector: (Fig.9)
Navigate to Test tab (Fig.10)
- Select + New Connection and choose Create button
- Enter credentials to create the connection
New Connection will be created in the connection list
Go back to Custom Connector and select Edit
Navigate to Test tab and Select the Connection from the drop down
Choose Test operation on Get Employee tab (Fig.11)
Conclusion:
To run through, I have to say that the custom connector is created, and the data is accessible through the actions specified. Custom logic or expressions can be added and consumed as data validations as a service used to connect PowerApps & Microsoft Flow. This will help your business to improve the security and access any local data sources with this approach.
Note: When creating the custom connector. GET, POST, PATCH, PUT, DELETE requests can also be configured through the connector where they can be used in both PowerApps and Flows to manipulate with on-premises data with the help of custom WebAPI.
Refer Links:
https://docs.microsoft.com/en-us/connectors/custom-connectors/define-blank