API Availability Toggling without Restart or Deployment
This project is an ASP.NET Core API for managing to-do items. It supports CRUD operations and is designed to be deployed using Azure Web App with a CI/CD pipeline integrated with GitHub.
- Get all to-do items.
- Get a to-do item by ID.
- Create a new to-do item.
- Update an existing to-do item.
- Delete a to-do item.
- Enable/Disable APIs without re-deployment or restart of the application.
git clone https://github.com/helmutsreinis/ToDoWebApi.git
Navigate to the project folder and run:
dotnet restore
dotnet run
Your API should now be running on http://localhost
on port 7226 or 5000, depending on your local setup.
To run unit tests, navigate to the test project folder and run:
dotnet test
Ensure that you have provisioned a Web App, a free tier plan will suffice for this.
The project is configured to be deployed to Azure using a CI/CD pipeline through GitHub Actions.
- Create a Web App on Azure Portal.
- In the Deployment Center, choose GitHub as the source for your application.
- Authorize Azure to access your GitHub repository.
- Choose the branch from which Azure will deploy (usually
master
ormain
). - Save and finish the setup.
Now, any push to the specified branch will trigger a build and deployment process.
In case a deployment fails, Azure Web App supports rollback mechanisms that can be configured to revert the application to a previous state.
After you have created CI/CD Pipeline, modify the workflow file to include an additional step right after the step '''Build with dotnet'''
- name: Run Unit Tests
run: dotnet test --configuration Release
The file will contain a list of features and the states. After you have deployed your application to productions, you will need access to the hosting environment to access the file to apply changes. Don't forget to restart the applications after the desired API availability has been applied.
"FeatureToggles": { "EnableTodoCreation": true, "EnableTodoDeletion": true, "EnableTodoPost": true, "EnableTodoPut": true, "EnableTodoGet": true, "EnableTodoGetAll": true