You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using (_logger.BeginNewTaskScope("ImportJob", "Queue", "Worker-1"))
41
+
varmetadata=newJsonObject
42
+
{
43
+
["tenant"] ="north",
44
+
["file"] ="customers.csv",
45
+
["pageSize"] =100000,
46
+
["cleanUpData"] =true
47
+
};
48
+
49
+
using (_logger.BeginNewTaskScope("ImportJob", "Queue", "Worker-1", metadata))
42
50
{
43
51
_logger.LogInformation("Processing started");
44
52
}
45
53
```
46
54
55
+
Metadata is exposed as `JsonObject` from `System.Text.Json.Nodes` and is stored as JSON in the Azure Table `TaskData` property. JSON value types, arrays, and nested objects are preserved. Use the overload without metadata when a task has none:
56
+
57
+
```csharp
58
+
vartaskId=awaittaskLoggerFactory.AnnounceTask(
59
+
"ImportJob",
60
+
"Queue",
61
+
"Worker-1");
62
+
```
63
+
64
+
### Updating Metadata
65
+
66
+
Metadata updates are buffered and persisted together with the next task status update. New values are merged into the stored JSON object; an existing key is overwritten:
Task scopes provide the same deferred behavior. Disposal persists the metadata together with the completion status:
79
+
80
+
```csharp
81
+
usingvarscope=_logger.BeginTaskScope(taskId);
82
+
scope?.MergeTaskMetadata(newJsonObject
83
+
{
84
+
["records"] =1200
85
+
});
86
+
```
87
+
88
+
Azure Table updates use optimistic ETag concurrency and partial entity updates. Concurrent metadata changes are re-read and merged without replacing unrelated task fields.
89
+
90
+
### Migrating from 0.x Metadata APIs
91
+
92
+
String and dictionary overloads were removed in 0.5.0. Parse existing JSON strings into a `JsonObject`:
`AnnounceTask` is available with or without metadata and with or without a `CancellationToken`. Structured metadata must be supplied as a `JsonObject`.
104
+
47
105
## Maintenance Cleanup
48
106
49
107
`CoreHelpers.TaskLogging.Maintenance` can delete old, month-based task logging tables that were created by `CoreHelpers.TaskLogging`.
@@ -118,4 +176,4 @@ git tag v0.0.0
118
176
git push origin v0.0.0
119
177
```
120
178
121
-
The release workflow builds, tests, packs all NuGet packages, creates the GitHub Release, uploads the `.nupkg` files as release assets, and then publishes the same package artifacts to NuGet.
179
+
The release workflow builds, tests, packs all NuGet packages, creates the GitHub Release, uploads the `.nupkg` files as release assets, and then publishes the same package artifacts to NuGet.
0 commit comments