

If you downloaded the source code and haven't installed the required packages yet, run npm install first. Use a terminal window to run the following command: node index.js npm install dotenvĬonfirm that you've configured the projects and its dependencies by checking that your package.json file looks similar to the following json: has been created.`) Īt this point, you're ready to run the sample. npm install dotenv, which is used to import the environment variables such as your search service name and API key. Install the JavaScript/TypeScript SDK for Azure Cognitive Search. To fully initialize the project, press Enter multiple times to accept the default values, except for the License, which you should set to "MIT". Initialize an empty project with npm by running the following command. Create a new npm projectīegin by opening VS Code and its integrated terminal or another terminal such as the Node.js command prompt.Ĭreate a development directory, giving it the name quickstart : mkdir quickstart Having a valid key establishes trust, on a per request basis, between the application sending the request and the service that handles it. You can use either one.Īll requests require an api-key on every request sent to your service. There are two interchangeable primary and secondary keys. In Settings > Keys, get an admin key for full rights on the service, required if you're creating or deleting objects. Sign in to the Azure portal, and in your search service Overview page, get the URL. You'll specify both values when creating the client in a later step. As a first step, find the API key and URL to add to your project. Then create a new project with npm as outlined below.Ĭalls to the service require a URL endpoint and an access key on every request. Start by getting the endpoint and key for your search service. You can use a free service for this quickstart. Create a service or find an existing service. Prerequisitesīefore you begin, have the following tools and services:Īzure Cognitive Search. If you don't have an Azure subscription, create a free account before you begin. Alternatively, you can download the source code and data and run the application from the command line.

This article demonstrates how to create the application step by step.


Use the JavaScript/TypeScript SDK for Azure Cognitive Search to create a Node.js application in JavaScript that creates, loads, and queries a search index.
