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

411
Visualizações
Azure function HTTP Trigger not cancelling request

When I cancel my request from browser to a HTTP Trigger it does not cancel and continues execution when hosted on Azure.

My function example:

[FunctionName("Test")]
public async Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
    CancellationToken cancellationToken,
    ILogger log)
{
    var allCancellationTokens = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, req.HttpContext.RequestAborted);

    await Task.Delay(30000, allCancellationTokens.Token);

    if (allCancellationTokens.IsCancellationRequested) {
        log.LogInformation("Request was cancelled!");
        return new StatusCodeResult(499);
    }

    return new OkObjectResult("Complete");
}

I have been testing the cancellation through Postman and axios cancel tokens. It works when I run the project locally and cancel it, but does not seem to cancel once it's published to azure.

My expected result would be that it throws an OperationCanceledException if I cancel the request during the await Task.Delay(30000, allCancellationTokens.Token); However when checking logs on Azure Functions, just seems to carry on execution and complete the function.

Steps to reproduce:

  1. Create a HTTP Trigger like the one defined above.
  2. Publish the app to Azure.
  3. Open the functions logs on Azure in the monitor section.
  4. Using Postman, send a request to this function and cancel the request (within the timeout period of 30 seconds).
  5. Won't cancel the request and will still execute.
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

CancellationToken is helpful for implementing graceful shutdown of your Functions runtime host when it is notified by the Operating System that something has gone wrong to terminate it, please see the following answer for more: https://stackoverflow.com/a/63439515/528779

over 4 years ago · Santiago Trujillo Relatório
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