I have the following Azure Function triggered by an HTTP call:
public static class MyAzureFunction
{
[FunctionName("api/v1/resource/")]
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get")]HttpRequestMessage request, ILogger logger)
{
// Extract query string params from the request...
}
}
I would like to have the parameters to be automatically passed to the Run method, the same way it is being done with ASP.NET Core Web API, instead of having to extract them from the request itself and parse them.
Here is an example of what I would like to get:
[FunctionName("api/v1/resource/{resourceId}")]
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get")]HttpRequestMessage request, ILogger logger, int resourceId)
{
// ...
}
Or, when doing a POST:
[FunctionName("api/v1/resource/")]
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "post")]HttpRequestMessage request, ILogger logger, [FromBody] SomeEntityModel entityModel)
{
// ...
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…