Add lambda.DurableFunction blueprint (vs2026)#2445
Conversation
Adds a new 'dotnet new' template (shortName: lambda.DurableFunction) under Blueprints/BlueprintDefinitions/vs2026 that scaffolds a Lambda durable execution workflow using the Annotations class-library programming model on the managed dotnet10 runtime. The sample workflow demonstrates the core durable primitives: StepAsync, a step with an exponential RetryStrategy and AtMostOncePerRetry semantics, WaitAsync (suspend timer), and RunInChildContextAsync. The generated serverless.template includes DurableConfig and the AWSLambdaBasicDurableExecutionRolePolicy managed policy. A test project drives the workflow locally via Amazon.Lambda.DurableExecution.Testing. Also registers the template in Blueprints/README.md.
| <PackageReference Include="Amazon.Lambda.Core" Version="3.1.1" /> | ||
| <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="3.0.0" /> | ||
| <PackageReference Include="Amazon.Lambda.Annotations" Version="2.0.1" /> | ||
| <PackageReference Include="Amazon.Lambda.DurableExecution" Version="0.1.1-preview" /> |
There was a problem hiding this comment.
will update to ga version once released
| <ItemGroup> | ||
| <PackageReference Include="Amazon.Lambda.Core" Version="3.1.1" /> | ||
| <PackageReference Include="Amazon.Lambda.TestUtilities" Version="4.1.0" /> | ||
| <PackageReference Include="Amazon.Lambda.DurableExecution.Testing" Version="0.0.1-preview" /> |
There was a problem hiding this comment.
since this pr isnt merged yet, i tested with local nuget feed.
# 1. Pack the three required packages into a local feed
FEED=/tmp/durable-feed && mkdir -p "$FEED"
cd Libraries/src/Amazon.Lambda.Annotations && dotnet pack -c Release -o "$FEED"
cd ../Amazon.Lambda.DurableExecution && dotnet pack -c Release -o "$FEED"
cd ../Amazon.Lambda.DurableExecution.Testing && dotnet pack -c Release -o "$FEED"
# 2. Install the template from the blueprint folder
cd <repo>/Blueprints/BlueprintDefinitions/vs2026/DurableFunction/template/src/BlueprintBaseName.1
dotnet new install . # or install from the .template.config location
# 3. Instantiate into a scratch dir
mkdir /tmp/dtest && cd /tmp/dtest
dotnet new lambda.DurableFunction --name MyOrders
# 4. Build + test against the local feed
dotnet test --source "$FEED" --source https://api.nuget.org/v3/index.json
| @@ -0,0 +1,39 @@ | |||
| { | |||
There was a problem hiding this comment.
intentionally only added to vs2026. didnt feel like it was worth adding to 2024 folder since dotnet8 will be end of life soon
|
The test project isn't actually bundled when doing a new project (same with other projects) but adding here to be consistent |
normj
left a comment
There was a problem hiding this comment.
The pattern of the template library is templates that start with the lambda. prefix deploy directory to Lambda. For example using the dotnet lambda deploy-function command. For templates that deploy via CloudFormation start with serverless. and you would deploy via the dotnet lambda deploy-serverless command.
I suggest we have 2 templates. One that goes directly to Lambda and uses the static wrapper method instead of annotations so it can be deploy straight to Lambda. Then a second serverless.* template that is what you have here.
The test project is still useful when you create the template via Visual Studio. |
philasmar
left a comment
There was a problem hiding this comment.
approving assuming you address norm's feedback
The single DurableFunction blueprint was labeled `lambda.DurableFunction` but shipped a serverless.template and deployed via `deploy-serverless` (the Annotations model) — a naming/convention mismatch. Follow the SimpleS3Function / SimpleS3FunctionServerless pattern and provide both: - DurableFunction (lambda.DurableFunction): deploys straight to Lambda with `dotnet lambda deploy-function`. Uses the static-wrapper, class-library programming model (DurableFunction.WrapAsync + [assembly: LambdaSerializer], no [DurableExecution], no serverless.template). aws-lambda-tools-defaults.json carries function-handler/function-runtime and the new durable-execution-timeout key. (Requires the deploy-function durable support from aws-extensions-for-dotnet-cli PR #447.) - DurableFunctionServerless (serverless.DurableFunction): the existing Annotations + serverless.template blueprint, relabeled to the serverless.* identity and deployed via `dotnet lambda deploy-serverless`. Both build and their test projects pass. The lambda.DurableFunction variant was verified end-to-end on the managed dotnet10 runtime (DurableConfig set, durable IAM policy auto-attached, workflow runs to SUCCEEDED).
|
@normj updated to have two templates and i retested both |
|
aws/aws-extensions-for-dotnet-cli#447 needs to be merged and released first |
Summary
Provides two
dotnet newtemplates underBlueprints/BlueprintDefinitions/vs2026for Lambda durable execution workflows, following the existinglambda.*/serverless.*convention (e.g.SimpleS3Function/SimpleS3FunctionServerless):lambda.DurableFunctionDurableFunction.WrapAsync), class-librarydotnet lambda deploy-functionserverless.DurableFunction[LambdaFunction]+[DurableExecution])dotnet lambda deploy-serverlessserverless.templateBoth target the managed dotnet10 runtime (durable execution requires dotnet10) and scaffold the same sample
ProcessOrderworkflow demonstrating the core durable primitives:StepAsync— checkpointed stepStepAsync+RetryStrategy.ExponentialwithStepSemantics.AtMostOncePerRetryWaitAsync— suspend timer (no compute charge while suspended)RunInChildContextAsync— grouping related stepsEach ships a test project that drives the workflow locally via
Amazon.Lambda.DurableExecution.Testing(no AWS resources needed). vs2026 only (matches the existing layout convention).Why two templates
The original single blueprint was labeled
lambda.DurableFunctionbut shipped aserverless.templateand deployed viadeploy-serverless— a naming/convention mismatch. This splits it so thelambda.*name actually deploys straight to Lambda, and the CloudFormation path keeps its ownserverless.*name.Using the templates
lambda.DurableFunction— deploy straight to Lambdadotnet new lambda.DurableFunction --name MyDurableApp cd MyDurableApp/src/MyDurableApp dotnet lambda deploy-functionHandlerdelegates toDurableFunction.WrapAsync<OrderRequest, OrderResult>(ProcessOrder, …); the serializer is declared with[assembly: LambdaSerializer(typeof(DefaultLambdaJsonSerializer))]. NoMain, no[DurableExecution], noserverless.template.aws-lambda-tools-defaults.jsoncarriesfunction-runtime: dotnet10, theAssembly::Type::Methodfunction-handler, anddurable-execution-timeout.deploy-functioncreates the execution role for you, it auto-attachesAWSLambdaBasicDurableExecutionRolePolicy(the checkpoint permissions). If you pass--function-role, attach that policy yourself.deploy-functiondurable support fromaws-extensions-for-dotnet-cliPR #447 (thedurable-execution-timeoutswitch + IAM auto-attach). Until that ships in a releasedAmazon.Lambda.Tools,deploy-functionwon't apply the durable config.serverless.DurableFunction— deploy via CloudFormationdotnet new serverless.DurableFunction --name MyDurableApp cd MyDurableApp/src/MyDurableApp dotnet lambda deploy-serverless[LambdaFunction]+[DurableExecution]. The source generator emits the handler wrapper and keepsserverless.templatein sync —DurableConfigplus theAWSLambdaBasicDurableExecutionRolePolicymanaged policy.Amazon.Lambda.Annotationsthat supports[DurableExecution].Run the local tests (either template)
dotnet testTesting
lambda.DurableFunctioninstantiated (placeholder substitution) and built against the published durable preview packages.lambda.DurableFunctionwith the PR Runningdotnet lambda list-functionsresults inError listing Lambda functions: Request headers must contain only ASCII characters.#447 CLI build →DurableConfig.ExecutionTimeoutset,AWSLambdaBasicDurableExecutionRolePolicyauto-attached to the tool-created role, and the workflow ran to SUCCEEDED (all six operations checkpointed, including theWaitAsyncsuspend/resume). Resources torn down afterward.Notes
lambda.DurableFunctionis gated onaws-extensions-for-dotnet-cliPR #447 landing in a releasedAmazon.Lambda.Tools.Amazon.Lambda.DurableExecution/.Testingare preview packages; the templates reference0.1.1-preview/0.0.1-preview. Restores once those are published (or via a local feed)..autoverchange file needed (autover tracksLibraries/srcprojects only).