Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reading Items from JSON file and Add them to Index on Azure Search using cUrl
#!/bin/sh
if [ $# -ne 1 ]
then
echo "Usage: $0 <json.file>"
exit 1;
fi
SERVICE_NAME='<Azure Search Service Name>'
API_VER='2015-02-28-Preview'
ADMIN_KEY='<API KEY>'
CONTENT_TYPE='application/json'
INDEX_NAME='wikipedia'
URL="https://$SERVICE_NAME.search.windows.net/indexes/$INDEX_NAME/docs/index?api-version=$API_VER"
JSON=`cat $1`
curl \
-H "Content-Type: $CONTENT_TYPE"\
-H "api-key: $ADMIN_KEY"\
-XPOST $URL -d "$JSON"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment