Create a Custom Connector For Power Automate & Power Apps

One of the most important qualities of extending capabilities of any platform is being able to add Custom code and make it available to wider use cases.

In this case, it’s a custom code that is encompassed in a Custom Connector in Power Platform and made available to Power Automate or Power Platform.

Use Case

The purpose of my custom connector is to call my hosted custom code in Power Automate or Power Apps.

For this example, I’ve created a simple Azure Function that just returns a value – just to test the working of the Custom Connector. Of course, your use case is to be able to connect to the hosted app, expect it to process the business logic which you intend to do and return back the results.
So, in my case – my Azure Function will simply greet the name passed to it.


See the Postman test below –

Now, let’s make a Custom Connector that will execute this Azure Function in your Power Automate.

Create Custom Connector in Power Apps / Power Automate

You can either make the Custom Connector from the Power Automate portal or the Power Apps Maker portal, both are the same things. Let’s see this example from Power Apps portal –

  1. In this use case, I’m in a Solution in Power Apps / Power Automate. Open the one in your case since you can’t create a Custom Connector from outside a Solution any longer.

  2. Now you can drop down from New and see in Automation menu that you can create a Custom Connector

  3. Now, you’ll be required to enter the name of the Connector itself and other details like a PNG icon for it, Description etc.

  4. Now, below is the info that I filled in. I’m calling it Data Transporter and have selected an Icon which should make me easy to recognize my connector in Power Automate and Power Apps and enter enter the details of my hosted Azure Function which is authenticated using an API Key.
    So, here’s what my info looks like –

  5. Now, when I click on Security after filling all the info, the type of Authentication I used in this case if API Key, yours could be different depending on what your custom application is configured to work with –

  6. It’ll ask you to fill in the information so that it appears as parameters to fill in for the Custom Connector when the end user will work on their Flows/Apps.

  7. The info I’m choosing to fill is this – I’m giving a name to the parameter to indicate what info is required. The actual parameter name required by the Azure Function, in this case – it’s ‘code’ and since I need to pass the API key in Query string, I’ve selected Query instead of Header.

  8. When you go to the next part, i.e. Definition, make sure you also give a Name to the Custom Connector already. Before your lose the info you’ve already entered. Make sure you also click on Create Connector


    Once you click on Create connector, it’ll create it in a few moments.

  9. Now, since you are aware of Triggers and Actions from using Power Automate – in this use case, my Custom Connector is designed to be an Action i.e. when called/used in Power Automate, it’ll simply perform the operation it’s designed to do.
    Hence, I’m selecting an Action here.
    When I select New Action from the left hand pane, it’ll open up information for me to fill out to describe the Action.

  10. Now, since this will appear as a listed item in Actions in my Power Automate connector, I’m filling in this info (and we can check later how it appears).


    Next, I’ll click on + Import from sample as it’ll give me a place to enter a sample for the request to call my hosted Azure Function.



  11. Next, I’ll pass these values as I did in Postman to create the sample. Once done, I can click on Import.

  12. When I import, I’ll the request parameters set in the Custom Connector based on the sample I entered.

  13. Next, I’ll scroll down to ensure that all validations are perfect and I needn’t fix anything.

  14. Next, I’ll skip AI Plugins step and also the Code step since I want to keep this example concise and to the scope of the hosted Azure Function only.


    And this is skipped too –

  15. Now, the final step is to Test the Custom Connector. The Editor will ask you to Update connector before you can Test. Then, in order to begin testing – you’ll need to first create a Connection using New Connection button as shown below.


  16. When you click on New Connection, you’ll be taken to a new tab to enter the API key which you created as parameter in the initial setup of this Connector. See #7 above. Enter the API key you have which works for this hosted app and then click Create connection.


  17. Next, in case the Connection doesn’t appear, click Refresh button once.

  18. Once you refresh, you should see your Connection come up and selected.

  19. Now, next step is to test the Custom Connector itself. Enter the values that you wish to test for and click Test operation.

  20. You’ll see the test results based on what the hosted code is supposed to perform.
    In my case, it was easy as it just greets the name entered.


    And your Custom Connector is now ready to be used!

Consuming Custom Connector

