.NET WebAPI project with basic authentication configured using MySQL Database, RESTful API, and OpenAI API(ChatGPT).
Requirements:
- .NET 7 SDK installed.
- Docker installed. (Required only for MySQL Database, if you have already MySQL installed, you can skip to step 3 of Running the app but you need to update the
appsettings.Development.json
connection strings)
- Using Docker secrets, in the root of the project create a text file named
db_root_password.txt
and fill the content as the database root password, you should set the password totoor12345
, if you choose something else you need to update theappsettings.Development.json
! - Run
docker-compose up -d
to add & install MySQL container to Docker.
The application uses .NET "Secret manager" More info can be found here
cd
intoAPI
project / folder and run the following command to set up the required secret key for this app:dotnet user-secrets set "OpenAPIKey" "[Value]"
This command will create a secrets.json
on your local machine that will be used only for this app!
As mentioned in the documentation, that will be stored in:
- For windows -
%APPDATA%\Microsoft\UserSecrets\0889f9dd-f77a-406d-9163-55089035a422\secrets.json
- For Linux/macOs -
~/.microsoft/usersecrets/0889f9dd-f77a-406d-9163-55089035a422/secrets.json
- Run
dotnet watch --project .\API\
or any other running command, just make sure you run theAPI
as an entry project.
The application is configured to be deployed and hosted in AWS Elastic Beanstalk using CodePipeline together with CodeBuild and CodeDeploy services to archive CI/CD
a software development best practice and in order to prevent too frequent deployments it has been set up to track any changes to production
branch, so any change to production branch will trigger a new deployment process.
To trigger a new deployment process:
- Do any changes to
master
branch and test it, make sure it works, once that ready make agit commit
. - Switch to
production
branch then make agit merge master
to sync with the master branch. - Upload the changed code to
production
branch usinggit push -u origin production
command. - Done. Switch back to
master
to avoid mistakes.
- https://aws.amazon.com/blogs/devops/building-net-7-applications-with-aws-codebuild/ - as for the current project building time, support for
.NET 7.0
on AWS yet to be released and a manual installation is required and archived by connecting to the AWS Elastic Beanstalk instance withSSH
Client using AWS EC2 service with aKey Pair
. - https://codewithmukesh.com/blog/deploying-aspnet-core-web-api-to-aws-elastic-beanstalk-using-aws-codepipeline/
http://todo-ai-server.us-east-1.elasticbeanstalk.com/swagger/index.html