• <legend id='D6Nr6'><style id='D6Nr6'><dir id='D6Nr6'><q id='D6Nr6'></q></dir></style></legend>

    1. <tfoot id='D6Nr6'></tfoot>
      1. <i id='D6Nr6'><tr id='D6Nr6'><dt id='D6Nr6'><q id='D6Nr6'><span id='D6Nr6'><b id='D6Nr6'><form id='D6Nr6'><ins id='D6Nr6'></ins><ul id='D6Nr6'></ul><sub id='D6Nr6'></sub></form><legend id='D6Nr6'></legend><bdo id='D6Nr6'><pre id='D6Nr6'><center id='D6Nr6'></center></pre></bdo></b><th id='D6Nr6'></th></span></q></dt></tr></i><div id='D6Nr6'><tfoot id='D6Nr6'></tfoot><dl id='D6Nr6'><fieldset id='D6Nr6'></fieldset></dl></div>

        <small id='D6Nr6'></small><noframes id='D6Nr6'>

        • <bdo id='D6Nr6'></bdo><ul id='D6Nr6'></ul>

        如何识别用于调用 Azure 函数的 HTTP 方法(动词)

        How to identify the HTTP method (verb) used to invoke an Azure Function(如何识别用于调用 Azure 函数的 HTTP 方法(动词))

          <legend id='eUUgC'><style id='eUUgC'><dir id='eUUgC'><q id='eUUgC'></q></dir></style></legend><tfoot id='eUUgC'></tfoot>

          <small id='eUUgC'></small><noframes id='eUUgC'>

              <tbody id='eUUgC'></tbody>
                <i id='eUUgC'><tr id='eUUgC'><dt id='eUUgC'><q id='eUUgC'><span id='eUUgC'><b id='eUUgC'><form id='eUUgC'><ins id='eUUgC'></ins><ul id='eUUgC'></ul><sub id='eUUgC'></sub></form><legend id='eUUgC'></legend><bdo id='eUUgC'><pre id='eUUgC'><center id='eUUgC'></center></pre></bdo></b><th id='eUUgC'></th></span></q></dt></tr></i><div id='eUUgC'><tfoot id='eUUgC'></tfoot><dl id='eUUgC'><fieldset id='eUUgC'></fieldset></dl></div>
                  <bdo id='eUUgC'></bdo><ul id='eUUgC'></ul>

                  本文介绍了如何识别用于调用 Azure 函数的 HTTP 方法(动词)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  通过 Azure 门户,我们可以轻松创建函数应用程序.创建 Function App 后,我们可以向该应用添加功能.

                  From the Azure Portal, we can easily create Function Apps. Once the Function App is created, we can add functions to the app.

                  就我而言,从自定义模板中,我选择了 C#、API 和Webhook,然后选择 Generic Webhook C# 模板.

                  In my case, from the custom templates, I'm selecting C#, API & Webhooks, and then selecting the Generic Webhook C# template.

                  在集成"菜单中,在 HTTP 标头 标题下,有一个带有 2 个选项的下拉框:所有方法和选定方法.然后我选择Selected Methods,然后可以选择该函数可以支持的HTTP 方法.我希望我的函数支持 GET、PATCH、DELETE、POST 和 PUT.

                  From the Integrate menu, under the HTTP Header heading, there is a drop down box to with 2 selections: All Methods and Selected Methods. I then choose Selected Methods, and then have the option to select which HTTP methods the function can support. I would like my function to support GET, PATCH, DELETE, POST and PUT.

                  从 C# run.csx 代码中,我如何知道使用什么方法来调用该方法?我希望能够根据用于调用函数的 HTTP 方法在函数代码中采取不同的操作.

                  From within the C# run.csx code, how can I tell what method was used to invoke the method? I would like to be able to take different actions within the function code based on the HTTP method that was used to invoke the function.

                  这可能吗?

                  感谢您的帮助.

                  推荐答案

                  回答我自己的问题...您可以检查 HttpRequestMessage 的 Method 属性,它的类型是 HttpMethod.

                  Answering my own question... you can examine the HttpRequestMessage's Method property, which is of type HttpMethod.

                  这是 MSDN 文档:

                  Here's the MSDN documentation:

                  • HttpRequestMessage MSDN 文档

                  HttpMethod MSDN 文档

                  HttpRequestMessage.Method属性

                  获取或设置 HTTP 请求消息使用的 HTTP 方法.

                  Gets or sets the HTTP method used by the HTTP request message.

                  • 命名空间:System.Net.Http
                  • 程序集:System.Net.Http(在 System.Net.Http.dll 中)
                  • Namespace: System.Net.Http
                  • Assembly: System.Net.Http (in System.Net.Http.dll)

                  还有一个快速示例:

                  #r "Newtonsoft.Json"
                  
                  using System;
                  using System.Net;
                  using Newtonsoft.Json;
                  
                  public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
                  {
                      log.Info($"Webhook was triggered!");
                  
                      if (req.Method == HttpMethod.Post)
                      {
                          log.Info($"POST method was used to invoke the function ({req.Method})");
                      }
                      else if (req.Method == HttpMethod.Get)
                      {
                          log.Info($"GET method was used to invoke the function ({req.Method})");
                      }
                      else
                      {
                          log.Info($"method was ({req.Method})");    
                      }
                  }
                  

                  这篇关于如何识别用于调用 Azure 函数的 HTTP 方法(动词)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)

                • <small id='qSAUt'></small><noframes id='qSAUt'>

                      <bdo id='qSAUt'></bdo><ul id='qSAUt'></ul>

                        <tbody id='qSAUt'></tbody>

                        <tfoot id='qSAUt'></tfoot>
                      1. <i id='qSAUt'><tr id='qSAUt'><dt id='qSAUt'><q id='qSAUt'><span id='qSAUt'><b id='qSAUt'><form id='qSAUt'><ins id='qSAUt'></ins><ul id='qSAUt'></ul><sub id='qSAUt'></sub></form><legend id='qSAUt'></legend><bdo id='qSAUt'><pre id='qSAUt'><center id='qSAUt'></center></pre></bdo></b><th id='qSAUt'></th></span></q></dt></tr></i><div id='qSAUt'><tfoot id='qSAUt'></tfoot><dl id='qSAUt'><fieldset id='qSAUt'></fieldset></dl></div>

                          • <legend id='qSAUt'><style id='qSAUt'><dir id='qSAUt'><q id='qSAUt'></q></dir></style></legend>