Now, let’s see how you can use the Customer Connector in Power Automate in order to perform the operation in your Flows –

  1. Once in Power Automate, look for the Custom tab in the Action selector.

  2. Then, you can see the Action you defined in your Connector Definition steps above.

  3. Since you need to authenticate using the API key you have, the create Connection step will ask you this info and you can give the name of the Connection.

  4. Pass the value you want to pass as data.

  5. Finally, you can just save and test the Flow itself and look for your Outputs.


    And that’s how you can have a Custom Connector for your custom app/service your have created. I’ll soon write about other aspects of Custom Connector which I wasn’t able to cover in this blog.

Hope this was useful!

Thank you!

HTTP Trigger Azure Function Authorization Types simplified

Now, many of you must be wondering how the Authorization types for Azure Functions using HTTP Triggers work and where to look for information while using these different types. Hopefully, this post helps simplify each of those for you.

Now, when you create a new Azure Function from Visual Studio or from the Azure Portal, you’ll be asked about Authorization where you’ll find the selection to either be 1 of the below –

  1. Anonymous
  2. Function
  3. Admin
  4. System

Anonymous

This type of Authotization let’s you use the Azure Function without needing for any key and anyone with the URL alone can access it. Of course, this is not recommended for any production use –

  1. Now, if you notice your Visual Studio, when you write your first Azure Function, it comes with pre-defined method ready for you to continue to write your own code. But right away, you’ll see that the Authorization method is pre-defined considering you must’ve selected Anonymous while starting the Project.

  2. Also, since the Azure Function is understood to be Published already on the Azure Portal, you’ll see in the Function’s settings that the same has been reflected as well.

  3. Now, if you test this using Postman, the code will be able to run directly just using the URL without any API key. Either you pass in the body – and you’ll get a 200 OK with the result that the Azure Function is supposed to result.


    Or using query parameters – the result will be the same.


    This simply explains Anonymous authorization. Without any check on who’s supposed to access the Azure Function.

Function

In this type of Authentication, only the Function and resources associated to it will be accessible. This needs the caller to have a key [or code] to be passed while calling Azure Function –

  1. Let’s look at the code, and see that the type is not set to Function for Authorization.

  2. And when you Publish the code, the same will be reflected in the Settings too.


  3. And when you want to access the Azure Function from Postman, you’ll need the Function Keys defined in the Function Keys area of the Function itself – a Default Key is given already but you can choose to add your own keys and using any of them would do.

  4. Now, here’s what the Key looks like when you click on Show [there’s a button on the far right to expose the key’s value]

  5. Now, when you go to Postman, you need to can pass this as a query parameter –


    Now, let’s look at the Admin Type of Authorization.

Admin

In this type of Authorization, you get access to Functions’ Runtime APIs. The way to use the Admin key is similar to the Function Keys, just that they are available from the Function App itself than the Function –

  1. Now, when the Authorization is set to Admin

  2. You’ll see this reflected in the portal once Published.

  3. Now, in the Function App itself – you can navigate to the App keys under Functions [as of the portal’s layout in mid-2024]

  4. You can expose to see this value and share it to the clients who are going to consume this Function App. They key required here is the _master

  5. Now, you can test this using Postman


    Remember, this type of Authorization is to be used when the calling client needs to also access Functions Runtime API.
    Finally, Let’s look at the System type.

System

This type of key is managed by Function runtime and is used when the calling client when there’s a need for granular access to function runtime features.

  1. Now, you can set this from the code and publish it.


  2. And it’ll appear in the settings of the Function [In case when the Function wants to access granular function runtime features].

  3. And this is present in the App keys area under System Keys section.

  4. And when you test the same, they work just like any other key from the Function app when called.

Hope this was useful!

Pre-Export Step Required setting in Deployment Pipeline | Power Platform Pipelines

Now that you must’ve already setup your basic Power Platform Pipeline as yet and are looking to explore how to extend the Power Platform Pipeline to do more advanced operations, this post is for you!
In case you are still looking to first setup your Power Platform Pipeline, you can check this Blog Series which this very post too, is a part of – Power Platform Pipelines | Blog Series

What is Pre-Export Step Required Setting?

This is the ability to have a trigger before an Export operation from the Development Environment is initiated in order to run the pipeline – only available for the first stage in the pipeline.

This is provided so that you may want to run some external operations before this is taken through the pipeline for deployment.

Use Case is – that you want to first seek an approval from the Admin before the Solution is deployed to Production (or rather, sent through the pipeline for deployment). Once approved, the pipeline should automatically proceed towards executing the rest of the deployment stages.

Pre-Export Step Required

