0
votes

I am sending messages to Service Bus Topic from Azure Functions, and when the function is called for the first 3-4 times, it takes around 10-20 seconds to send message to Service Bus Topic, and I am looking ways to reduce this time, I am sending message to service bus using below code.

public class ServiceBusTopicService

    {
    private static ITopicClient _topicClient;

    public ServiceBusTopicService(string serviceBusConnectionString, string topicName)
    {
        _topicClient = new TopicClient(serviceBusConnectionString, topicName);
    }
    private  static async Task SendMessage(string json)
    {
        var message = new Message(Encoding.UTF8.GetBytes(json));

        await _topicClient.SendAsync(message);
    }

    public async Task BroadCastEvent(string matasId, Guid correlationId, string profileSource, string eventType)
    {
        var eventToPost = JsonConvert.SerializeObject(ProfileEvent.GetProfileEvent(matasId, correlationId, profileSource, eventType));
        await SendMessage(eventToPost);
    }
}
1
Is the function app hosted on consumption plan?user1672994
Yes the function is hosted on Consumption tierShabir jan

1 Answers

0
votes

If it's only at start up then it's very likely cold start problem.

See this answer for solutions.