[英]Integrate http trigger powershell azure Function app with app gateway
I have an http trigger azure function.I created an app gateway and routed it to function app and it seems working.我有一个 http 触发器 azure function。我创建了一个应用程序网关并将其路由到 function 应用程序,它似乎可以正常工作。 But how can I route to http trigger function app?
但是我怎样才能路由到 http 触发 function 应用程序?
We can update or override the route for our Http Triggered Azure function by modifying the route parameter in the function1.cs.我们可以通过修改 function1.cs 中的路由参数来更新或覆盖我们的 Http Triggered Azure function 的路由。 By default the route parameter is assigned as null.
默认情况下,路由参数分配为 null。
Suppose we want the route to send a request to our Azure function as localhost:7071/api/hello then we would need to simply assign the route parameter as hello.假设我们希望路由将请求发送到我们的 Azure function 作为 localhost:7071/api/hello 那么我们只需要将路由参数分配为 hello。
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Hello")] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}. This HTTP triggered function executed successfully.";
return new OkObjectResult(responseMessage);
}
}
Check the Http Trigger Function for complete information about routing.检查Http 触发器 Function以获取有关路由的完整信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.