Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 40

Custom Connectors

© Copyright Microsoft Corporation. All rights reserved.


Create and configure custom connectors

Module Use Policy Templates


Agenda
Implement Custom Code

© Copyright Microsoft Corporation. All rights reserved.


Module 1: Create and configure custom
connectors

© Copyright Microsoft Corporation. All rights reserved.


Module 1 - Introduction

In this module, you will


• Create and configure custom connectors

© Copyright Microsoft Corporation. All rights reserved.


Why do you want a custom connector?

Connectors make it easier to use the API from apps and flows

When the service or API that you want to use doesn't have a prebuilt connector

If a prebuilt connector doesn't expose all triggers and actions that you need from the
API

© Copyright Microsoft Corporation. All rights reserved.


Steps to create a custom connector

Identify or
Describe the Use the Certify/open
build the
API connector source
API

You can define the custom connector to describe any REST API that is
public (one that is available on the internet) or private (one that is only
on your internal network).

© Copyright Microsoft Corporation. All rights reserved.


Steps to create a custom connector - Describe

Identify or
Describe the Use the Certify/open
build the
API connector source
API

For Power Apps and Power Automate to discover what triggers and
actions are available from the API, you must identify them when you
create your custom connector

© Copyright Microsoft Corporation. All rights reserved.


Steps to create a custom connector - Use

Identify or
Describe the Use the Certify/open
build the
API connector source
API

After they have been created in an environment, custom connectors can be


used in the same way as built-in connectors

To use in other environments the connector definition needs to be exported


from the environment where it was created and then imported into any
environment that needs it

© Copyright Microsoft Corporation. All rights reserved.


Describe the connector

To define a connector's actions and triggers, you need to describe the


connector.

© Copyright Microsoft Corporation. All rights reserved.


Work with authenticated APIs

The custom connector architecture supports working with


authenticated APIs.
• No authentication
• Basic authentication
• OAuth 2.0
• API key

© Copyright Microsoft Corporation. All rights reserved.


Work with OAuth 2 authenticated APIs

© Copyright Microsoft Corporation. All rights reserved.


Demo of the maker portal experience

DEMO

© Copyright Microsoft Corporation. All rights reserved.


Explore custom connector configuration options

Connector naming and general information Response

Action and trigger naming Validation

Action visibility Other settings

Request

© Copyright Microsoft Corporation. All rights reserved.


Connector naming and general information

One of the first decisions that you will


make is the name of your connector.

The name should be unique and clarify


what the connector is to the consumer.

© Copyright Microsoft Corporation. All rights reserved.


Action and trigger naming

After a user has narrowed down to your


connector, they will pick an action or
trigger to use from the connector.

© Copyright Microsoft Corporation. All rights reserved.


Action visibility

You can set the visibility option on an


action to influence how the action will
show in the maker experience

• None - This option is the default. The


action will display normally.
• Advanced - The action will be
available but not prioritized.
• Internal - The action will be hidden.
• Important - The action will be
prioritized and will show first.
© Copyright Microsoft Corporation. All rights reserved.
Request

The request defines what


parameters/data will be passed into the
operation when the action invokes the
operation on the API.

© Copyright Microsoft Corporation. All rights reserved.


Response

The response defines what you expect


to be returned from the API.

© Copyright Microsoft Corporation. All rights reserved.


Use a custom connector

Custom connectors can be used


by Power Apps, Power Automate,
and Azure Logic Apps.
Options to deploy the custom
connector into each of the
environments
• Download and import
• Solutions
• Command line

© Copyright Microsoft Corporation. All rights reserved.


Share and move between environments

Methods on how to share the connector Sharing outside the organization


and connections to make them available to • A few options are available for sharing a custom
other users: connector outside of the organization where the
• Logic apps - visible and available to the connector was created:
connector's author and to users. ‒ Certify the custom connector to make it publicly available.
‒ Make the custom connector configuration files open
• Custom connectors that are created as a solution
source.
asset can be moved between environments
‒ Use a solution to transport the connector across.
• Standalone connectors
‒ Create a complete copy of the connector by downloading
‒ Custom connectors that are created outside of a solution and sharing the configuration files.
can be shared explicitly within the same environment.
‒ Custom connectors can be shared with individual users,
user groups, or the entire organization.
‒ Individual connections can also be shared explicitly

© Copyright Microsoft Corporation. All rights reserved.


Module 1 - Summary

• You learned how authentication works to create a connection by using a custom connector and
the connector that is authenticating to the underlying API.

• Custom connectors provide a flexible framework for supporting different types of API
authentication

• When you configure authentication for a custom connector, the connector runtime manages the
authentication process.

© Copyright Microsoft Corporation. All rights reserved.


Module 2: Use Policy Templates

© Copyright Microsoft Corporation. All rights reserved.


Module 2 - Introduction

