Login

Guide To Custom Connectors In Power App

Author: Bonny

Oct. 28, 2024

7

0

Guide To Custom Connectors In Power App

Please visit our website for more information on this topic.

Microsoft Power Apps has emerged as a significant change in the realm of app development, offering a versatile platform to create powerful applications. One key feature that takes the capabilities of PowerApps to the next level is the ability to create custom connectors. In this blog post, we will guide you through the process of creating a custom connector in PowerApps, allowing you to seamlessly integrate your apps with various data sources and unlock the full potential of this remarkable platform.

Understanding the Power of Custom Connectors in PowerApps

 

PowerApps, at its core, empowers users to build applications with minimal coding. However, true magic happens when you leverage custom connectors. These connectors act as bridges, enabling your apps to connect with external data sources, services, and APIs. By creating a custom connector, you open the door to a world of possibilities, extending the functionality of your apps and ensuring they meet the unique requirements of your business or project. 

What is a PowerApps Custom Connector?

 

A PowerApps Custom Connector serves as a conduit for integrating your custom APIs with Microsoft Power AppsMicrosoft Power Automate, and Azure Logic Apps. It acts as a wrapper around an API, facilitating communication between different systems. 

Think of a Custom Connector as a vital link that bridges the gap between PowerApps and external services, such as APIs or various data sources. Its primary function is to enable seamless access, retrieval, and manipulation of data. By functioning as this intermediary, Custom Connectors significantly enhance the capabilities of your apps, allowing them to interact with external services effortlessly. 

Creating a New Custom Connector:

Step 1: Power Apps 

Step 2: Select &#;Custom connectors&#; in the Navigation pane on the left. 

 

Step 3: Click on &#;New Custom Connector&#; and choose &#;Create from blank.&#; 

Step 4: Provide a meaningful name for your connector. 

General details of the API and Power Apps Connector: 

  • In the 

    Description

     field, enter a meaningful value. This description will appear in the custom connector&#;s details, and it can help others know if the connector could be useful to them.

     

  • Schema

    : HTTP or HTTPS.

     

  • Update 

    Host to the address

     for the API URL. The connector uses the API host and the base URL to determine how to call the API.

Select on Security to continue. 

Defining security sections: 

Choose authentication type On the Security tab. 

Select on Definition to continue.

Custom Connector in PowerApps definition: 

In the definition section, you can define multiple actions for your custom connector. For this blog, we will cover a single action. Click on &#;New action,&#; fill in the summary and description, and name the operation ID field for future reference. 

In the operation ID field, name the field which will be easy to remember and meaningful as this field will be required later in the canvas app. 

Create a New Action &#; Actions > Select New Action 

Complete the SummaryDescription/Operation ID for the new action.

Import from sample: 

Here, we will define the requirement needed for the request. 

We will use GET as we are getting data from the API. 

In the URL, provide the endpoint which we use earlier to test by city name and click import. 

Defining a Response in our custom connector: 

Select Add default response. 

Select Import from sample

Copy a RAW JSON response from URL. 

In example case from the URL: https://api.weatherapi.com/v1/current.json?key=4ca4bc&q=India&aqi=no 

Paste Body&#;example (as shown below): 

Then, select&#;Import. 

Finally, you will see the properties loaded in the response. 

Select on&#;Code&#;to continue. 

Test the Custom Connector in PowerApps: 

Select Test from Create a new Connection. 

Select New Connection

Then, select Create

Link to AIKE Electronics

Test Operation: 

Select Test Operation

Integrating PowerApps with APIs (Custom Connector):

After creating our custom connector, we will now see how to add our custom connector to our canvas app and use it as a data source. 

Sign in to&#;PowerApps. 

Start a new app or open an existing one. 

Navigate to Home > Blank app.

A blank screen will be displayed. 

Click on the data icon and select &#;Add data.&#; 

Go to the Connectors tab or locate your custom connector in the list. 

Select the custom connector to load and establish a connection.

Now, you just must use a label and see whether it is working or not. 

Use the formula given below to test it. 

The custom connector is the connector name we have given earlier, and the place is the operation ID. 

Note: use your own API Key in the app id.

Add Text Label and Input Boxes

Include Text labels and Text input boxes in your app. 

Use the formula below to display real-time data: 

For Temperature

Default = gblCurrentWeather.current.temp_f 

For Time Zone:  

Default = gblCurrentWeather.location.localtime 

For Wind Speed:  

Default = gblCurrentWeather.current.wind_kph 

For Cloud Cove:  

Default = gblCurrentWeather.current.cloud 

Configure Button Properties

Add a button to trigger data retrieval. 

Set the OnSelect property with the following code: 

OnSelect = Set(gblCurrentWeather,CustomConnectorinPowerApps.GetTotalWeather({q:txtCity.Text})) 

