Reputation: 43067
I have a continuous web job that is triggered by a queue. The Functions
method accepts a TextWriter
parameter, and I use that to write the output of my job.
public static void ProcessQueueMessage([QueueTrigger("build")] ProjectTrigger projectInfo, TextWriter log)
I can browse the azure-jobs-host-archive
storage container in the Azure portal and view the latest file to see the host log, containing JSON that includes the following path to the actual log in the azure-webjobs-hosts
container.
// ...
"Arguments": {
"projectInfo": "{\"ProjectId\":1}",
"log": null
},
"Reason": "AutomaticTrigger",
"StartTime": "2015-03-31T00:22:33.0447775+00:00",
"OutputBlob": {
"ContainerName": "azure-webjobs-hosts",
"BlobName": "output-logs/06001f0c69064d4289b3501d0064f11c.txt"
},
// ...
With that, I can browse to the azure-webjobs-hosts
container in the Azure portal and find the file specified by BlobName
.
That's great, but how can I do this programmatically? I want to be able to display the output log in my web application. If I knew the path of host archive file while the job is running, I could store it in SQL and access it later. Is this possible?
Upvotes: 1
Views: 1085
Reputation: 43067
I didn't find the exact answer I was looking for, but you can save the job log to a specific blob path using BlobAttribute
, where ProjectId
and Id
are properties of ProjectTrigger
.
public static void ProcessQueueMessage([QueueTrigger("build")] ProjectTrigger projectInfo,
[Blob("projecthistory/{ProjectId}/{Id}.txt", FileAccess.Write)] TextWriter log)
Upvotes: 1