Project Templates
kanject new scaffolds a deploy-ready .NET service from a template: a .slnx solution, the projects, a wired test project, and the kanject-cli/ manifest and stage files. All six templates are free and ship inside the CLI, so scaffolding needs no feed access.
- Scaffold a service with
kanject new <template> --name - Pick a template by the shape of service you are building
- Know which two templates build on paid Kanject libraries
- Add a second function to an existing service with
kanject add function
Scaffold a service
kanject new installs the template pack bundled with the CLI if dotnet new doesn't already have that version, runs dotnet new, then runs kanject init on each Lambda project it finds. On a terminal it asks for anything you leave out: the template first, then the name. In CI, pass both.
# Scaffold a service from a templatekanject new minimal-api --name Acme.Orders# Or choose a template, then enter the name, interactivelykanject new# Tune the scaffold with template optionskanject new webapi --name Acme.Api \ --framework net10.0 --auth-provider none --include-tests false The templates
[ApiEndpoints] classes, OpenAPI at the root, /health, and Api, Business, Common and Data projects with integration tests.--include-connect true adds a Cognito Connect Lambda.Kanject.FileServer library.Options
A template that doesn't take an option prints a warning and keeps its own default.
--framework—net8.0(default),net9.0, ornet10.0.minimal-apitakesnet10.0(default) ornet8.0.--auth-provider—jwt(default) ornone.webapiandinstant-messagingonly.--include-tests—true(default) orfalse. Every template exceptsource-generator.--name/--output— the service name, and the directory it lands in (./<name>by default).--skip-init— scaffold only; runkanject inityourself later.--non-interactive— never prompt. Needs the template, the name, and either--skip-initor--yes.
Keeping templates current
The template pack carries the CLI's own version. After a CLI update, the next kanject new installs the matching pack from the CLI install, with no prompt and no network call. kanject update --templates-only installs it from nuget.org instead.
Add another function
Inside an existing service, kanject add function scaffolds another Lambda from the same templates, adds it to the service-root solution (.slnx or .sln), and registers it as a new entry in the manifest. One stack then deploys both. source-generator isn't a function and is refused. Bare kanject add function shows a picker; automation passes the template and --name.
# Add a worker beside the API in an existing servicekanject add function tasks --name Acme.Orders.Worker kanject new <template> --namescaffolds a deploy-ready service: a.slnxsolution, projects, tests, and the manifest and stage files.- All six templates are free and bundled with the CLI.
instant-messagingandfile-serverneed a subscription to build, because their libraries are paid. --framework,--auth-providerand--include-teststune the scaffold;--paidand--freeonly warn now.kanject add functionadds another Lambda to an existing service, deployed in the same stack.