ASP.NET OpenAPI makes it very convenient to automatically document our Web API projects. In addition to automatic documentation, we can also use Azure API Management to integrate the OpenAPI automatically documented Web API into the most popular low-code applications. In this article, I’ll show you how to use Azure API Management to string together Azure Functions, Power Apps, Logic Apps, and other Azure Services. Azure API Management is able to leverage documented API definitions to expose our API endpoints, which can be easily used in low-code applications. Here’s how easy it is:

Import your API into Azure API Management

With Visual Studio 2019 16.9, we’ve added support for publishing to existing Azure API Management service instances as well as creating new consumption pattern instances of Azure API Management, so as long as you’re an Azure customer, You can then use API Management’s monitoring, security and integration capabilities as needed.

When you publish an integrated Swashbukle.AspNetCore(the default integration option in the ASP.NET Core 5 Web API project). When a NET Core API project goes to Azure App Service, the Azure API Management TAB will appear in the Publish dialog. You can select an existing Azure API Management instance or create a new one.

Once the release is complete, you will be able to test your API directly in the Azure API Management portal. Here, you can also monitor traffic, control access, and export the API to other services (how to export the API to other services is covered in the next section of this article).

Note: Only Azure API Management consumption mode instances can be created in Visual Studio. This is a lightweight, serverless version of Azure API Management that charges per execution and offers 1 million free calls per month. If you have an existing Azure API Management instance, you can import it there as well. This feature can be used at any service level of Azure API Management.

If you’re not familiar with Azure API Management, You can learn more about publishing apis to Azure API Management using Visual Studio or Visual Studio Code at Docs.microsoft.com.

Azure API Management:

Translate.google.com/translate?h…

A lightweight, serverless version of Azure API Management that charges per execution and provides 1 million free calls per month:

Azure.microsoft.com/pricing/det…

Visual Studio:

Translate.google.com/translate?h…

The Visual Studio Code:

Translate.google.com/translate?h…

Build the workflow using your API and Logic Apps

Once you publish Web apis or Azure Functions that include OpenAPI (included in the sample code base attached to this article), you can use Azure Logic Apps to use them in business workflows, scheduled tasks, or event-triggered processes. The Logic Apps Designer automatically selects all the apis in an existing Azure API Management service instance to be imported, making it easy to determine which apis are available.

Since the Logic Apps designer knows how to draw an OpenAPI documented definition for the API I import in API Management, it’s easy to figure out which API I need to call to create a repeating inventory check process.

Extend workflows with Azure Functions

By introducing the OpenAPI extension to Azure Functions, you can export your OpenAPI description from Azure Functions just as you can export the OpenAPI description from The WebAPI Controllers using NSwag and Swashbukle. In the sample code, you’ll find a notification function that builds Adaptive Cards that summarize the inventory status of low-end products. Using the extended functionality properties of the OpenAPI, Azure Function can be documented using OpenAPI and imported into Azure API Management.

public static class InventoryNotifier{[OpenApiOperation(operationId: nameof(SendLowStockNotification), Visibility = OpenApiVisibilityType.Important)]
    [OpenApiRequestBody(contentType: "application/json",
      bodyType: typeof(Product[]),
      Required = true] [FunctionName(nameof(SendLowStockNotification))]
    public static async Task<IActionResult> SendLowStockNotification(
        [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
        ILogger log)
    {
      // function code...}}Copy the code

Once imported into Azure API Management, we can use these Azure functions in complex Workflows such as Logic apps. For example, I can design a workflow in Azure Portal that can use a mixture of pure Web API and Azure Function exported to Azure API Management using OpenAPI.

Sample code base:

Translate.google.com/translate?h…

OpenAPI:

Translate.google.com/translate?h…

The Adaptive Cards:

Translate.google.com/translate?h…

Use your API to build Power Apps

If you’re building ASP.NET Core Web API and Azure Functions in an environment using Office 365 and Power Apps, Azure API Management can leverage your HTTP API development talents. The API Management APIs can be easily exported to the Power Platform as custom connectors.

Here, I’ve started building a mobile application that can be distributed to any user in Microsoft 365 Tenant. Since it’s just beginning, I quickly added the custom connector I just created that will connect the Power Platform to the API hosted in Azure. When I add the new Refresh button, I call the ClearCollect method to clear the productsCollection variable from the formula input box that appears when I mouse over it. The collection is then repopulated using the StoreAPIs.GetProducts operation.

The advantage of Power Apps is that it can be data bound even in design mode. As a result, when I developed the application, I didn’t have to re-run it over and over, and the data was always bound to the right controls.

If you are not familiar with how to use OpenAPI to document your API, you can refer to our previous post:

Create discoverable HTTP apis using ASP.NET Core 5 Web API

Translate.google.com/translate?h…

Open source HTTP API packages and tools

Translate.google.com/translate?h…

Generate the HTTP API client using Visual Studio Connected Services

Translate.google.com/translate?h…

Building applications with Azure API Management, Functions, Power Apps and Logic Apps (this article)

conclusion

In this series of articles, we started with some general guidelines for ensuring proper documentation of apis using OpenAPI, and then discussed various open source projects and tools that can help you design, build, and test apis more easily. Finally, I showed you how to use these documented apis in various application build and integration scenarios. Hopefully, this will give you some new tips and some inspiration to make building apis and applications more enjoyable for future projects.

What’s next?

We’re excited to be able to share the entire end-to-end with you in this series. NET HTTP API developer experience. Hopefully you’ve seen it. NET helps you build high-quality apis that integrate well with industry standards and specifications, community projects, and Microsoft tools such as Visual Studio and Azure.

If you are experienced. NET developers, can be in. NET documentation for more advanced topics, or check out the source code in this blog series.

The.net document:

Translate.google.com/translate?h…

In this blog series:

Translate.google.com/translate?h…

The source code:

Translate.google.com/translate?h…