For some reason, I cannot send the message to the Service Bus Queue in my web job. Is this a limitation of a webjob that I cannot send an async request? I've tried downgrading and upgrading all the packages and even changing the .net framework, but nothing works.
Характеристики: 1. net framework 4.6.1 2. Microsoft. Azure .Amqp 2.4.3 3. Microsoft. Azure .ServiceBus 4.1.1 4. Microsoft. Azure .WebJobs 2.2.0 5. Microsoft. Azure .WebJobs.Core 2.2.0 6. Newtonsoft. Json 12.0.3 7. WindowsAzure .Storage 9.3.3
Код:
public bool AddoQueue(string message)
{
_sendMessage.SendMessageToQueue(message);
return true;
}
static IQueueClient queueClient;
public async Task<bool> SendMessageToQueue(string message)
{
try
{
queueClient = new QueueClient(Configurator.GetConfigSettings("SBConnectionString"), Configurator.GetConfigSettings("QueueName"));
var messageObj = new Message(Encoding.UTF8.GetBytes(message))
{
TimeToLive = TimeSpan.FromDays(6),
PartitionKey = message
};
await queueClient.SendAsync(messageObj);
return true;
}
catch (Exception e)
{
Console.Write(e);
return false;
}
}