The FeatureBoard CLI Tool can generate a fully type safe API for your application based on the configuration of your FeatureBoard project.
First run npx @featureboard/cli login to authenticate, then from a folder containing the target .NET csproj run npx @featureboard/cli code-gen --template dotnet-api --output ./ to generate a Features.cs file in the output path or update an existing one.
Install the plugin by running npm install @featureboard/nx-plugin
Login to FeatureBoard by running npx @featureboard/cli login
Generate a Features.cs file by running npm exec nx generate @featureboard/nx-plugin:code-gen --featureBoardProductName="My Product" --projectName=my-api --template=dotnet-api --subFolder=./
Manual creation
Note that FeatureKeyName can be used here to apply the correct feature key to a property, otherwise FeatureBoard will do it’s best to convert the property to a kebab case key.
Implement the audience provider
This provides the audiences of the current user or application context. For example it could pull the roles from the User and add the audience key role-admin, or it could pull a location header which your CDN provides and have country-australia as an audience.
Then register the IAudienceProvider provider with its corresponding implementation. This allows FeatureBoard to use your custom audience provider. e.g. inside Program.cs :
Register the provider in program.cs with an update strategy
FeatureBoard SDKs are designed to work with different update strategies to accommodate various application architectures.
Polling strategy (recommended)
This strategy means that the FeatureBoard service is polled for updates on a frequency based on the MaxAge configuration option in appsettings.json . Default value is 30 seconds.
Request update strategy
This strategy is useful for serverless applications where the VM gets paused between invocations, it will guarantee that the feature values are always up to date for the current invocation at the cost of an additional server call for every request.
Add middleware
Azure Function Support
Azure Function 4.x support under .NET 8 has deprecated In-Process Azure Functions, as such to use .NET 8 with Azure Function 4.x Runtime requires a slight change. Here is an example Program.cs:
The FeatureBoard client can be injected into your class or controller with dependency injection and used directly to resolve features for the current users audience.
Or if you have generated your features model though the cli you can use the generated FeatureFilter attributes to limit access
External State Store
You can create an external state store in the case where FeatureBoard is unavailable. To do this, implement IFeatureBoardExternalState.