![](/img/trans.png)
[英]Unable to send message into Service Bus Queue using Azure function
[英]send message to azure service bus queue from web api
我正在尝试开始使用Azure Service Bus队列。 紧随本文https://docs.microsoft.com/zh-cn/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues的唯一区别是,我尝试从在网络api中。
我得到的错误是:无法建立连接,因为目标计算机主动拒绝了它40.84.xxx.xx:443
我将不胜感激任何帮助或指示!
注意:遵循上述指南,控制台应用程序可以正常运行。
更新7/24,这是我的操作方法中的代码:
try
{
var connectionString =
"Endpoint=sb://xxxxx-test.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=shared_access_key";
var queueName = "testqueue1";
var client =
QueueClient.CreateFromConnectionString(connectionString, queueName);
var message = new BrokeredMessage(eventMessage);
client.Send(message);
}
catch (Exception e)
{
//log exception
}
更新7/25。 我可以通过将defaultConfig条目设置为在web.config中启用来使其工作:
<system.net>
<defaultProxy enabled="true"/>
</system.net>
无法建立连接,因为目标计算机主动拒绝了它40.84.xxx.xx:443
请检查出站443端口是否被防火墙阻止。
注意:遵循上述指南,控制台应用程序可以正常运行。
Service Bus连接模式的默认值为AutoDetect。 它将基于自动检测机制自动在Tcp和Http模式之间进行选择,该机制将探测当前网络环境中是否有可用的连接选项。 它可能会为您的控制台应用程序和Web API应用程序选择不同的模式。 在使用服务总线队列之前,请尝试在Web API应用程序中将其显式设置为TCP。
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Tcp;
我可以通过将defaultConfig条目设置为在web.config中启用来使其工作:
<system.net>
<defaultProxy enabled="true"/>
</system.net>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.