This sample extracts HTTP request features and adds them as context features to a Rank request that can be sent to an Azure Personalizer instance. After this request is sent, the user has the option to send a followup Reward request and then generate a new Rank request.
This is a ASP.NET Core MVC with Knockout.js solution. When run, it displays a single page with the Rank request, Reward request, and HTTP request features shown. Pressing the Send Rank Request button sends a rank request to your Personalizer instance with HTTP information gathered from the featurizer as part of the context features. Once sent, the Send Reward Request button can be pressed in order to send a corresponding reward. At any time, you can press the Generate new Rank Request button to create a new Rank request.
-
Clone the Azure Personalizer Samples repo.
git clone https://github.com/Azure-Samples/cognitive-services-personalizer-samples.git
-
Navigate to samples/HttpRequestFeatures.
-
Open
HttpRequestFeaturesExample.sln
.
-
Create a Personalizer instance in the Azure portal.
-
In the Azure portal, find the
Endpoint
and eitherKey1
orKey2
(either will work) in the Keys and Endpoints tab. These are yourPersonalizerServiceEndpoint
and yourPersonalizerApiKey
, respectively. Fill in thePersonalizerServiceEndpoint
in appsettings.json. Configure thePersonalizerApiKey
as an app secrets in one of the following ways:If you are using the .NET Core CLI, you can use the
dotnet user-secrets set "PersonalizerApiKey" "<API Key>"
command. If you are using Visual Studio, you can right-click the project and select the Manage User Secrets menu option to configure the Personalizer keys. By doing this, Visual Studio will open asecrets.json
file where you can add the keys as follows:
{
"PersonalizerApiKey": "<your personalizer key here>",
}
Build and run HttpRequestFeaturesExample. Press F5 if using Visual Studio, or dotnet build
then dotnet run
if using .NET Core CLI. Through the UI, you will be able to send a Rank request and a Reward request and see their responses, as well as the http request features extracted from your environment.