This module explores using policies with custom connectors and explains how you can configure them
by using policy templates.

In this module, you will


• Use Policy Templates
• Apply policy templates to a custom connector

© Copyright Microsoft Corporation. All rights reserved.


What are policy templates?

Apply policy templates to a custom connector.

You can use policies to perform data conversion, route requests, set parameter values,
and more.

Example use case


By default, the host URL is hardcoded into the connector configuration. A policy,
combined with a connection parameter, allows the host URL to be specified every time
you create a connection by using the connector.

© Copyright Microsoft Corporation. All rights reserved.


Apply a policy

Applying a policy template to a custom


connector allows you to select a policy
that you want to use from a list of
templates

Each selected template will prompt you


to fill out the necessary configuration for
that policy

© Copyright Microsoft Corporation. All rights reserved.


Choose which actions to apply policy

You can choose to have it apply to all


actions and triggers or only for specific
ones.
For example, the set host URL template
is typically applied to all actions and
triggers.

Alternatively, the convert an array to an


object (preview) template might only be
applied to one or two actions that return
similar data.

© Copyright Microsoft Corporation. All rights reserved.


Policy ordering

You can select the ellipsis (...) next to


each policy and move it up or down in
the list.

This feature allows you to configure the


order in which policies are applied at
runtime.

© Copyright Microsoft Corporation. All rights reserved.


Use expressions to access runtime values

Use expressions to access runtime For example,


values @connectionParameters('HostUrl')
would get the value configured for the
connection property HostUrl, which
Functions can access and transform would allow a maker to change the
runtime data from the headers, query, service URL as part of the connection,
and body of the request and response similar to test versus production API
from the API scenarios

© Copyright Microsoft Corporation. All rights reserved.


Module 2 - Summary

• How to use Policy Templates

• How to apply policy templates to a custom connector

© Copyright Microsoft Corporation. All rights reserved.


Module 3: Implement Custom Code

© Copyright Microsoft Corporation. All rights reserved.


Module 3 - Introduction

Use custom code to implement advanced transformation of the input and output of a connector’s
actions

In this module, you will


• Implement Custom Code
• Configure which connector operations use the custom code

© Copyright Microsoft Corporation. All rights reserved.


Use Custom Code with Custom Connectors

Use custom code (C#) to implement advanced transformation of the input and output
of a connector’s actions

Implement custom code to go beyond what policy templates are capable of

By implementing custom code, the logic takes over complete control of the request
and response transformation as well as invoking the operation on the underlying
service

© Copyright Microsoft Corporation. All rights reserved.


Implement custom code

To implement custom code you must public class Script : ScriptBase


create a class named Script and it must {
inherit from the abstract base class public override Task<HttpResponseMessage>
ScriptBase ExecuteAsync()
{
// Your code here
}
}

© Copyright Microsoft Corporation. All rights reserved.


Implementing ExecuteAsync

public override async Task<HttpResponseMessage> ExecuteAsync()


The ExecuteAsync method must provide
{
the full implementation of any
// Create a new response
transformation and invoking the
var response = new HttpResponseMessage();
underlying service
// Set the content
// Initialize a new JObject and call .ToString() to get the serialized JSON
response.Content = CreateJsonContent(new JObject
{
["greeting"] = "Hello World!",
}.ToString());

return response;
}

© Copyright Microsoft Corporation. All rights reserved.


Invoke the underlying service

To invoke the underlying service, you public override async Task<HttpResponseMessage>


ExecuteAsync()
would use the SendAsync method on
{
the context object
HttpResponseMessage response = await
this.Context.SendAsync(this.Context.Request,
this.CancellationToken).ConfigureAwait(continueOnCap
turedContext: false);
return response;
}

© Copyright Microsoft Corporation. All rights reserved.


Configure which operations run the code

You can also control which operations


the custom code is run on by
configuring it to run for specific
operations

By default, once code is enabled, all


operations will run the custom code

© Copyright Microsoft Corporation. All rights reserved.


Exercise: Custom Connectors
In this lab, you will build a custom connector for A Datum’s Risk Score API.

Follow the exercise on GitHub

Time estimate:
1 hour and 30 minutes

© Copyright Microsoft Corporation. All rights reserved.


Exercise: Integrate AI
In this lab, you will be using the AI Builder to process the construction funding request
form document that was emailed to the funding shared mailbox to extract essential
information. The extracted information will be stored in Dataverse for use in the funding
process

Follow the exercise on GitHub

Time estimate:
1 hour and 30 minutes

© Copyright Microsoft Corporation. All rights reserved.


Module 3 - Summary

• How to implement Custom Code on a custom connector

• How to configure which connector operations use the custom code

© Copyright Microsoft Corporation. All rights reserved.


© Copyright Microsoft Corporation. All rights reserved.

You might also like