While setting up your Pipeline, in case you were wondering what Pre-Export Step Required setting was, see below –

  1. Once you mark this field as checked/Required, save the record and it’ll appear like this on the record.

  2. What this does is, it runs the trigger action ‘OnDeploymentRequested’

  3. And once this Flow is trigger based on this Action, you can perform custom logic to be carried out and be successful before the deployment is carried forward.
    In this example, I’m setting a simple Approval process to be in place so that the Admin is aware and approves all the Deployment requests.

  4. Now, once an Approval is received, you need to check the status of the request and if it’s Approved, you need to run Perform an unbound action to initiate the Action ‘UpdatePreExportStepStatus
    You’ll need to pass the StageRunId – You’ll get this in the Dynamics Content Properties of the Flow itself from the trigger.
    Then, you need to set the Status of 20 – this means Approved.
    For rejection, the status to set is 30.

  5. Now, once this Flow is in place, every time a Pipeline is Run to deploy the solution, it’ll first wait for the Approval process to complete and the pipeline itself will show the below message.

  6. This status can also be seen in the Deployment Stages in the ‘Deployment Pipeline Configuration‘ app as well.

  7. Now, the Admin on the other hand, will receive a Power Automate Approval like this (based on whatever you have configured). This is received on both Approvals in Teams and in Power Automate as well.

  8. Once the Approver approves, I’ll enter some notes while approving.

  9. The pipeline will then proceed to deploy to production.

  10. And this will also proceed on the UI in Pipelines as well.

  11. Once deployed, you’ll see that this is completed Successfully if there are no issues.

  12. You can also see the History. The End Time will represent when it was completed as opposed to Start Time representing when the Deployment Request was initiated.

  13. And also in the ‘Deployment Pipeline Configuration‘ app.



Here’s official Microsoft documentation on how you have Gated Extensions like these to be in place in Power Platform Pipelines – https://learn.microsoft.com/en-us/power-platform/alm/extend-pipelines#gated-extensions-available?WT.mc_id=DX-MVP-5003911

Hope this was useful!

Thank you!

Setup Power Platform Pipelines

Given that you need to setup Power Platform Pipelines, here’s a post for you!
This post will walk you through on how you can setup Power Platform Pipelines.

Pre-Requisites

Here’s what you need to setup in order to enable Power Platform Pipelines –

  1. You need to enable Managed Environments for the environments which need to participate in Power Platform Pipelines. Here’s a post on Managed Environment which I’ve written in the past – Enable Managed Environments in Power Platform Admin Center

    Given that all participating environments have been enabled with Managed Environments, select an Environment which is supposed to a “Host” environment where all the Pipelines master data will house and then go to it’s Dynamics 365 Apps section from Resources to install Power Platform Pipelines into that environment.

  2. Once you are in, click on Install app and then search for Power Platform Pipelines.

  3. Confirm that you are about to install this Solution.

  4. Once installed, go to Power Apps Maker Portal (https://make.powerapps.com/) and then select the Host environment in which you have installed Power Platform Pipelines on.
    Then go to Apps and you’ll see Deployment Pipeline Configuration app. Play that app!



    Let’s see how you can set the environments up first!

Setting up Environments

Here’s how you can setup your Environments in the –

  1. Once you are in the Deployment Pipeline Configuration App, go to Environments and create a New record.

  2. Then, enter all the details. Also, mention if the Environment type is Development Environment or Target Environment.

  3. Once you save the record, this the configuration will be validated.


  4. In case you are wondering how to you find the Environment ID, here’s where you’ll find the Environment ID in Power Platform Admin Center (https://admin.powerplatform.microsoft.com/environments), select the environment and you’ll see the details as below –

  5. Once all the Environments are set in the Deployment Manager, here’s how it should look


Configure Deployment Pipelines

Now that your environments are set, let’s also configure the Deployment Pipelines –

  1. Go to Pipelines and create a New record.

  2. Now, fill in all the relevant information and save the record.

  3. Now, link your Managed Environments in the Linked Deployment Environment grid below. Then click on Add Existing Environments button.

  4. And once you add, they’ll appear like this while selecting them in lookups. Then click Add.

  5. Once added the Development Environments, go ahead and create new Pipeline Stages too.

  6. In the new Deployment Stage, I’ll simply tag the Production Environment and save the record to keep this example simple.

    At this point, your Pipeline is all set to Run.

    Shortly, I’ll share another post on how you can Run a Pipeline in Power Platform!

Hope this was useful!

Thank you!