In this section, we will focus on defining custom connectors in Azure. When you define a custom connector, you need to define the base URL for your API, the operations your API supports, and any data types your API uses.

  • Base URL: This is the base URL for service calls. All operation URLs are relative to this base URL. The base URL includes the protocol (http or https), the hostname, and optionally the port number and base path.
  • Operations: Operations are the actions for your connector, such as Read, Create, Update, and Delete.
  • Data Types: Data types are input and output parameters for your operations. You can specify a data type for each parameter.

Table of Contents

Creating a Custom Connector

Here is a step by-step guide to creating a custom connector from an Azure Service:

  1. Select the API: In the Azure portal, select the Azure service where you want to add the connector.
  2. Define the connector: On the custom connectors page, select New custom connector and then Enter URL for the Swagger definition of the API.
  3. Upload the connector: Upload a Swagger metadata document or manually enter the details.
  4. Define the connection: You are required to specify the general information and security details for the connector.
  5. Define actions and triggers: You can now define the operations (actions and triggers) supported by your API.
  6. Test the connector: Finally, test the connector to ensure that it’s working as expected.

To provide a practical example, let’s consider the creation of a custom connector for Azure’s Text Analytics API.

public class TextAnalyticsConnector
{
private static readonly string textAnalyticsApiKey = "";
private static readonly string textAnalyticsBaseUrl = "";

public static SentimentResponse GetSentiment(SentimentRequest request)
{
string sentimentApiUrl = $"{textAnalyticsBaseUrl}/sentiment";
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", textAnalyticsApiKey);
HttpResponseMessage response = client.PostAsJsonAsync(sentimentApiUrl, request).Result;

if (response.IsSuccessStatusCode)
{
var sentimentResponse = response.Content.ReadAsAsync().Result;
return sentimentResponse;
}

throw new Exception($"Failed to get sentiment. Status code: {response.StatusCode}");
}
}

This piece of code constitutes a custom connector capable of connecting to Azure’s Text Analytics service. It proceeds to retrieve sentiment analysis through the ‘GetSentiment()’ function, given a ‘SentimentRequest’.

Benefits of Custom Connectors

Creating custom connectors comes with several benefits:

  1. Gaps in connector ecosystem: Custom connectors can fill any gaps in the connector ecosystem, allowing any service with a web-accessible API to be used in applications and flows.
  2. Ease of use: Custom connectors abstract the underlying service by presenting a list of available operations with associated input and output parameters.
  3. Code reusability: Through the client libraries’ use, developers can increase code reusability across different Azure services.

As you delve deeper into custom connectors for Azure services in preparation for the PL-400 exam, remember to combine this knowledge with practical examples. This encourages better understanding and mastery for the certification exam.

Practice Test

True or False: A custom connector can be created in Azure for services that have an API.

  • True
  • False

Answer: True

Explanation: Custom connectors in Azure are created to bridge between different services utilizing their APIs.

Which of the following is a method in which you can create a custom connector in Azure Logic Apps?

  • a) By using a Postman collection.
  • b) By using an OpenAPI definition.
  • c) By defining the connector directly within an app.
  • d) All of the above.

Answer: d) All of the above.

Explanation: You can use any of the methods stated to create a custom connector: Postman collection, OpenAPI definition, or directly within an app.

True or False: Custom connectors in Azure cannot interact with on-premises data.

  • True
  • False

Answer: False

Explanation: Custom connectors can be created to interact with on-premises data using the On-premises data gateway.

What is the role of a connector in Azure Logic Apps?

  • a) Manage a process.
  • b) Hold data.
  • c) Connect two components.
  • d) Run a script.

Answer: c) Connect two components.

Explanation: Connectors in Azure Logic Apps enable you to connect and interact with different services seamlessly.

In Azure, what language is used to create an OpenAPI definition for a custom connector?

  • a) Python
  • b) JavaScript
  • c) JSON
  • d) Java

Answer: c) JSON

Explanation: OpenAPI definitions for custom connectors are created using JSON language.

True or False: A custom connector for an Azure service needs the service to have an OpenAPI definition.

  • True
  • False

Answer: False

Explanation: An OpenAPI definition simplifies the process but it’s not a requirement. A custom connector can be created without an OpenAPI definition.

Which of the following is not a property of a custom connector in Azure?

  • a) Description
  • b) Host
  • c) Schema
  • d) Security

Answer: c) Schema

Explanation: Schema is not a property of a custom connector. Connectors have different properties which include description, host and security.

True or False: You can use a custom connector in Power Apps and Power Automate.

  • True
  • False

