Amazon web services 将.Net核心Web API移动到AWS Web API网关
我有一个用.NETCore开发的Web API,它有几个端点(GET/POST)。要求将其移动到AWS API网关。WebAPI是使用分层体系结构构建的,它有一个业务层,与数据库层对话,数据库层拥有一些实体框架存储库(后端数据库postgre)。现在,我已经将我的解决方案重新创建为AWS无服务器解决方案(使用AWS visual studio工具包附带的一个模板项目) 问题是如何启用我的web api方法AWS api Gatway?我尝试将我的web api发布到AWS,但它在api网关中创建了一个空白api(Visual studio说已成功发布),这意味着由于某些原因,api网关无法识别我的解决方案中的端点,我认为原因是我不知道如何正确配置它们并使它们启用AWS-api网关 第二个问题是 模型绑定将如何在AWS API-GATEWAY中工作。我应该使用映射模板来实现模型绑定,还是使用内置的.net核心web api模型绑定来实现模型绑定 下面是一个开发的Web API示例,需要部署到AWS API网关Amazon web services 将.Net核心Web API移动到AWS Web API网关,amazon-web-services,aws-api-gateway,asp.net-core-webapi,Amazon Web Services,Aws Api Gateway,Asp.net Core Webapi,我有一个用.NETCore开发的Web API,它有几个端点(GET/POST)。要求将其移动到AWS API网关。WebAPI是使用分层体系结构构建的,它有一个业务层,与数据库层对话,数据库层拥有一些实体框架存储库(后端数据库postgre)。现在,我已经将我的解决方案重新创建为AWS无服务器解决方案(使用AWS visual studio工具包附带的一个模板项目) 问题是如何启用我的web api方法AWS api Gatway?我尝试将我的web api发布到AWS,但它在api网关中创建
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace TestApi
{
[Route("api/testapi")]
public class TestApiController : Controller
{
private ITestApiManager testApiManager;
public TestApiController(ITestApiManager testApiManager)
{
this.testApiManager = testApiManager;
}
// GET: api/testapi/data/D-001
[HttpGet]
[Route("data/{param}")]
public IActionResult SomeMethod(string param)
{
// This method access busines layer which calls data access layer to get the data from postgress database using entity framework
}
// There are some more similar GET and POST methods in this api as well
}
}
好的,我回答我自己的问题,以防万一其他人正在寻找相同的信息。我的端点在API网关上不可用的原因是,我的lambda处理程序没有完全合格,我必须在serverless.template文件中配置Proxy+部分 对于serverless.template文件,请检查Resources>AspNetCoreFunction>Handler属性。它应该有这种格式
"Handler": "<your-web-api-project-name>::<namespace-for-your-lambda>.<lambda-class-name>::FunctionHandlerAsync"
"Events": {
"ProxyResource": {
"Type": "Api",
"Properties": {
"Path": "/{proxy+}",
"Method": "ANY"
}
},
"RootResource": {
"Type": "Api",
"Properties": {
"Path": "/",
"Method": "ANY"
}
}