A dotnet new
template for creating a fully-featured, 12 Factor, ASP.NET Core Web API for AKS.
dotnet new -i RobBell.AksApi.Template
The template resolves from the official NuGet repository.
To create a new project named MyApi:
dotnet new aksapi -n MyApi
Other options include:
--controller-name The name of the default controller
Default: SampleController
--disable-open-api Disable OpenAPI (Swagger) support
Default: false
--disable-health-check Disable liveness and readiness support
Default: false
--disable-logging Disable Logging and AppInsights support
Default: false
--instrumentation-key The AppInsights application key if logging is enabled
Default: 11111111-1111-1111-11111111111111111
--skip-restore Skips the restore of the project on create
Default: false
- Sample endpoint
- Docker containerisation
- OpenAPI support (Swagger)
- Automatic post creation actions -
dotnet restore
- Health check endpoint, including liveness and readiness probes
- No unused package references or usings
- Helm charts
- Deployment and service creation
- Image references
- Labels
- AppInsights configuration - thanks to Dirk Rheeder
- Reintroduce launchsettings.json as per https://github.com/dotnet/aspnetcore/tree/master/src/ProjectTemplates
- README in created project, including file overview
- YAML release pipeline (Azure DevOps or GitHub Actions?)
- Clean-up rules
- Linting
- Build badges, NuGet package version
- Tests project (includes running in Dockerfile) - are these valuable? Forces this to become a multi-project, and possibly solution-creating template
- Other 12 Factor app traits - look at what would be useful to include
- Other creation parameters (Port? EnablingAuthentication? FrameworkVersion?)
- Are there any references that can be pulled at creation time? Helm charts for example
- LICENSE and CONTRIBUTING files - should
dotnet new
creation map 1:1 with a repository?
- Local build and install
- Tests
- Installation and usage notes
- Template packaging on all platforms (.csproj package)
- Template package versioning
- Removal of package warnings
After making changes to the template, run the script below to pack and install locally:
./pack-and-install.sh
Once complete, you can create new projects from the template using:
dotnet new aksapi
Try:
dotnet new -i RobBell.AksApi.Template --nuget-source https://api.nuget.org/v3/index.json
Sometimes you might have private NuGet repositories in your package sources which interfere with installation of the template from the official repo. For example:
C:\Program Files\dotnet\sdk\3.1.403\NuGet.targets(128,5):
error : Unable to load the service index for source https://myprivatenugetrepo.com/nuget/v3/index.json.
C:\Program Files\dotnet\sdk\3.1.403\NuGet.targets(128,5):
error : Response status code does not indicate success: 401 (Unauthorized).