This folder contains the C# Web API code for the App Service API used in the CQRS Pattern. The API exposes endpoints for both command (insert) and query (retrieve) operations.
Program.cs
: Main entry point for the API.appsettings.json
: Configuration file for the API.CommandController.cs
: Handles data insert operations.QueryController.cs
: Handles data retrieval operations.deploy-api.yml
: GitHub Action workflow to automate the deployment of the App Service API.
- Azure Subscription: You need an active Azure account.
- Azure Web App: Ensure the Azure Web App is created (using the Bicep template in the
/infrastructure
folder). - GitHub Secrets Configuration:
AZURE_WEBAPP_PUBLISH_PROFILE
: Publish profile for the Azure Web App.
-
Add Required Secrets to GitHub:
- Go to your repository's Settings > Secrets and variables > Actions > New repository secret.
- Add the following secret:
AZURE_WEBAPP_PUBLISH_PROFILE
: The publish profile for your Azure Web App.
-
Run the GitHub Action:
- Push your changes to the
main
branch or manually trigger the Deploy App Service API workflow from the Actions tab.
- Push your changes to the
-
Monitor the Deployment:
- Go to the Actions tab in your GitHub repository.
- Select the Deploy App Service API workflow to monitor the deployment progress.
-
Insert Data:
- Send a POST request to
/api/command/insert
with a JSON body containing the data to insert. - Example:
{ "data": "Sample data to insert" }
- Send a POST request to
-
Query Data:
- Send a GET request to
/api/query/get?id={your_id}
to retrieve data by ID.
- Send a GET request to
- The CommandController sends data to the Command Handler Function for insertion, which then publishes an event to Azure Event Hubs.
- The QueryController sends a query request to the Query Handler Function, which retrieves data from the Query DB.
This project is licensed under the MIT License - see the LICENSE file for details.