- .NET Version: .NET 9
- C# Version: 13.0
- Packages:
Azure.Storage.Blobs- Version 12.23.0FluentValidation.AspNetCore- Version 11.3.0Microsoft.ApplicationInsights.NLogTarget- Version 2.22.0Microsoft.AspNetCore.Authentication.JwtBearer- Version 9.0.0Microsoft.AspNetCore.OpenApi- Version 9.0.0Microsoft.EntityFrameworkCore- Version 9.0.0Microsoft.EntityFrameworkCore.Sqlite- Version 9.0.0Microsoft.EntityFrameworkCore.Tools- Version 9.0.0Newtonsoft.Json- Version 13.0.3NLog.Extensions.Logging- Version 5.3.15NLog.Web.AspNetCore- Version 5.3.15Swashbuckle.AspNetCore- Version 7.2.0WindowsAzure.Storage- Version 9.3.3
- Logging: Configured using NLog, settings in
appsettings.json. - Admin Account Seed:
- Username/Password/Email as specified in
appsettings.jsonunderUserSettings:Administrator. - Verification token for password change in
appsettings.jsonunderUserSettings:Administrator:ChangePasswordToken.
- Username/Password/Email as specified in
- User Roles Seed:
AdministratorandUserroles are seeded and immutable. - Authentication: JWT tokens (SymmetricSecurityKey).
- Name: Authorization (in Headers)
- Security Scheme: Bearer (in Headers -
Bearer <token>) - Token Expiry: Configurable in
appsettings.json - Signing Credentials: HmacSha256
- Password Storage: Passwords are hashed using
Microsoft.AspNetCore.Identity.IPasswordHasher. - Validation: Implemented using FluentValidation.
- API Documentation: Swagger with documentation generation.
- Exception Handling: Custom exception handler middleware.
- Authorization:
- Use custom attributes for functions
[Authorize], custom attribute -[DynamicRoleAuthorize]. - All roles assigned to functions can be found in
appsettings.jsonunder theRolesConfigsection.
- Use custom attributes for functions
- Configure Settings: First, rename
appsettings_schema.jsontoappsettings.json, then configure and familiarize yourself with theappsettings.jsonfile. - Database Migration: Run migrations and create the database if it does not exist. By default, the SQLite database is set.
- Login:
- Send a POST request to
/api/system/account/login. - Body: { "email": "", "password": "" }
- Send a POST request to
- Retrieve JWT Token: Obtain the Bearer JWT token and include it in the Headers of your HTTP requests.
- Token Expiry: Check the token expiry duration in
appsettings.json.
Before deploying to Azure App Service, remove all directories and files except launchSettings.json from the Properties directory.
The project is configured to use Azure Application Insights. To use it, follow the steps below:
- Rename
nlogsettings_azureinsightsapp_schema.jsontonlogsettings_azureinsightsapp.json. - Change Program.cs to use
nlogsettings_azureinsightsapp.jsoninstead ofnlogsettings.json.` - Add the
instrumentationKeyandEndpointAddressfrom your insights application in thenlogsettings_azureinsightsapp.json.
The project is configured to use Azure Storage Account. To use it, follow the steps below:
- Rename
appsettings_schema.jsontoappsettings.json. - Add the
ConnectionString:AzureBlobStorageConnectionfrom your Azure storage account in theappsettings.json. - Change
Azurein theappsettings.jsonfile. By default, use a temporary store whose data is automatically deleted after ttl and a static library where files are not deleted.
- Local settings: A branch called
TemplateAPI-branchis available, which serves as a template with the main API features without any additional functionality. After downloading the branch for your new API project, change the project name, solution name, namespaces, etc., and read the 'Getting Started' section from the branchREADME.md. - Azure settings: A branch called
TemaplateApi-Azure-AppServices-branchis available. It is ready to be deployed to Azure as an App Service. It serves as a template with the main API features without any additional functionality. After downloading the branch for your new API project, change the project name, solution name, namespaces, etc., and read the 'Getting Started' section from the branchREADME.md.