Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

352
Visualizações
Using SignalR in a .Net 5.0 Isolated Process Function

I'm upgrading a .Net core 3.1 azure function which uses a ServiceBusTrigger, to a .Net 5.0 isolated process function. The function uses SignalR to broadcast real-time messages throughout the steps of the process--for example: "Opening file"... "Reading records - 10% complete"... "Preparing to display records", and so forth. Multiple messages are broadcast via SignalR during a single run of the function.

The .Net core 3.1 function signature was similar to this:

    [FunctionName("MyFunction")]
        public async Task RunTopic(
            [ServiceBusTrigger("TopicName", "SubscriptionName", Connection = "ConnectionString")]
            string message, ILogger log, ExecutionContext executionContext,
            [SignalR(HubName = "Hub", ConnectionStringSetting = "SignalRConnectionString")]IAsyncCollector<SignalRMessage> signalRMessages
            )
        { ... }

And, below is an example of the logic used to broadcast the messages:

await signalRMessages.AddAsync(
            new SignalRMessage
            {
                Target = "newMessage",
                Arguments = new[] { $"Message content" }
            });

Upon converting the function to a .Net 5.0 isolated process function, I've noticed that the SignalR implementation is a bit different. I've found examples; however, they seem to address basic scenarios.

In a .Net 5.0 isolated process function, what steps are needed to allow multiple messages to be broadcast real-time via SignalR, during a single run of the function? The examples I've seen so far seem to allow a single message to be broadcast with each run of the function.

Here's an example of the method signature, after upgrading the function to a .Net 5.0 isolated function:

    [Function("MyFunction")]
    [SignalROutput(HubName = "Hub", ConnectionStringSetting = "SignalRConnectionString")]
    public async Task<CustomMessage> Run(
        [ServiceBusTrigger("TopicName", "Subscription", Connection = "ConnectionString")]
        string message, FunctionContext functionContext)
    { ... }

public class CustomMessage
{
    public string Target { get; set; }

    public object[] Arguments { get; set; }
}

Additional info:

I came across this posted item which describes what I am asking: https://github.com/Azure/azure-functions-dotnet-worker/issues/179

Namely, the IAsyncCollector, supported in .Net Core 3.1, seemed to allow several different/unique messages to be sent over the course of the function running, as opposed to only the last message being sent, once the function completed. Alternatives are being considered at the moment, as comments in the above link indicate this behavior may not be supported in .Net 5.0 isolated process functions.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda