How do you create a custom connector in solution?
Oct. 28, 2024
Create custom connectors in solutions - Microsoft Learn
Please visit our website for more information on this topic.
Create custom connectors in solutions
In this article
By using solutions, you can move your custom connectorsalong with canvas apps, flows, and Microsoft Dataverse customizationsin a single package. Solutions have the added benefit of managing your customizations in Azure DevOps and automating your CI/CD process.
Get started
Solutions are accessible both from Power Apps and Power Automate.
Prerequisites
You must have a license for Dataverse or Dynamics 365 Customer Engagement and a valid security role granting create access for connectors.
Steps
Select the Solutions tab.
Create a new solution or open an existing unmanaged solution.
Select New > Automation > Custom connector.
A new tab opens, where you create a new custom connector.
When you've finished, select Save.
Close the browser tab. You'll see the new custom connector listed within your solution.
To migrate the custom connector and any other customizations, export your solution, and then import it to the target environment.
Note
You'll need to re-enter credentials required by the connector, and then create connections.
Known limitations
- Dependencies aren't logged.
- Managed properties.
- Backup/restore/copy.
- Custom connectors aren't available in classic solution explorer.
- Custom connectors need to be imported first, before connection references or flows.
- If your environment doesnt contain the custom connector in a solution, import a separate solution that only the custom connectors. Do this importation before you import the actual solution because Azure needs to register the custom connector beforehand.
- If you import a solution that contains custom connectors and flows, Azure won't be able to register the custom connector while it's registering your connection references or flows. This also applies to connection references for the custom connector that wasn't previously imported in a separate solution. If Azure hasn't registered your custom connector, the importation will fail, or you won't be able to start the import.
- Solution custom connectors are created without role assignments by default.
- The Power Apps for Admin connector has the Get Custom Connectors as Admin action that doesn't return solution custom connectors without role assignments. Users can add role assignments to custom connectors through sharing or through the Power Apps for Admin connector.
- Role assignments aren't maintained when you import/export custom connectors across environments. This is because role assignments depend on specific users in the environment. Once the solution custom connector is created, configure role privileges and role based security as needed.
Related information
Build and certify custom connectors
Use solutions in Power Apps
Provide feedback
We greatly appreciate feedback on issues with our connector platform, or new feature ideas. To provide feedback, go to Submit issues or get help with connectors and select your feedback type.
Create a custom connector from scratch
Create a custom connector from scratch
In this article
This article is part of a tutorial series on creating and using custom connectors in Azure Logic Apps, Microsoft Power Automate, and Microsoft Power Apps.
Note
Make sure you read the custom connector overview to understand the process.
To create a custom connector, you must describe the API you want to connect to so that the connector understands the API's operations and data structures. In this topic, you create a custom connector from scratch, without using an OpenAPI definition to describe the Azure Cognitive Services Text Analytics API sentiment operation (our example for this series). Instead, you describe the connector completely in the custom connector wizard.
For another way to describe an API, go to Create a custom connector from an OpenAPI definition.
Note
You can currently create a custom connector from scratch in Power Automate and Power Apps. For Logic Apps, you must start with at least a basic OpenAPI definition.
Prerequisites
An API key for the Cognitive Services Text Analytics API
One of the following subscriptions:
- Power Automate
- Power Apps
Start the custom connector wizard
Sign in to Power Apps or Power Automate.
On the left pane, select Data > Custom connectors.
Select New custom connector > Create from blank.
Enter a name for the custom connector, and then select Continue.
Parameter Value Custom connector title SentimentDemo
From this point, we'll show the Power Automate UI, but the steps are largely the same across the technologies. We'll point out any differences.
On the General tab, do the following:
In the Description field, enter a meaningful value. This description will appear in the custom connector's details, and it can help others decide whether the connector might be useful to them.
Update the Host field to the address for the Text Analytics API. The connector uses the API host and the base URL to determine how to call the API.
Parameter Value Description Uses the Cognitive Services Text Analytics Sentiment API to determine whether text is positive or negative Host westus.api.cognitive.microsoft.com
Step 2: Specify authentication type
There are several options available for authentication in custom connectors. The Cognitive Services APIs use API key authentication, so that's what you specify for this tutorial.
On the Security tab, under Authentication type, select API Key.
Under API Key, specify a parameter label, name, and location. Specify a meaningful label, because this is displayed when someone first makes a connection with the custom connector. The parameter name and location must match what the API expects. Select Connect.
Parameter Value Parameter label API key Parameter name Ocp-Apim-Subscription-Key Parameter location HeaderAt the top of the wizard, make sure the name is set to SentimentDemo, and then select Create connector.
Step 3: Create the connector definition
The custom connector wizard gives you many options for defining how your connector functions, and how it's exposed in logic apps, flows, and apps. We'll explain the UI and cover a few options in this section, but we also encourage you to explore on your own.
Create an action
The first thing to do is create an action that calls the Text Analytics API sentiment operation.
On the Definition tab, the left pane displays any actions, triggers (for Logic Apps and Power Automate), and references that are defined for the connector. Select New action.
There are no triggers in this connector. To learn about triggers for custom connectors, go to Use webhooks with Azure Logic Apps and Power Automate.
The General area displays information about the action or trigger that's currently selected. Add a summary, description, and operation ID for this action.
Parameter Value Summary Returns a numeric score representing the sentiment detected Description The API returns a numeric score between 0 and 1. Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. Operation ID DetectSentimentLeave the Visibility property set to none. This property for operations and parameters in a logic app or flow has the following options:
- none: displayed normally in the logic app or flow
- advanced: hidden under another menu
- internal: hidden from the user
- important: always shown to the user first
The Request area displays information based on the HTTP request for the action. Select Import from sample.
Specify the information necessary to connect to the API, specify the request body (provided after the following image), and then select Import. We provide this information for you, but for a public API, you typically get this information from documentation such as Text Analytics API (v2.0).
Parameter Value Verb POST URL<https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment>
Body Use the following JSON codeExample:
{ "documents": [ { "language": "string", "id": "string", "text": "string" } ] }
The Response area displays information based on the HTTP response for the action. Select Add default response.
Specify the response body, and then select Import. As we did for the request body, we provide this information for you following the image, but it's typically provided in the API documentation.
Example:
{ "documents": [ { "score": 0.0, "id": "string" } ], "errors": [ { "id": "string", "message": "string" } ] }
The Validation area displays any issues that are detected in the API definition. Check the status, and then in the upper-right corner of wizard, select Update connector.
Now let's change a few things so that the connector is more friendly when someone uses it in a logic app, flow, or app.
In the Request area, select body, and then select Edit.
In the Parameter area, you now see the three parameters that the API expects:
id
,language
, andtext
. Select id, and then select Edit.In the Schema Property area, update values for the parameter, and then select Back.
Link to AIKE Electronics
Parameter Value Title ID Description An identifier for each document that you submit Default value 1 Is required YesIn the Parameter area, select language > Edit, and then repeat the process that you used for
Parameter Value Title Language Description The two or four character language code for the text Default value en Is required Yesid
in steps 2 and 3 of this procedure, with the following values.In the Parameter area, select text > Edit, and then repeat the process that you used for
Parameter Value Title Text Description The text to analyze for sentiment Default value None Is required Yesid
in steps 2 and 3 of this procedure, with the following values.In the Parameter area, select Back to take you back to the main Definition tab.
In the upper-right corner of the wizard, select Update connector.
Step 4: (Optional) Enable your connector as an AI plugin
Use the AI Plugin (preview) tab for a connector only if you're planning to certify your connector. In order for a connector to be used as an AI plugin, the connector must be certified.
Before you enable your connector as an AI plugin, ensure you understand the use case for AI plugin scenarios and have reviewed other considerations such as supportability, best practices, and recommendations. More information: Create a connector AI plugin (preview)
On the left navigation pane, select Custom connectors.
If you don't see Custom connectors, select More > Discover all > Custom connectors. The option appears on the left navigation pane.
In the upper right, select an option from the New vcustom connector menu.
Make sure you've completed Step 1, Step 2, and Step 3 in this article.
Select the AI Plugin (preview) tab.
In the Plugin manifest section, enter details to enable this connector as an AI plugin.
Scroll down to the Plugin Actions Details section and enter the action details for each action in your connector AI plugin.
Tip
If you need help defining your actions, turn on the Swagger editor toggle.
Scroll down to the Parameter section and enter the parameter details for your connector AI plugin.
in the Request section below the AI Plugin (preview) sections, select the input parameter, and then enter a description.
Step 5: (Optional) Use custom code support
Custom code transforms request and response payloads beyond the scope of existing policy templates. Transformations include sending external requests to fetch additional data. When code is used, it will take precedence over the codeless definition. This means that the code will execute, and we won't send the request to the back end.
Note
- This step is optional. You can complete the codeless experience for creating your connector by ignoring this step and going to Step 6: Test the connector.
- Custom code support is available in public preview.
You can either paste in your code or upload a file with your code. Your code must:
- Be written in C#.
- Have a maximum execution time of five seconds.
- Have a file size no larger than 1 MB.
For instructions and samples of writing code, go to Write code in custom connectors.
For frequently asked questions about custom code, go to Custom code FAQ.
On the Code tab, insert your custom code by using one of the following options:
- Copy/paste
- Select the Upload button.
If you choose to upload your custom code, only files with a .cs or .csx extension will be available.
Important
Currently, we only support syntax highlighting in the code editor. Make sure to test your code locally.
After you paste or upload your code, select the toggle next to Code Disabled to enable your code. The toggle name changes to Code Enabled.
You can enable or disable your code anytime. If the toggle is Code Disabled, your code will be deleted.
Select the actions and triggers to apply to your custom code by selecting an option in the dropdown menu. If no operation is selected, the actions and triggers are applied to all operations.
Step 6: Test the connector
Now that you've created the connector, test it to make sure it's working properly. Testing is currently available only in Power Automate and Power Apps.
Important
When using an API key, we recommend against testing the connector immediately after you create it. It can take a few minutes until the connector is ready to connect to the API.
On the Test tab, select New connection.
Enter the API key from the Text Analytics API, and then select Create connection.
Note
For APIs that require bearer authentication, add Bearer and one space before the API key.
Return to the Test tab, and do one of the following:
(In Power Automate) You're taken back to the Test tab. Select the refresh icon to make sure the connection information is updated.
(In Power Apps) You're taken to the list of connections available in the current environment. On the left pane, select Data > Custom connectors. Choose the connector you created, and then go back to the Test tab.
On the Test tab, enter a value for the text field (the other fields use the defaults that you set earlier), and then select Test operation.
The connector calls the API, and you can review the response, which includes the sentiment score.
(For CLI users) Best practices
Download all your connectors, and use Git or any source code management system to save the files.
If there's an incorrect update, redeploy the connector by rerunning the update command with the correct set of files from the source code management system.
Test the custom connector and the settings file in a test environment before deploying in the production environment.
Always double-check that the environment and connector ID are correct.
Next steps
Now that you've created a custom connector and defined its behaviors, you can use the connector from:
You can also share a connector within your organization, or get the connector certified so that people outside your organization can use it.
Provide feedback
We greatly appreciate feedback on issues with our connector platform, or new feature ideas. To provide feedback, go to Submit issues or get help with connectors and select your feedback type.
For more custom Connectors for Consumer Electronicsinformation, please contact us. We will provide professional answers.
15
0
0
Comments
All Comments (0)