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
Once logged in, fill out the form to register your application:
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
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.
Now create the custom connector. From the Azure Portal select "Create a resource" and search for Logic Apps custom connector.
Once the connector has been deployed, select go to resource and then select the "Edit" button
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.
(Now select the Swagger Editor again and notice the action has been populated!)
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.
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
- 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
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.
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"
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.
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.