Skip to main content
This page takes an empty Visual Studio solution to a running ASP.NET Core application that reads a config, a secret and a feature flag from Nexus - and picks up a change made in the console without a restart. It takes about ten minutes.

What you need

  • The .NET 10 SDK (or later), and Visual Studio, Rider or the dotnet CLI.
  • A Nexus service with a secret key (wxs_...) and its endpoint (https://<slug>.westyx.dev) - see Create a service. The endpoint is on the service’s page in the console; the key is shown once, when you create it.
  • In that service, three values to read:

1. Create the project

In your solution, right-click the solution in Solution Explorer and choose Add > New Project. Pick ASP.NET Core Empty, name it Checkout, and choose .NET 10.0.
Any ASP.NET Core project works the same way - a Web API or MVC project only adds its own endpoints.

2. Add the package source and the packages

The packages are on the Westyx GitLab NuGet feed, which is public - no token is needed. Put a nuget.config next to your solution file and commit it, so every machine and your CI find the feed:
Then add two packages to the Checkout project:
Right-click the project, Manage NuGet Packages, set Package source to westyx-nexus (or All), and install WestyxNexus.Extensions.Configuration and WestyxNexus.Extensions.DependencyInjection. Both bring in the core WestyxNexus package.

3. Tell the application where Nexus is

The endpoint is not a secret, so it goes in appsettings.json:
The key is a secret, so it stays out of the repository. For development, keep it in user secrets:
Right-click the project, Manage User Secrets, and add:
In production, set the same value as the environment variable Nexus__ApiKey, or skip the key entirely with workload identity.

4. Write Program.cs

Replace the contents of Program.cs:
What each part does:
  • builder.AddWestyxNexus(...) creates one client, runs the first sync before the application starts, and keeps it current over a live connection that delivers a change within milliseconds. It is disposed with the application.
  • Configs arrive in IConfiguration with : as the separator, so checkout.currency is checkout:currency and binds like any other section. IConfiguration matches property names case-insensitively but not across an underscore, which is what [ConfigurationKeyName] is for.
  • Secrets do not enter IConfiguration, so a configuration dump cannot print them. AddWestyxNexusSecrets<T>("payment") binds every secret under payment. to PaymentOptions, and maps api_key to ApiKey itself. Keep the options type a class: a record prints its values from ToString() - see Secrets binding.
  • Flags are read from the client: GetFlag answers from memory, with no network call.
  • IOptionsMonitor<T> is what sees a change without a restart; IOptions<T> keeps the value from startup.

5. Run it

Start the project (F5 in Visual Studio, or dotnet run) and open /checkout on the address it prints (Now listening on: http://localhost:<port>):
Now change checkout.max_items or switch new.checkout off in the console, and call the endpoint again: the new value is there, with no restart.

If it does not start

The first sync runs before the application starts, so a wrong setting stops it at startup rather than on the first request: The full list is in Error handling.

In production

  • The key comes from the environment - Nexus__ApiKey overrides user secrets and appsettings.json - or from whatever secret store already feeds your IConfiguration.
  • Better: no key at all. On Kubernetes, EKS, AKS, GKE and Azure, the SDK can prove the workload’s identity instead. Set Wif and drop ApiKey:
    See Workload identity for the trust policy it needs.
  • Locally without a key: run westyx dev setup --service=<name> once. It stores a developer credential for the service, and the same Wif configuration finds it on your machine - see Local development.

Which call to use

builder.AddWestyxNexus(config) is the right call for most ASP.NET Core applications. The others serve one side only: Use one of them. Two calls create two clients, each with its own sync loop and live connection. Wiring the packages explains the trade-offs.

Without ASP.NET Core

A console tool or a script creates the client itself and disposes it at the end:
A long-running process calls client.ConnectStream() after creating the client to receive changes as they happen.

Next

Feature management

Nexus flags through IFeatureManager and [FeatureGate].

OpenFeature

The vendor-neutral flag API, with per-user targeting.

Workload identity

Authenticate without a static key.

Configuration

Every NexusConfig option.