Answer: True

Explanation: Custom connectors created can be utilized across Microsoft Power Platform, including Power Apps and Power Automate.

What is the primary purpose of creating a custom connector?

  • a) To improve the performance of applications.
  • b) To connect and interact with different services.
  • c) To design a new user interface.
  • d) To build a new database.

Answer: b) To connect and interact with different services.

Explanation: The main purpose of a custom connector is to enable interaction between various services.

True or False: A custom connector’s API definition includes its base URL and its operations.

  • True
  • False

Answer: True

Explanation: The API definition of a custom connector includes its base URL and all operations that describe how to interact with the API.

What security authentication does Azure support when creating a custom connector?

  • a) None
  • b) API Key
  • c) OAuth 0
  • d) All of the above

Answer: d) All of the above

Explanation: Azure supports several types of authentication for custom connectors including None, API Key, and OAuth

True or False: Custom Connectors in Azure can access services that don’t have a publicly available API.

  • True
  • False

Answer: False

Explanation: Custom connectors rely on publicly available APIs to establish connections and interact with services.

Custom connectors in Azure are used along with which service to perform tasks?

  • a) Azure Logic Apps
  • b) Azure Functions
  • c) Azure Data Factory
  • d) Azure SQL Database

Answer: a) Azure Logic Apps

Explanation: Azure Logic Apps uses custom connectors to create workflows that can interact with multiple services.

True or False: You must manually update the custom connector every time the API it connects to is updated.

  • True
  • False

Answer: True

Explanation: When an API updates, you must manually update the custom connector to ensure it matches the new API specifications.

When creating a custom connector in Azure, you can create a connector from?

  • a) Blank
  • b) An OpenAPI file
  • c) An Azure service
  • d) All of the above

Answer: d) All of the above

Explanation: You can create a custom connector from blank, an OpenAPI file or from an existing Azure service.

Interview Questions

What is a custom connector in Azure?

A custom connector is essentially a wrapper around a REST API that allows the Power Platform to communicate with that API.

What are the basic steps in creating a custom connector for Azure services?

The basic steps involve describing the API by defining the host, base URL, security, actions, and triggers, defining input/output parameters for actions and triggers, creating a connector from an OpenAPI definition, Postman collection, or from scratch, and finally, testing the custom connector in Power Apps or Power Automate.

How can you authenticate to your connector in Azure?

Azure supports a variety of authentication types, including Anonymous, Basic authentication, API Key, and OAuth 2.0.

In Azure, how do you define the actions a custom connector should take?

In Azure, actions are defined by detailing the operation ID, request method and URL, query parameters, headers, and response properties and types.

What is the OpenAPI definition in creating custom connectors on Azure?

OpenAPI definition is a file format for describing APIs. Azure uses the definition to create a custom connector.

Is testing a newly created custom connector necessary and why?

Yes, testing the connector is necessary to make sure that the API you built is working correctly and to validate that the operations defined programmatically function as expected.

How do you test a custom connector in Azure?

In Azure, you test your custom connector by creating a connection, creating an operation, and passing in parameters and executing requests.

What is the use of Postman collections in Azure custom connector service?

Postman collections provide a group of related requests that call the API, and these collections can be used directly within Azure to create a custom connector.

What is the importance of defining the correct response properties and types when creating a custom connector?

Defining the correct response properties and types is critical as it determines how the data returned from an API call can be consumed in Power Platform.

Can you update or modify a custom connector once created?

Yes, you can update or modify a custom connector in Azure by navigating to the custom connector page, making necessary adjustments, and saving the changes.

What is the role of API keys in the creation of custom connectors?

An API Key allows you to authenticate your custom connector. It can be included in the connector definition or provided by users when they create a connection.

What are “triggers” in the context of Azure custom connectors?

Triggers define which events start workflows. The API needs to support webhooks to include triggers in the connector.

What is the difference between creating a custom connector from scratch and from an OpenAPI definition?

When creating a custom connector from an OpenAPI definition or a Postman Collection, Azure can automate much of the process by pulling in the necessary details, whereas creating a custom connector from scratch requires manually defining the API’s host, base URL, security scheme, actions, and triggers.

What is the significance of the operation ID when defining connector actions?

The operation ID is important in differentiating each unique action the connector can take. It’s used to generate the action’s name and should be unique within the connector.

What are the potential security options for custom connectors in Azure?

Azure supports a range of security options including OAuth 2.0, API key, basic authentication, and anonymous access. The choice depends on the security mechanism supported by the API you are wrapping.

Leave a Reply

Your email address will not be published. Required fields are marked *