For local backend dev you will need:
- VS Code
- Git CLI
- .NET Core 3.1
- Docker Desktop
- Dapr CLI
- DAPR VS Code Extension
Then run these commands in a terminal:
# Clone
git clone https://github.com/DanielLarsenNZ/gameon.git
cd gameon
# Init Dapr local *Must run as Admin / sudo
dapr init
A helper script to run all services locally is provided. Dapr must be initialised and running in Docker (Docker desktop).
cd /deploy
./run-dapr-local.ps1
Once you have run run-dapr-local.ps1
, and each service is running in its own console, you can easily debug attaching the VS Code debugger.
- In VS Code, click the Run and Debug button
- Choose .NET Core Attach from the dropdown
- Click the play button
VS Code will prompt to select the process to attach to.
- Type "GameOn" into the search box
- Choose the
GameOn.*.exe
process that you wish to debug
You can debug mutiple processes at one. Repeat these steps for each process.
By default the local dev environment uses a local Redis instance for storage and messaging. You can purge the entire Redis DB using redis-cli
.
First install redis-cli
on Ubuntu in WSL2:
sudo apt-get update
sudo apt-get install redis-tools
Next list and then purge the keys
# Start redis-cli
$ redis-cli
# List all of the keys in the DB
127.0.0.1:6379> KEYS *
# Delete all of the keys and values in the current DB
127.0.0.1:6379> FLUSHDB
# Verify that the keys have been deleted
127.0.0.1:6379> KEYS *
Each service is a new Visual Studio ASP.NET Core project. It is easiest to create new services in Visual Studio (Community, Developer or Enterprise).
- Add a new ASP.NET Core API Project, e.g.
GameOn.(NewServiceName)
- Add project references to
GameOn.Common
,GameOn.CommonCore
Use another service project as a template and:
- Copy nuget references
- Clone Startup.cs
- Create a new empty API Controller
- Create new Models in
GameOn.Common
project, in the Models folder, but change namespace back toGameOn.Common
- Implement a Service
Before you run locally you will need to:
- Add new lines to
/deploy/run-dapr-local.ps1
to build and run the Service. Choose a new unused port for the new service. - Update
Properties/launchSettings.json
to only startup on HTTP and to use the port you chose in the previous step. See How to change the port number for Asp.Net core app?
👉🏻 https://docs.microsoft.com/en-us/graph/tutorials/aspnet-core?tutorial-step=3
GitHub Actions Default environment variables
Debugging Dapr applications with Visual Studio Code
ASP.NET Core Routing Sample - for inter-service calls
How to review your Azure AD B2C tokens using Policy – Run Now and jwt.ms
Quickstart: Protect an ASP.NET Core web API with Microsoft identity platform
Azure-Samples/active-directory-dotnet-native-aspnetcore-v2
Microsoft identity platform and OAuth 2.0 authorization code flow