我有一个 Azure Function v2。该函数由 POST HTTP 请求触发,并获得一个帐户列表。
这是 Azure 函数:
public sealed class AccountFunction
{
private readonly ILogger m_logger;
public AccountFunction(ILoggerFactory loggerFactory)
{
m_logger = loggerFactory.CreateLogger<AccountFunction>();
}
[FunctionName("AccountFunction")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "v1/accounts")] List<Account> accounts)
{
m_logger.LogInformation("C# HTTP trigger function processed a request.");
return new OkObjectResult(accounts);
}
}
Account 类是一个简单的 POCO:
public class Account
{
public string Name { get; set; }
public string Description { get; set; }
}
我启动该函数,然后发送以下 POST 请求:
http://localhost:7071/api/v1/accounts
我在请求正文中设置了 JSON 集合:
[{
"name":"A",
"description":"covfefe"
},
{
"name":"B",
"description":"huuuggge"
}]
当年话下
相关分类