Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[FunctionName("Counter")]
public static async Task Counter(
[EntityTrigger] IDurableEntityContext ctx)
{
int currentValue = ctx.GetState<int>();
int operand = ctx.GetInput<int>();
switch (ctx.OperationName)
{
case "add":
currentValue += operand;
break;
case "subtract":
currentValue -= operand;
break;
case "reset":
await SendResetNotificationAsync();
currentValue = 0;
break;
}
ctx.SetState(currentValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.