Introduction
The finance tracker is a sample application created to demonstrate how Angular Web App for frontend and ASP.Net Core API for backend can be configured to work together. The cloud architecture for this application is hosted on Azure.
Financial Tracker BackEnd
This api is developed using ASP.NET Core 3.1 and is hosted on Azure App Service.
Following Azure Resources are being utilized:
- Azure App Service Plan + Azure App Service - Host the API
- Azure SQL Server + Azure SQL DB - Store data
- Azure Keyvault - Store Secrets
- Azure Application Insights - Logging
We followed the DB first approach and performed the following steps:
-
Created a SQL DB project
-
Created a user in SQL DB called gh-runner by running following commands
CREATE USER [gh-runner] WITH PASSWORD = 'password'; alter role db_datareader add member [gh-runner]; alter role db_datawriter add member [gh-runner]; alter role db_executor add member [gh-runner]; GRANT VIEW DEFINITION TO [gh-runner]; GRANT ALTER TO [gh-runner]; GRANT ALTER ANY DATABASE SCOPED CONFIGURATION to [gh-runner]; GRANT REFERENCES TO [gh-runner];
-
Using GitHub actions - Build & Deploy the SQL DB
-
Created API Project
-
Using the following command, created models and dbContext: “Scaffold-DbContext “Server=tcp:{server_url},1433;Initial Catalog={db_name};Persist Security Info=False;User ID={user_id};Password={password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models”
-
Gave DB access to Azure App Service API by running following command:
create user [financetracker-api] from external provider; alter role db_datareader add member [financetracker-api]; alter role db_datawriter add member [financetracker-api]; alter role db_executor add member [financetracker-api];
-
Then deployed the azure app service as a docker image to GitHub Container Registry using GitHub actions.
The API project has following features:
- APIs authenticated with Azure AD
- Keyvault and SQL accessed by managed identity, thus no secrets exposed anywhere
Finance Tracker FrontEnd
This project is created using Angular and hosted on Azure App Service.
The following steps were performed to develop and configure this app:
- ng new financial-tracker - Initialize default angular application
- npm install –force - Install the required modules
- Generate services and components using ng generate service api, ng generate component AddInvestmentComponent
- Configure authentication using this article: Angular App - Azure AD Auth
- Run the application locally: ng serve
- Create Docker image for angular app, and push it to GitHub container registry using GitHub actions.
- Configure app service to pull image from this container.
Website: Finance Tracker APP
API: Finance Tracker API
Repository Frontend: https://github.com/deep-mm/FinancialTracker-Frontend
Repository Backend: https://github.com/deep-mm/FinanceTracker-Backend
Technology: Azure, Angular, ASP.NET, Azure AD, Database