1. <small id='viaZi'></small><noframes id='viaZi'>

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

      <tfoot id='viaZi'></tfoot>

      <legend id='viaZi'><style id='viaZi'><dir id='viaZi'><q id='viaZi'></q></dir></style></legend>

      Azure Functions 在函数内部调用 http post

      Azure Functions call http post inside function(Azure Functions 在函数内部调用 http post)

      1. <legend id='GCcXO'><style id='GCcXO'><dir id='GCcXO'><q id='GCcXO'></q></dir></style></legend>

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

            <tbody id='GCcXO'></tbody>

            • <i id='GCcXO'><tr id='GCcXO'><dt id='GCcXO'><q id='GCcXO'><span id='GCcXO'><b id='GCcXO'><form id='GCcXO'><ins id='GCcXO'></ins><ul id='GCcXO'></ul><sub id='GCcXO'></sub></form><legend id='GCcXO'></legend><bdo id='GCcXO'><pre id='GCcXO'><center id='GCcXO'></center></pre></bdo></b><th id='GCcXO'></th></span></q></dt></tr></i><div id='GCcXO'><tfoot id='GCcXO'></tfoot><dl id='GCcXO'><fieldset id='GCcXO'></fieldset></dl></div>
              • <bdo id='GCcXO'></bdo><ul id='GCcXO'></ul>
              • <tfoot id='GCcXO'></tfoot>
                本文介绍了Azure Functions 在函数内部调用 http post的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以在 Azure Function 中创建 HTTP(s) 发布请求?我正在尝试创建一个自定义 webhook,它正在侦听一项服务,并在触发时使用 post 通过 HTTP 调用另一项服务.

                Is it possible to create HTTP(s) post request inside Azure Function? I am trying to create a custom webhook that is listening to one service and when triggered then its calling another service over HTTP using post.

                我的代码是这样的:

                public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
                {
                
                    BitbucketRequest data = await req.Content.ReadAsAsync<BitbucketRequest>();
                    //DO STH WITH DATA TO GET e.g. USER STORY ID
                
                    using(var client = new HttpClient()){
                        client.BaseAddress = new Uri("https://SOME_TARGETPROCESS_URL/api/v1");
                        var body = new { EntityState = new  { Id = 174 } };
                        var result = await client.PostAsJsonAsync(
                                       "/UserStories/7034/?resultFormat=json&access_token=MYACCESSTOKEN",
                                       body);
                        string resultContent = await result.Content.ReadAsStringAsync();
                    }
                
                    return req.CreateResponse<string>(HttpStatusCode.OK,"OKOK");
                }
                

                我想问题是当前 HttpRequestMessage 正在占用 web socket,我无法创建新的 Http Request.

                I suppose the problem is that currently HttpRequestMessage is occupying web socket and I can not create new Http Request.

                我在异常详情中发现的错误:

                Errors that I found in Exceptions details:

                • 底层连接已关闭:发送时发生意外错误.
                • 无法从传输连接读取数据:现有连接被远程主机强行关闭.
                • 套接字异常错误代码:10054

                推荐答案

                适用于在 Azure 函数中搜索 HttpClient 时登陆此处的其他任何人.

                For anyone else who lands here when searching for HttpClient in Azure functions.

                https://docs.microsoft.com/en-我们/azure/azure-functions/manage-connections

                // Create a single, static HttpClient
                private static HttpClient httpClient = new HttpClient();
                
                public static async Task Run(string input)
                {
                    var response = await httpClient.GetAsync("https://example.com");
                    // Rest of function
                }
                

                这篇关于Azure Functions 在函数内部调用 http post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                WPF ListBox not updating with the ItemsSource(WPF ListBox 未使用 ItemsSource 更新)
                Problem getting list box items added through jquery in code behind(在后面的代码中通过 jquery 添加列表框项目时出现问题)
                Selected item in list box is null(列表框中的选定项为空)
                ASP.NET: Listbox datasource and databind(ASP.NET:列表框数据源和数据绑定)
                .NET 3.5 Listbox Selected Values (Winforms)(.NET 3.5 列表框选定值(Winforms))
                Why does the WPF listbox change selection on mouse button down rather than button up?(为什么 WPF 列表框在鼠标按下而不是按下按钮时更改选择?)

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

                    • <bdo id='usvSU'></bdo><ul id='usvSU'></ul>
                      <legend id='usvSU'><style id='usvSU'><dir id='usvSU'><q id='usvSU'></q></dir></style></legend>
                        <tbody id='usvSU'></tbody>

                          <tfoot id='usvSU'></tfoot>

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