Skip to content

Commit 00b5e43

Browse files
committed
Missing JS deleteIndex file
1 parent f29d54a commit 00b5e43

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { DefaultAzureCredential } from "@azure/identity";
2+
import {
3+
SearchIndexClient
4+
} from "@azure/search-documents";
5+
6+
const credential = new DefaultAzureCredential();
7+
export const searchEndpoint = process.env.AZURE_SEARCH_ENDPOINT;
8+
export const indexName = process.env.AZURE_SEARCH_INDEX_NAME;
9+
10+
console.log(`Using Azure Search endpoint: ${searchEndpoint}`);
11+
console.log(`Using index name: ${indexName}`);
12+
13+
const searchIndexClient = new SearchIndexClient(searchEndpoint, credential);
14+
15+
try {
16+
console.log("Deleting index...");
17+
await searchIndexClient.deleteIndex(indexName);
18+
console.log(`Index ${indexName} deleted`);
19+
} catch (ex) {
20+
console.error("Failed to delete index:", ex);
21+
}

0 commit comments

Comments
 (0)