How to manage secrets in .NET locally and on GitHub? — Maytham Fahmi

md MySecretsApp
cd MySecretsApp
dotnet new console
dotnet user-secrets init
Set UserSecretsId to 'b6b695f2-7611-4ed2-8ea9-a8a716afa697' for MSBuild project '..\MySecretsApp\MySecretsApp.csproj'.
dotnet user-secrets set apikey 4f15a66c-2e17-408d-b6f6-db9dec3d8382
{ "apikey": "4f15a66c-2e17-408d-b6f6-db9dec3d8382" }
using Microsoft.Extensions.Configuration;var config = new ConfigurationBuilder()
string apiKey = config["apikey"];
- name: Test
apikey: ${{ secrets.APIKEY }}
run: dotnet test --no-build --verbosity normal
working-directory: MySecretsApp



Maytham is a passionate software developer with more than ten years of experience. His motivation is to help transform ideas into production ready systems.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store