简体   繁体   English

集成http触发器powershell azure Function应用网关

[英]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.

相关问题 Azure Function 事件中心不触发应用程序 - Azure Function App does not trigger by Event Hub 如何使用 HTTP 触发器解析 Azure Function App 中的多部分表单数据? (节点) - How to parse Multi-part form data in an Azure Function App with HTTP Trigger? (NodeJS) Azure Function 应用程序 HTTP 触发函数在部署时不显示 - Azure Function App HTTP Trigger Functions don't show when deployed Azure Function App v4 Blob 触发并发 - Azure Function App v4 Blob Trigger Concurrency 在 Azure Function 运行时使用 Logic App Standard 触发执行警告 - Trigger execution warnings with Logic App Standard on Azure Function Runtime Azure App Gateway - 后端运行状况 404 错误 - Azure App Gateway - Backend Health 404 error 重写规则不适用于 Azure App Gateway - Rewrite Rule is not working on Azure App Gateway 在 http 请求中使用 AD 应用注册 azure function - using AD app registration in http request in an azure function 从逻辑应用触发 Azure 操作组 - Trigger Azure Action Group from a Logic App 是否可以在 Azure 逻辑应用程序工作流中触发 Azure function 和 Python 运行时? - Is it possible to trigger an Azure function with Python runtime inside a Azure Logic App workflow?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM