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

154
Visualizações
How to set multiple schedule in azure timer function?

I have a working sample azure timer function, but about setting it in multiple schedule, I'm not sure if doing it correctly, because I can't test it immediately because it is scheduled hours gap.

My goal is, to display context.log every 8:00AM, and 8:00PM every day.

note: my code below actually don't work because parameter hour does not accept array (for demonstration purpose only)


Here is my code:

export const TimerTrigger1 = TypedAzFunc.createFunctionBuilder(__dirname)
  .with(
    TimerTriggerPlugin.init({
      schedule: {
        crontab: {
          second: 0,
          minute: { interval: 1 },
          hour: [{ interval: 8 }, { interval: 20 }],
          day: '*',
          month: '*',
          dayOfWeek: '*',
        },
      },
    })
  )
  .build(async (context, timer) => {
    var timeStamp = new Date().toISOString()

    if (timer.isPastDue) {
      context.log('timer has already triggered')
    }
    context.log('timer has triggered', timeStamp)
  })

export const run = TimerTrigger1.run
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

you can achieve this, by passing an array in the hour property.

TimerTriggerPlugin.init({
  schedule: {
    crontab: {
      second: 0,
      minute: 0,
      hour: [8, 20],
      day: '*',
      month: '*',
      dayOfWeek: '*',
    },
  },
})

this will result a schedule for example:

if today is february 18, 2022 7:00am

02/18/2022 08:00:00Z
02/18/2022 20:00:00Z
02/18/2022 08:00:00Z
02/18/2022 20:00:00Z
02/18/2022 08:00:00Z
about 4 years ago · Juan Pablo Isaza Relatório

0

You could solve this by having 2 timers, one for 8 am and one for 8 pm.

about 4 years ago · Juan Pablo Isaza 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