I have a custom container with a time-triggered Azure Function. When I build the Docker image, and run it locally, I don't get any action, i.e. the trigger doesn't fire.
I'm wondering - is my function.json
missing something? Do I need an output within that, and/or in __init__.py
? I'm starting to think that the timer trigger alone isn't enough to elicit any kind of response.
The function.json
file:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 * * * * *",
"authLevel": "anonymous"
}
]
}
The __init__.py
imports some custom functions, which work, but need the custom container for selenium concerns. The function scrapes and then outputs to Twitter. But is there a need for an output, like the answer in this question? If this Function needs to output to Twitter (the internet), is the timer trigger enough?
import logging
import azure.functions as func
#importing custom modules, here, they work
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
# Class instantiation for the scraping, etc. ----
#calling other functions
Some of the logs from the running container, though I don't think it's a string connection issue, as I have that defined in the local.settings.json
file, or I use the storage emulator in VS Code, and that works too.
The listener for function 'Functions.BadFunc' was unable to start.
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'Functions.BadFunc' was unable to start.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
at Microsoft.Azure.Storage.CloudStorageAccount.Parse(String connectionString)
at Microsoft.Azure.WebJobs.Extensions.Timers.StorageScheduleMonitor.get_TimerStatusDirectory() in C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions\Extensions\Timers\Scheduling\StorageScheduleMonitor.cs:line 77
at Microsoft.Azure.WebJobs.Extensions.Timers.StorageScheduleMonitor.GetStatusBlobReference(String timerName) in C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions\Extensions\Timers\Scheduling\StorageScheduleMonitor.cs:line 144
at Microsoft.Azure.WebJobs.Extensions.Timers.StorageScheduleMonitor.GetStatusAsync(String timerName)
at Microsoft.Azure.WebJobs.Extensions.Timers.Listeners.TimerListener.StartAsync(CancellationToken cancellationToken) in C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions\Extensions\Timers\Listener\TimerListener.cs:line 99
at Microsoft.Azure.WebJobs.Host.Listeners.SingletonListener.StartAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Singleton\SingletonListener.cs:line 72
at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.StartAsync(CancellationToken cancellationToken, Boolean allowRetry) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\FunctionListener.cs:line 69
--- End of inner exception stack trace ---
info: Host.Startup[413]
Host started (154ms)
info: Host.Startup[0]
Job host started
Hosting environment: Production
Content root path: /
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
info: Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher[0]
Worker process started and initialized.
info: Host.Startup[0]
Retrying to start listener for function 'Functions.BadFunc' (Attempt 1)
info: Host.Startup[0]
Listener successfully started for function 'Functions.BadFunc' after 1 retries.
info: Host.General[316]
Host lock lease acquired by instance ID '000000000000000000000000F28FAECC'.