Gym members and their classes
Read live from the GymMembership Azure SQL database.
Loading members…
The database is on Azure's free tier and goes to sleep when nobody uses it, so the first load can take up to a minute.
Code First migration
- The GymMember and ClassSession models are C# classes.
- The DbContext sets up a many-to-many link: a member can attend many classes.
- Running the migration creates:
- the GymMembership database
- the GymMember and ClassSession tables
- the joining table GymMemberClassSession
- test data, such as Alice Johnson attending Morning Yoga and HIIT Blast
Terraform deployment to Azure
- Uses the existing resource group ResourceGroup1.
- Creates the App Service plan asp-gym-membership-b1. Terraform can't create a Free tier plan, so it was moved to Free in the portal.
- Creates the GymMembership database on the existing server
wizzard262.database.windows.net. The free database also had to be set up in the portal. - Creates the web app gym-membership-webapp and gives it a connection string called DefaultConnection.
- Sets
ASPNETCORE_ENVIRONMENTto Development.
Azure DevOps pipeline
Terraform makes the resources; a pipeline then deploys into them:
- the C# MVC app to the web app gym-membership-webapp
- the database migrations (tables and data) to GymMembership