This function app is using content files; these files are stored in Azure blob storage to recommend items (Item to Item recommendation) or recommend user's items (User to item recommendation).
This sample is a modified app from the sample recommendation console app that is stored here. You can find more details on the Recommendations API and other Cognitive Services at www.microsoft.com/cognitive-services/.
The Recommendations API identifies consumption patterns from your transaction information in order to provide recommendations. These recommendations can help your customers more easily discover items that they may be interested in. By showing your customers products that they are more likely to be interested in, you will, in turn, increase your sales.
The function application out when running it locally from Visual Studio 2015.
- Setup Recommendation API service in Azure portal.
- Set Blob storage files in function.json file.
- Set Azure blob storage connection string in AzureWebJobsStorage and AzureWebJobsmofunctions_STORAGE keys in appsettings.json file.
- Set Access key in run.csx file for the provisioned cognitive service service in azure.
- Set the base uri in run.csx file for the provisioned instance of cognitive service.
- Set the Items catalog (Restaurant Catalog as i use it in this app) in the function.json file.
- Set the User Transaction for items (Users' Restaurant Trnasactions) in the function.json file.
- The function app connects to Azure blob storage to read required files to build a recommender model in Recommendation API in Cogntiive Services.
- Run and debug the function app in VS locally by clicking on F5! Enjoy.
- modelId (Optional): The model that the function will connect to, if not provided, the app will create a new model.
- buildId (Optional): The build that the function will use, if not provided, the app will create a new model.
- itemId (Required): The item id that the recommender model will use to provide item recommendation to a given item.
- userId (Required): The user id that the recommender model will use to recommend items to a given user.
Using postman to test the function app, below is the output in the function app in VS 2015.
The Function Application will execute the following activities:
- Read Catalog and transaction files from Azure blob storage.
- Create a model container.
- Add catalog and usage or transaction data needed to train the model.
- Trigger a recommendation model build.
- Monitor the training process, and notify you when the build has completed.
- Use the newly created build to get recommendations.
- run.csx - The main file that included the function app code.
- RecommendationsApiWrapper.cs - A wrapper that makes it easy to consume the recommendations API from C#
- Helpers.cs - Helper file with classes to simplify serialization/deserialization of the RESTful API requests/responses.
Azure Functions Developer Reference
Working with Triggers and Bindings
Create your first Azure function in VS
Get started with Recommendation API
Recommendation sample app on GitHub
Got questions? don't hesitate to contact me. You can follow me on Twitter: @MostafaElzoghbi