Making API Requests


Building a Recommendation Engine on Azure

The course is part of this learning path

Start course

Building a Recommendation Engine on Azure is a course designed for teams interested in using artificial intelligence to add product recommendations to their websites.

A product recommendation engine is a valuable feature that helps drive sales on e-commerce sites. In this course, you will learn the essentials of building, deploying, and testing a recommendation engine on Microsoft Azure. You will also build skills to fine-tune a recommendation model and evaluate its effectiveness.

This course is made up of five lectures covering deploying, testing, configuring, evaluating models, and making API requests. This is an intermediate-level course, and prior Azure and API experience is recommended.

Learning Objectives

  • Deploy a recommendation engine on Microsoft Azure
  • Test and evaluate different recommendation models
  • Make API calls to the Microsoft Product Recommendations Solution

Intended Audience

  • People who are interested in artificial intelligence services on Microsoft Azure, especially recommendation engines


  • Experience using Microsoft Azure
  • Experience using APIs

Related Training Content


The GitHub repository for this course is at



- [Instructor] Now that you know how to train and evaluate a model, you'll need a practical way to get recommendations from it. So far, we've just used the web form to submit recommendation requests, but that won't work for your product website, which will need to make lots of recommendations in real time. The answer, of course, is to make API requests from the code on your website. 

As I mentioned earlier, there's some sample C# code in Microsoft's GitHub repository for this project, but I'm going to show you something more generic. We're going to hit the API directly from the command line. All you need is the curl command. 

If you're running a recent version of Windows 10, or you're on a Mac or a Linux, then the curl command will already be installed. If not then you can download it from Alternatively, you can run it from Cloud Shell in the Azure portal. I've included the skeleton of a curl command in the ReadMe file for this course. Copy and paste the first part of it. 

If you don't still have the page with the primary key open in the Azure portal, then go to resource groups and click recommend. Then click deployments, Microsoft.template, and outputs. Copy the recommend primary key and paste it into the command line. 

You have to include a key in the header of the request. If you don't, then authorization will fail. You can use the admin key for all API operations. If you're just requesting a recommendation, then alternatively, you can use the recommend key, which is what we're doing here. It's better to use the recommend key because if a hacker obtains it, then they'll only be able to use it to get recommendations. Now type single quote space single quote. 

Then copy the website URL and paste it. Then add slash API slash models slash. Now go back to your model, copy the ID, and paste it. Okay, just one more thing. Go back to the ReadMe file, copy the last part of the command, including the slash, and paste it. Whew, that was a lot of steps. 

All right, now we can finally hit enter. It gave us the same results as when we made the request in the web form, although it's a lot harder to read. The advantage is that you can make this API request from your code. There are APIs available for doing everything else, as well, such as training and deleting models. I'm not going to go through them, but you can find the full API documentation at this URL. And that's it for making API requests.

About the Author
Learning Paths

Guy launched his first training website in 1995 and he's been helping people learn IT technologies ever since. He has been a sysadmin, instructor, sales engineer, IT manager, and entrepreneur. In his most recent venture, he founded and led a cloud-based training infrastructure company that provided virtual labs for some of the largest software vendors in the world. Guy’s passion is making complex technology easy to understand. His activities outside of work have included riding an elephant and skydiving (although not at the same time).