使用Azure API Management, Functions, Power Apps和Logic App构建应用

ASP.NET OpenAPI 可以非常方便的将我们的Web API项目自动文档化,除了自动文档化以外,我们还可以利用Azure API Management将Open API自动文档化了的Web API整合到当下最火的低代码应用当中,在这篇文章中,我将向您展示如何使用Azure API Management将Azure Functions,Power Apps和Logic Apps等等Azure Service 串联在一起。Azure API Management能够利用已文档化的API定义来公开我们的API 端点,这些端点可以轻松使用在低代码的应用程序中。来看看这有多简单:

使用Azure API Management, Functions, Power Apps和Logic App构建应用

 

将您的API导入Azure API Management

随着Visual Studio 2019 16.9的发布,我们增加了对发布到现有Azure API Management服务实例以及创建Azure API Management的新消费模式实例的支持,所以只要您是Azure的客户,您就可以在需要时使用API Management的监视,安全和集成功能。

 

当您发布一个已经整合了Swashbukle.AspNetCore(在ASP.NET Core 5 Web API项目中为默认整合选项)的.NET Core API项目到Azure App Service的时候,Azure API Management 选项卡就会出现在发布对话框中,你可以选择一个现成的Azure API Management实例,也可以新建一个实例。

 

使用Azure API Management, Functions, Power Apps和Logic App构建应用

 

发布完成后,您将能够直接在Azure API Management门户中测试您的API。在这里,您还可以监测流量,控制访问权限并将API导出到其他服务(本文的下一部分中将介绍如何将API导出到其他服务)。

注:Visual Studio中只能新建Azure API Management的消费模式实例。这是Azure API Management的轻量级,无服务器版本,按执行次数收费,每月提供100万次免费调用。如果有现有的Azure API Management实例,也可以将其导入其中。该功能可用于Azure API Management的任何服务级别。  

使用Azure API Management, Functions, Power Apps和Logic App构建应用

 

如果您不熟悉Azure API Management,您可以在docs.microsoft.com上了解更多有关使用Visual Studio或Visual Studio Code将API发布到Azure API Management中的信息。    

Azure API Management:

https://translate.google.com/translate?hl=zh-CN&prev=_t&sl=en&tl=zh-CN&u=https://azure.microsoft.com/services/api-management/%3FWT.mc_id%3Ddotnet-13135-bradyg

Azure API Management的轻量级,无服务器版本,按执行次数收费,每月提供100万次免费调用:

https://azure.microsoft.com/pricing/details/api-management/?WT.mc_id=dotnet-13135-bradyg

Visual Studio:

https://translate.google.com/translate?hl=zh-CN&prev=_t&sl=en&tl=zh-CN&u=https://docs.microsoft.com/aspnet/core/tutorials/publish-to-azure-api-management-using-vs%3Fview%3Daspnetcore-5.0%26WT.mc_id%3Ddotnet-13135-bradyg

Visual Studio Code:

https://translate.google.com/translate?hl=zh-CN&prev=_t&sl=en&tl=zh-CN&u=https://docs.microsoft.com/azure/api-management/visual-studio-code-tutorial%3FWT.mc_id%3Ddotnet-13135-bradyg

使用您的API和Logic Apps构建工作流程

发布包含OpenAPI的Web API或Azure Functions(包含在本文后附的示例代码库)之后,就可以使用Azure Logic Apps将它们用于业务工作流,定时任务或事件触发的流程中。Logic Apps设计器会自动选择导入现有Azure API Management服务实例中的所有API,从而轻松确定可用的API。

使用Azure API Management, Functions, Power Apps和Logic App构建应用

由于Logic Apps设计器知道如何为我在API Management中导入的API绘制OpenAPI文档化的定义,因此很容易弄清楚我需要调用哪个API才能创建重复的库存检查流程。

使用Azure API Management, Functions, Power Apps和Logic App构建应用

使用Azure Functions扩展工作流

通过引入Azure Functions的OpenAPI扩展,您能像在WebAPI Controllers中利用NSwag和Swashbukle导出OpenAPI的描述一样, 从Azure Functions中导出你的OpenAPI描述。在示例代码中,您会发现一个通知功能,该功能可以构建一个Adaptive Cards,总结低档产品的库存状态。使用该OpenAPI的扩展的功能属性,Azure Function就可以使用OpenAPI进行文档化描述并导入到Azure API Management了。 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpfwyg.html