Tuesday, October 26, 2021

Create a Custom Connector for Logic Apps using the Azure portal

 

There are multiple ways to do create a custom connector for Logic Apps (CLI, Postman collection, OpenAPI definition). For this project we will demo use of  the Custom Connector Wizard in the Azure Portal. This custom Power BI connector will refresh a Power BI Dataset from a specified workspace

 

Prerequisites:

  1. Azure Subscription
  2. Azure Active Directory tenant
  3. A PowerBI account with read/write privileges

 

Steps:

  1. First youll need to log into Power BI with an account with sufficient privileges and register your app at https://dev.powerbi.com/apps
  2. Once logged in, fill out the form to register  your application:
     TheComputerTutor_1-1635280019463.png

  3. Required information youll need:
    a. Application name
    b. Application type - since we're creating a Logic App connector chose 'server side web application'
    c.  Homepage URL- you can choose any valid URL
    d. Redirect URL - for now we can use "https://login.live.com/oauth20_desktop.srf" . We will be able to change this later in the Azure Portal
    e. API access - to refresh a dataset the required access permission would be "Read and write all datasets". You can change this later in the Azure Portal.After you select "Register", you will receive a confirmation prompt including your application ID and secret. Make sure you save these in a safe location

  4. After you select "Register", you will receive a confirmation prompt including your application ID and secret. Make sure you save these in a safe location.


     TheComputerTutor_2-1635280140598.png

  5.  Now create the custom connector. From the Azure Portal select "Create a resource" and search for Logic Apps custom connector.TheComputerTutor_3-1635280140602.png

  6. Once the connector has been deployed, select go to resource and then select the "Edit" button

    TheComputerTutor_4-1635280140600.png
  7. Here in the General tab is where you create and define its actions. Notice if you select "Swagger Editor", you are presented with a blank Swagger file. A Swagger file is a JSON file that describes a RESTful API. This is where you can define your connectors actions. For this project, we will use a template Swagger file available on Github that defines the actions for your connector.  Download this file then import into the custom connector editor. Leave "REST" and "OpenAPI file" selected.
     TheComputerTutor_5-1635280496445.png

    (Now select the Swagger Editor again and notice the action has been populated!)

  8. Other settings such as uploading an icon image and specifying a description are optional, so from here, make sure you select "HTTPS" under General Information and use api.powerbi.com as a host for now and then click on the "Security" tab so that we can configure the authentication type.

  9. Here we will select "Oauth 2.0"  as the authentication type , then configure the form as such:
    - Azure Active Directory as the identity provider.
    - The client ID and secret we created earlier by registering the app at the Power BI website.
    - The login URL should stay as-is "https://login.windows.net"
    - The Tenant ID should stay as-is "common"
    - For Resource URL use: "https://analysis.windows.net/powerbi/api."
    - Enable on behalf of login : false

    - Scope: openid TheComputerTutor_6-1635280922407.png

    - a redirect URL will be generated upon save. You will need to copy this and replace the original redirect URL from when we registered the app in the Azure Portal

    TheComputerTutor_7-1635281033414.png

  10. From the Azure Portal go to Active Directory -> App Registrations -> select the app with the name you used when registering on the Power BI site ->  Manifest Blade. Here you can click inside the JSON and use ctrl+f to use the search within the JSON object to look for "reply" . Here you will find the parameter "replyUrlsWithType". For this url setting: paste the redirect URL you just copied from the previous step and click the save button.
     TheComputerTutor_8-1635281054351.png

     

  11. Now go to your "Definition" tab of your custom logic app. You may notice one or more actions or references may display a warning. This is most likely due to a type or something similar hasn’t been defined. These can be ignored for now. Make sure you have selected the desired action. In this case "Datasets_RefreshDatasetInGroup"

     

    TheComputerTutor_9-1635281244290.png

     

  12. Once you scroll down and see that validation has succeeded just click the "Update connector" in the top wizard menu and your new Custom Connector is ready to be used in a Logic App.

    TheComputerTutor_10-1635281269702.png

     

  13. To add to a Logic App simply click the "+" icon in the Logic App Designer to add an action and look under the "Custom" tab to find your new Custom Connector.

    TheComputerTutor_11-1635281319338.png

    Additional Information:

    Custom connectors overview | Microsoft Docs

    Create a custom connector in Azure Logic Apps | Microsoft Docs for ms doc on how to

    Example custom connectors | Microsoft Docs for examples

    Create an Azure Active Directory tenant to use with Power BI embedded - Power BI | Microsoft Docs - if you don’t have active directory

    praveensri/LogicAppCustomConnector: Azure Logic App Custom Built in connectors (github.com)

     

    *note that depending on your Azure Active Directory setup, your system admin may need to grant administrator permissions to use this connector*

     


     

Posted at https://sl.advdat.com/2ZueQaE