Visual Studio, Code & Rider C# code snippets for Durable Functions (v2.x).
Type funccl
inside a new class followed by one or two [TAB]
s depending on your IDE and it results in:
[FunctionName(nameof(OrchestrationClientClassName))]
public async Task Run(
[TriggerAttribute] ParameterType parameterName,
[DurableClient] IDurableClient client,
ILogger logger)
{
// TODO
// object input = ;
// string instanceId = await client.StartNewAsync(
// nameof(OrchestrationClassName),
// input);
}
Type funcor
inside a new class followed by one or two [TAB]
s depending on your IDE and it results in:
[FunctionName(nameof(OrchestratorClassName))]
public async Task Run(
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger logger)
{
// Since the orchestrator code is being replayed many times
// don't depend on non-deterministic behavior or blocking calls such as:
// - DateTime.Now (use context.CurrentUtcDateTime instead)
// - Guid.NewGuid (use context.NewGuid instead)
// - System.IO
// - Thread.Sleep/Task.Delay (use context.CreateTimer instead)
//
// More info: https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-code-constraints
// TODO
// var input = context.GetInput<T>();
// var activityResult = await context.CallActivityAsync<string>(
// nameof(ActivityClassName),
// input));
}
Type funcac
inside a new class followed by one or two [TAB]
s depending on your IDE and it results in:
[FunctionName(nameof(ActivityClassName))]
public async Task<OutputType> Run(
[ActivityTrigger] InputType input,
ILogger logger)
{
// TODO
}
Download the snippet file locally and import it in Visual Studio by following these instructions.
Until I've managed to create a proper extension you can copy & paste the content from this file into your own User Snippets as is documented here.
Download the DotSettings file locally and import it in Rider by following these instructions.
It works best if you are working in a Function App project with a reference to the DurableTask nuget package. So these references should be available:
- Microsft.Azure.WebJobs.Extensions.DurableTask
- Microsft.Azure.WebJobs.Extensions.Storage (only if you plan to use the default QueueTrigger in the orchestration client snippet).
- Microsoft.NET.Sdk.Functions