Azure Function Timer Trigger works for seconds but not minutes
I tried to create an azure function for timer. (Using Teams Toolkit extension in VS Code to create a default template app Bot -> Chat Notification Message -> Timer Trigger).
And I found it works fine with "schedule": "*/30 * * * * *" but failed to trigger if I update the schedule to schedule": "* */2 * * * *".
Any suggestion is welcomed for the problem. Thanks.
Here is the bicep for resource deployment.
@maxLength(20)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName string
param functionAppSKU string
@maxLength(42)
param botDisplayName string
param serverfarmsName string = resourceBaseName
param functionAppName string = resourceBaseName
param identityName string = resourceBaseName
param location string = resourceGroup().location
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
location: location
name: identityName
}
// Compute resources for your Web App
resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
kind: 'functionapp'
location: location
name: serverfarmsName
sku: {
name: functionAppSKU
}
properties: {}
}
// Azure Function that host your app
resource functionApp 'Microsoft.Web/sites@2021-02-01' = {
kind: 'functionapp'
location: location
name: functionAppName
properties: {
serverFarmId: serverfarm.id
httpsOnly: true
siteConfig: {
alwaysOn: true
appSettings: [
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4' // Use Azure Functions runtime v4
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'node' // Set runtime to NodeJS
}
{
name: 'WEBSITE_RUN_FROM_PACKAGE'
value: '1' // Run Azure Functions from a package file
}
{
name: 'WEBSITE_NODE_DEFAULT_VERSION'
value: '~18' // Set NodeJS version to 18.x
}
{
name: 'BOT_ID'
value: identity.properties.clientId
}
{
name: 'BOT_TENANT_ID'
value: identity.properties.tenantId
}
{
name: 'BOT_TYPE'
value: 'UserAssignedMsi'
}
{
name: 'RUNNING_ON_AZURE'
value: '1'
}
{
name: 'SCM_ZIPDEPLOY_DONOT_PRESERVE_FILETIME'
value: '1' // Zipdeploy files will always be updated. Detail: https://aka.ms/teamsfx-zipdeploy-donot-preserve-filetime
}
]
ftpsState: 'FtpsOnly'
}
}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${identity.id}': {}
}
}
}
// Register your web service as a bot with the Bot Framework
module azureBotRegistration './botRegistration/azurebot.bicep' = {
name: 'Azure-Bot-registration'
params: {
resourceBaseName: resourceBaseName
identityClientId: identity.properties.clientId
identityResourceId: identity.id
identityTenantId: identity.properties.tenantId
botAppDomain: functionApp.properties.defaultHostName
botDisplayName: botDisplayName
}
}
output BOT_DOMAIN string = functionApp.properties.defaultHostName
output BOT_AZURE_FUNCTION_APP_RESOURCE_ID string = functionApp.id
output BOT_FUNCTION_ENDPOINT string = 'https://${functionApp.properties.defaultHostName}'
output BOT_ID string = identity.properties.clientId
output BOT_TENANT_ID string = identity.properties.tenantId
I got same issue when i use TTK to create project. I set schedule: 0 0 1 * * *, fired on every morning 1 A.M. , Also not triggered. It did work in local debug session. But when I provision into Azure env, It didn't fire.
Hi @xzf0587 Thanks for reporting will check and update.
Hi @xzf0587 I checked and found its working.locally as well as portal also.can you check it again.
@bhagyshricompany Thanks for your reply. The timer works fine in our old version which uses storage account for Azure function. Recently, we updated the project by using SWA for Azure function and the timer does not work. Does the different storages impact the timer?
Hi @xzf0587 I checked and found its working.locally as well as portal also.can you check it again.
![]()
I think you don't enable the RUN_FROM_PACKAGE feature because you don't have this warning bar in the top of the test page.
And here is my test result and snapshot
@kshyju please comment and validate .
Hi @bhagyshricompany @kshyju, is there any update for this issue?
Hello @xzf0587 I found there is no issue trying it from local and as well as portal , please validate the same .
This seems to be unresolved issue. When deployed via Microsoft 365 Agents Toolkit as a bot solution, Timer Triggered functions with schedule set other then seconds are not triggered at all.
Using template:
-
Doesnt work
{ "bindings": [ { "name": "myTimer", "type": "timerTrigger", "direction": "in", "schedule": "* */5 * * * *" } ], "scriptFile": "../dist/src/timerTrigger.js" } -
Does work
{ "bindings": [ { "name": "myTimer", "type": "timerTrigger", "direction": "in", "schedule": "*/30 * * * * *" } ], "scriptFile": "../dist/src/timerTrigger.js" }