Run the PowerApps 

Execute the PowerApp. 

Input the city name and click the button to retrieve and display the values.

Conclusion

Custom connectors in Power Apps open doors to API integration beyond standard connectors. This guide walked you through creating custom connectors, empowering you to tailor solutions for unique needs. Whether building apps or automating workflows, custom connectors enhance connectivity. If you have questions or feedback, share them in the comments. Best of luck in your Power Apps journey! 

The ALM story for Custom Connectors

This post is a part of a series of posts about custom connectors. In this post we will look at ALM for custom connectors. That story starts with the concept of Dataverse solutions. Here are my findings after working with custom connectors in solutions!

All parts of this series:

There is a certification process you can go though in order to get a new connector to be available in the platform among the other connectors. As a connector if you own the API or as an independent publisher connector if not. In some cases that might not be applicable and you want to create the custom connector for a certain project. Then, you want to use Dataverse solutions in order to get healthy ALM for your custom connector.

Custom connector in Solution

Connectors can be created from scratch or you can import a definition from e.g. a Postman collection or Open API definition. If you want to use a custom connector in a production environment you want to build it properly in a development environment first, then try it out in a test environment, before letting the users utilize your automations in production. You will need to use Dataverse solutions.

You can read about custom connectors in solutions in the official documentation. When you create a custom connector in a solution you only get the choice to create it from scratch. You do not want to do that if you have a definition you can use. This is not mentioned (or I missed it) in the official documentation, but you have two different alternatives. In both cases you first create the custom connector outside of a solution, from a definition.

Then either choose to add existing component (custom connector) to your solution. This is mentioned as in Public Preview since March 31, in a release plan. I can&#;t find any more information in the official documentation (like GA or not) so make sure you test your custom connector properly. You will not get to choose your own prefix for the custom connector this way though.

Adding an existing component to a solution in Maker Portal

The other way would (also) be to create the connector, from a definition, outside of the environment. Then, in your solution, create a connector from scratch. Then open the one created outside of the solution in Swagger mode. Copy from there and paste into swagger mode in your custom connector created in your solution.

Swagger mode when updating a custom connector in the UI

Environment variables in custom connectors

It is recommended to have unmanaged solutions in development environments and managed in the other environments (such as test and production). You are not supposed to do any updates in the target environments, except for setting values for environment variables.

In some cases you will need to use environment variables for your custom connector. E.g. if you use OAuth 2.0. In order to be able to successfully export a solution containing a custom connector, you will need to have the client secret in an environment variable.

Otherwise, the client secret setting in the connector will not be included in the exported file. That would result in the custom connector not having a value or something pointing out the value to the client secret. That would result in you being frustrated because of the fact that you cannot create connections successfully until you *not recommended* manually update the client secret field of the connector in the target environment.

Remember to remove the current value of the environment variable before exporting the solution from the development environment. Export as managed (recommended to use umanaged solutions only in the development environment). If you import the solution manually, you will be prompted to add the values to be used in the target environments for the environment variables. You can change the values in an unmanaged solution (or the default solution) later.

Read more: Use environment variables in solution custom connectors.

Cloud flows and connection references

Other things to consider are where to put your cloud flows if you want to create cloud flows that utilizes your connector. There is a known limitation that a custom connector needs to be imported to a target environment prior to importing cloud flows and connection references.

So you will need two different solutions, one for the custom connector and one containing the cloud flows and connection references. (Usually the recommendation is to have one unmanaged solution per development environment, consider this an exception &#;).

I&#;ve noticed that in some cases the custom connector are added to the solution in which the cloud flows and connection references are located. I&#;m not sure if this is a bug or intended behavior. I then usually remove it from there. Why have it in two solutions?

Findings

  • When working with Custom Connectors in Solutions you do not get the choice to create from a definition/Postman collection. Create it outside of the solution from definition or Postman collection and choose add existing to get it into your solution or copy paste in swagger mode in the custom connector designer.
  • You cannot use the client secret directly as is in the custom connector client secret field under Security settings, you need to use environment variables in order to get the client secret setting included in the exported file.
  • You can&#;t have the custom connector and the cloud flows and connection references in the same solution.
  • Interesting post on the Power Automate blog: Easier deployments of Custom Connectors. It lists some limitations in the end, I do not know the status of those now.

Also see the landing page for Power Platform and Azure Logic Apps connectors.

Photo by Chris Lawton on Unsplash

Share this:

Like

Loading...

For more information, please visit custom Connectors for Consumer Electronics.

Previous

None

Comments

0

0/2000

Guest Posts

If you are interested in sending in a Guest Blogger Submission,welcome to write for us!

Your Name: (required)

Your Email: (required)

Subject:

Your Message: (required)

Join Us