-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { SearchClient, AzureKeyCredential } = require("@azure/search-documents"); | ||
|
||
const indexName = process.env["SearchIndexName"]; | ||
const apiKey = process.env["SearchApiKey"]; | ||
const searchServiceName = process.env["SearchServiceName"]; | ||
|
||
// Create a SearchClient to send queries | ||
const client = new SearchClient( | ||
`https://` + searchServiceName + `.search.windows.net/`, | ||
indexName, | ||
new AzureKeyCredential(apiKey) | ||
); | ||
|
||
module.exports = async function (context, req) { | ||
|
||
//context.log(req); | ||
|
||
// Reading inputs from HTTP Request | ||
const id = (req.query.id || (req.body && req.body.id)); | ||
|
||
// Returning the document with the matching id | ||
const document = await client.getDocument(id) | ||
|
||
context.log(document); | ||
|
||
context.res = { | ||
// status: 200, /* Defaults to 200 */ | ||
headers: { | ||
"Content-type": "application/json" | ||
}, | ||
body: { document: document} | ||
}; | ||
|
||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters