public static void GetState_BindToKeyName( string key, [DaprState("store1", Key = "{key}")] DaprStateRecord state, ILogger log) { log.LogInformation(state.Value?.ToString() ?? string.Empty); }
public static async Task <IActionResult> Run( [DaprTopicTrigger("%PubSubName%", Topic = "%TopicName%")] CloudEvent cloudEvent, [DaprState("%StateStore%")] IAsyncCollector <DaprStateRecord> state, ILogger log) { // Get data from CloudEvent log.LogInformation($"Received message: {cloudEvent.Data}."); var cancellationData = cloudEvent.Data as JToken; // TODO: Implement cancellation validaiton logic. // Parse state ID and Save var keyname = Environment.GetEnvironmentVariable("StateKey") ?? "id"; var key = cancellationData.Value <string>(keyname); var stateRec = new DaprStateRecord(key, cancellationData); await state.AddAsync(stateRec); return(new OkResult()); }