title | description | author | manager | editor | services | documentationcenter | ms.assetid | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Create custom connectors from Web APIs - Azure Logic Apps | Microsoft Docs |
Build custom connectors from Web APIs |
ecfan |
anneta |
logic-apps |
logic-apps |
logic-apps |
na |
na |
article |
09/22/2017 |
LADocs; estfan |
To build a custom connector that you can use in Azure Logic Apps, Microsoft Flow, or Microsoft PowerApps, first create a Web API that you can host with Azure Web Apps, authenticate with Azure Active Directory, and register as a connector with Logic Apps, Flow, or PowerApps. This tutorial shows you how to perform these tasks by building an ASP.NET Web API app. For patterns that show you can structure code for your connector's triggers and actions, see Create custom APIs that you can call from logic app workflows.
-
Visual Studio 2013 or later. This tutorial uses Visual Studio 2015.
-
Code for your Web API. If you don't have any, try this tutorial: Getting Started with ASP.NET Web API 2 (C#).
-
An Azure subscription. If you don't have a subscription, you can start with a free Azure account. Otherwise, sign up for a Pay-As-You-Go subscription.
For this tutorial, create a Visual C# ASP.NET web application.
-
Open Visual Studio, then choose File > New Project.
-
Expand Installed, go to Templates > Visual C# > Web, and select ASP.NET Web Application.
-
Provide a project name, location, and solution name for your app, then choose OK.
For example:
-
-
In the New ASP.NET Web Application box, select the Web API template. If not already selected, select Host in the cloud. Choose Change Authentication.
-
Select No Authentication, and choose OK. You can set up authentication later.
-
When the New ASP.NET Web Application box reappears, choose OK.
-
In the Create App Service box, review the hosting settings described in the table, make the changes you want, and choose Create.
An App Service plan represents a collection of physical resources used for hosting apps in your Azure subscription. Learn about App Service.
Setting Suggested value Description Your Azure work or school account, or your personal Microsoft account your-user-account Select your user account. Web App Name custom-web-api-app-name or the default name Enter the name for your Web API app, which is used in your app's URL, for example: http://web-api-app-name. Subscription Azure-subscription-name Select the Azure subscription that you want to use. Resource Group Azure-resource-group-name Select an existing Azure resource group, or if you haven't already, create a resource group. Note: An Azure resource group organizes Azure resources in your Azure subscription.
App Service Plan App-Service-plan-name Select an existing App Service plan, or if you haven't already, create a plan. If you create an App Service Plan, specify these settings:
Setting Suggested value Description Location deployment-region Select the region for deploying your app. Size App-Service-plan-size Select your plan size, which determines the cost and computing resource capacity for your service plan. To set up any other resources required by your app, choose Explore additional Azure services.
Setting Suggested value Description Resource Type Azure-resource-type Select and set up any additional resources required by your app. -
After Visual Studio deploys your project, build the code for your app.
To connect your Web API app to Logic Apps, you need an OpenAPI (formerly Swagger) file that describes your API's operations. You can write your own OpenAPI definition for your API with the Swagger online editor, but this tutorial uses an open source tool named Swashbuckle.
-
If you haven't already, install the Swashbuckle Nuget package in your Visual Studio project.
-
In Visual Studio, choose Tools > NuGet Package Manager > Package Manager Console.
-
In the Package Manager Console, go to your app's project directory if you're not there already (run
Set-Location "project-path"
), and run this PowerShell commandlet:Install-Package Swashbuckle
For example:
[!TIP] If you run your app after installing Swashbuckle, Swashbuckle generates an OpenAPI file at this URL:
http://{your-web-api-app-root-URL}/swagger/docs/v1
Swashbuckle also generates a user interface at this URL:
http://{your-web-api-app-root-URL}/swagger
-
-
When you're ready, publish your Web API app to Azure. To publish from Visual Studio, right-click your web project in Solution Explorer, choose Publish..., and follow the prompts.
[!IMPORTANT] Duplicate operation IDs make an OpenAPI document invalid. If you used the sample C# template, the template repeats this operation ID twice:
Values_Get
To fix this problem, change one instance to
Value_Get
and republish. -
Get the OpenAPI document by browsing to this location:
http://{your-web-api-app-root-URL}/swagger/docs/v1
You can also download a sample OpenAPI document from this tutorial. Make sure that you remove the comments, which starting with "//", before you use the document.
-
Save the content as a JSON file. Based on your browser, you might have to copy and paste the text into an empty text file.