azure-webjobs-sdk
azure-webjobs-sdk copied to clipboard
Associate state with job runs
Add a way to associate state with a job run and have ability to look it up (probably keyed on Function name or some other unique key generation we can customize).
Use Case
Tracking whether or not the last job run was successful. Currently I manually do this via database integration and storing job runs. Basically I just store a single record that has a timestamp of when my last successful run was, since I do time-relative processing.
This feels like something that belongs in your application code, not in the SDK. However, I'm wondering if we already have some support that might help you. The extensions library includes an ExecutionContext
binding that allows your function to access the unique FunctionInstanceID that we assign to the invocation. You could use that as a correlation key for your external storage. This is the same ID shown in the Dashboard. Thoughts?
Another thought is that we already store this information in your storage account (it drives the Dashboard display) though that information (in blob storage) might not be readily queryable - would have to experiment.
In my specific case, I really only need to track success/failure result and last run time--i.e. a single row of data. I agree anything more complex probably requires custom code. But I think since Webjobs already record that kind of information (Success/Failure), it would be nice to access it (even if it's just the last result). If there was a way to assign a state object on a run some generic data, we could look that up later (via REST API).
Since all this info is queryable via REST already... maybe just need an extension that could auto-bind that data to an object on invocation?
latest_run:
{
id: "20131103120400",
status: "Success",
start_time: "2013-11-08T02:56:00.000000Z",
end_time: "2013-11-08T02:57:00.000000Z",
duration: "00:01:00",
output_url: "http://.../vfs/data/jobs/triggered/jobName/20131103120400/output_20131103120400.log",
error_url: "http://.../vfs/data/jobs/triggered/jobName/20131103120400/error_20131103120400.log",
url: "http://.../triggeredwebjobs/jobName/history/20131103120400",
trigger: "Schedule - 0 0 0 * * *",
customState: {
myCustomProp1: true
}
}
I was looking for this feature too when using the TimerTrigger from the Extensions library. This currently gives me the Last and Next run time, but these only refer to the schedule and not wether or not it was successful. Maybe this feature could be added to the Extensions?
I'm upvoting this :)
It will be really nice to have below information:
- latest run with status
- latest successful run
Any news on this?