Skip to content

Azure Function app that integrates with Recommendation API in Azure Cognitive Services.

Notifications You must be signed in to change notification settings

melzoghbi/RecommenderApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recommendations API Function Application Sample

Introduction

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. Item Recommendation and User Recommendation output

How to use this app:

  1. Setup Recommendation API service in Azure portal.
  2. Set Blob storage files in function.json file.
  3. Set Azure blob storage connection string in AzureWebJobsStorage and AzureWebJobsmofunctions_STORAGE keys in appsettings.json file.
  4. Set Access key in run.csx file for the provisioned cognitive service service in azure.
  5. Set the base uri in run.csx file for the provisioned instance of cognitive service.
  6. Set the Items catalog (Restaurant Catalog as i use it in this app) in the function.json file.
  7. Set the User Transaction for items (Users' Restaurant Trnasactions) in the function.json file.
  8. The function app connects to Azure blob storage to read required files to build a recommender model in Recommendation API in Cogntiive Services.
  9. Run and debug the function app in VS locally by clicking on F5! Enjoy.

Query String parameters

  1. modelId (Optional): The model that the function will connect to, if not provided, the app will create a new model.
  2. buildId (Optional): The build that the function will use, if not provided, the app will create a new model.
  3. itemId (Required): The item id that the recommender model will use to provide item recommendation to a given item.
  4. 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. Using postman to test the function app, here is the output

Description

The Function Application will execute the following activities:

  1. Read Catalog and transaction files from Azure blob storage.
  2. Create a model container.
  3. Add catalog and usage or transaction data needed to train the model.
  4. Trigger a recommendation model build.
  5. Monitor the training process, and notify you when the build has completed.
  6. Use the newly created build to get recommendations.

Source Code Files

  • 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.

More Information

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

About

Azure Function app that integrates with Recommendation API in Azure Cognitive Services.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published