Skip to content

Sample repository to test out Azure Bing Apis

Notifications You must be signed in to change notification settings

vrhovnik/azure-sample-bing-apis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sample repository about using Bing Cognitive Services API

The Bing Search APIs let you build web-connected apps and services that find webpages, images, news, locations, and more without advertisements. By sending search requests using the Bing Search REST APIs or SDKs, you can get relevant information and content for web searches. Use this article to learn about the different Bing search APIs and how you can integrate cognitive searches into your applications and services.

In this repository we will demonstrate the usage with having a simple web application that will use the Bing Search API:

  1. Bing Web Search API - demos page here
  2. Bing Image Search API - demos page here
  3. Bing Entity Search API - demos page here
  4. Bing News Search API - demos page here
  5. Bing Video Search API - demos page here
  6. Bing Visual Search API - demos page here
  7. Bing Autosuggest API
  8. Bing Spell Check API - demos page here

It will integrate the API inside the app to demonstrate the usage in the app itself.

Prerequisites

  1. an active Azure subscription - MSDN or trial or Azure Pass is fine - you can also do all of the work in Azure Shell (all tools installed) and by using Github Codespaces
  2. Subscription key from Azure Portal
  3. PowerShell installed - we do recommend an editor like Visual Studio Code to be able to write scripts, YAML pipelines and connect to repos to submit changes.
  4. [OPTIONAL] Windows Terminal to be able to work with multiple terminal Windows with ease

If you will be working on your local machines, you will need to have:

  1. Powershell installed
  2. git installed - instructions step by step here
  3. .NET installed to run the application if you want to run it locally
  4. an editor (besides notepad) to see and work with code and more (for example Visual Studio Code or NeoVim or Visual Studio or Jetbrains Rider)

To control settings, we recommend to use environment variables. The easiest way to set them is via PowerShell and his provider option.

Set-Content env:\$name $value

Check out appsettings.json to see what settings are needed.

For example:

Set-Content env:\App__SubscriptionKey "YourSubscriptionKeyYouGetFromAzure"

You can check out docs for dotnet run for more options how to run the app with parameters.

If you want to automate the process, you can use PowerShell script to prepare the environment for you with *.env files.

Get-Content $PathToENVFile | ForEach-Object {
    $name, $value = $_.split('=')
    Set-Content env:\$name $value
}

Open PowerShell and run the upper command by replacing PathToENVFile the path to your file in double quotes.

When all settings are set, you can run the application with dotnet run command.

Example below:

dotnet run

Open the browser on URL presented to you on the screen and you should see the application running.

App is running on localhost

Run it in postman

If you want to explore REST api calls, I have added postman collection. To run it, you will need to install client side tool Postman.

After install, open postman:

  1. use Import option from File menu (File -- Import or press CTRL+O)
  2. select files and save it in collection.
  3. Change the key and update Authorization tab, which you get from Azure portal (when you create resource)

Bing authorization information

  1. test out the api's

Links and additional information

  1. Bing Search API overview
  2. Bing Search API pricing
  3. Bing usage and guidelines