如何在C#Windows应用程序中调用Azure函数(2.x) [英] How to call azure function (2.x) in c# windows applications

查看:72
本文介绍了如何在C#Windows应用程序中调用Azure函数(2.x)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用Azure函数(2.x)时出错说底层连接已关闭:发送中发生意外错误."但它正在工作 可以使用天蓝色函数(1.x)

Error while calling azure function(2.x) says "The underlying connection was closed: An unexpected error occurred on a send." but it is working fine with azure function(1.x)

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
clsParams objparams = new clsParams();       
string Baseurl = "azure function url";
WebRequest request = WebRequest.Create(Baseurl);
objparams.name = "Some string";
string json = JsonConvert.SerializeObject(objparams);
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(json);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream(); //Error occured here
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();      Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();

推荐答案

这听起来像是TLS问题.您能否在SSL设置下签入门户网站,以查看允许V2功能上的入站请求使用的TLS版本.默认情况下,在四月之后创建的任何新应用都默认使用TLS 1.2,但是可以按照说明进行降级 以上.

This sounds like a TLS issue. Can you check in the portal under SSL settings to see what version of TLS you allow for inbound requests on the V2 function. Any new app created after April by default uses TLS 1.2, but this can be downgraded using the instructions above.


这篇关于如何在C#Windows应用程序中调用Azure函数(2.x)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