Skip to content

Commit ef7a478

Browse files
authored
[Search] safe secrets (#33437)
`supportsSafeSecretStandard` is a parameter that tells whether the subscription the resource is being created in disallows API-key-like authentication. This PR updates the `test-resources.bicep` file to use this parameter to disable such authentication methods if they're disallowed by the target subscription. This unblocks creating resources in the playground subscription. Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4666974&view=results Failures in CI and nightly are unrelated to the PR.
1 parent 32f91fe commit ef7a478

37 files changed

+116
-122
lines changed

sdk/search/search-documents/samples-dev/indexOperations.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { SearchIndexClient } from "@azure/search-documents";
1111
import "dotenv/config";
1212

1313
const endpoint = process.env.ENDPOINT || "";
14-
const TEST_INDEX_NAME = "example-index-sample-1";
14+
const INDEX_NAME = "example-index-sample-1";
1515

1616
async function createIndex(indexName: string, client: SearchIndexClient): Promise<void> {
1717
console.log(`Creating Index Operation`);
@@ -59,7 +59,7 @@ async function createIndex(indexName: string, client: SearchIndexClient): Promis
5959
async function getAndUpdateIndex(indexName: string, client: SearchIndexClient): Promise<void> {
6060
console.log(`Get And Update Index Operation`);
6161
const index: SearchIndex = await client.getIndex(indexName);
62-
await index.fields.push({
62+
index.fields.push({
6363
type: "Edm.DateTimeOffset",
6464
name: "lastUpdatedOn",
6565
filterable: true,
@@ -139,13 +139,13 @@ async function main(): Promise<void> {
139139
}
140140
const client = new SearchIndexClient(endpoint, new DefaultAzureCredential());
141141
try {
142-
await createIndex(TEST_INDEX_NAME, client);
143-
await getAndUpdateIndex(TEST_INDEX_NAME, client);
144-
await getIndexStatistics(TEST_INDEX_NAME, client);
142+
await createIndex(INDEX_NAME, client);
143+
await getAndUpdateIndex(INDEX_NAME, client);
144+
await getIndexStatistics(INDEX_NAME, client);
145145
await getServiceStatistics(client);
146146
await listIndexes(client);
147147
} finally {
148-
await deleteIndex(TEST_INDEX_NAME, client);
148+
await deleteIndex(INDEX_NAME, client);
149149
}
150150
}
151151

sdk/search/search-documents/samples-dev/synonymMapOperations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function getAndUpdateSynonymMap(
2929
console.log(`Get And Update SynonymMap Operation`);
3030
const sm: SynonymMap = await client.getSynonymMap(synonymMapName);
3131
console.log(`Update synonyms Synonym Map my-synonymmap`);
32-
await sm.synonyms.push("Florida, Fld. => FL");
32+
sm.synonyms.push("Florida, Fld. => FL");
3333
await client.createOrUpdateSynonymMap(sm);
3434
}
3535

sdk/search/search-documents/assets/vectors.ts renamed to sdk/search/search-documents/samples-dev/vectors.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
/**
5+
* A bunch of embeddings to be used in the samples.
6+
* @azsdk-util true
7+
*/
8+
49
// An embedding of Fancy Stay's English description
510
export const fancyStayEnVector = [
611
-0.0038569495, 0.028041067, -0.014854468, -0.02942227, -0.003537709, 0.020001411, -0.03426952,

sdk/search/search-documents/samples/v12-beta/javascript/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP
7878
[stickysession]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v12-beta/javascript/stickySession.js
7979
[synonymmapoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v12-beta/javascript/synonymMapOperations.js
8080
[vectorsearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v12-beta/javascript/vectorSearch.js
81-
[apiref]: https://learn.microsoft.com/javascript/api/@azure/search-documents
81+
[apiref]: https://learn.microsoft.com/javascript/api/@azure/search-documents?view=azure-node-preview
8282
[freesub]: https://azure.microsoft.com/free/
8383
[createinstance_azuresearchdocumentsinstance]: https://learn.microsoft.com/azure/search/search-create-service-portal
8484
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/README.md

sdk/search/search-documents/samples/v12-beta/javascript/bufferedSenderAutoFlushSize.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ const {
1212
SearchIndexClient,
1313
SearchIndexingBufferedSender,
1414
} = require("@azure/search-documents");
15-
const { createIndex, delay, documentKeyRetriever, WAIT_TIME } = require("./setup");
16-
17-
require("dotenv").config();
15+
const { createIndex, delay, documentKeyRetriever, WAIT_TIME } = require("./setup.js");
16+
require("dotenv/config");
1817

1918
/**
2019
* This sample is to demonstrate the use of SearchIndexingBufferedSender.

sdk/search/search-documents/samples/v12-beta/javascript/bufferedSenderAutoFlushTimer.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ const {
1313
SearchIndexClient,
1414
SearchIndexingBufferedSender,
1515
} = require("@azure/search-documents");
16-
const { createIndex, delay, documentKeyRetriever, WAIT_TIME } = require("./setup");
17-
18-
require("dotenv").config();
16+
const { createIndex, delay, documentKeyRetriever, WAIT_TIME } = require("./setup.js");
17+
require("dotenv/config");
1918

2019
/**
2120
* This sample is to demonstrate the use of SearchIndexingBufferedSender.

sdk/search/search-documents/samples/v12-beta/javascript/bufferedSenderManualFlush.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ const {
1212
SearchIndexClient,
1313
SearchIndexingBufferedSender,
1414
} = require("@azure/search-documents");
15-
const { createIndex, delay, documentKeyRetriever, WAIT_TIME } = require("./setup");
16-
17-
require("dotenv").config();
15+
const { createIndex, delay, documentKeyRetriever, WAIT_TIME } = require("./setup.js");
16+
require("dotenv/config");
1817

1918
/**
2019
* This sample is to demonstrate the use of SearchIndexingBufferedSender.

sdk/search/search-documents/samples/v12-beta/javascript/dataSourceConnectionOperations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { SearchIndexerClient } = require("@azure/search-documents");
10-
11-
require("dotenv").config();
10+
require("dotenv/config");
1211

1312
const endpoint = process.env.ENDPOINT || "";
1413
const connectionString = process.env.CONNECTION_STRING || "";

sdk/search/search-documents/samples/v12-beta/javascript/indexOperations.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { SearchIndexClient } = require("@azure/search-documents");
10-
11-
require("dotenv").config();
10+
require("dotenv/config");
1211

1312
const endpoint = process.env.ENDPOINT || "";
14-
const TEST_INDEX_NAME = "example-index-sample-1";
13+
const INDEX_NAME = "example-index-sample-1";
1514

1615
async function createIndex(indexName, client) {
1716
console.log(`Creating Index Operation`);
@@ -139,13 +138,13 @@ async function main() {
139138
}
140139
const client = new SearchIndexClient(endpoint, new DefaultAzureCredential());
141140
try {
142-
await createIndex(TEST_INDEX_NAME, client);
143-
await getAndUpdateIndex(TEST_INDEX_NAME, client);
144-
await getIndexStatistics(TEST_INDEX_NAME, client);
141+
await createIndex(INDEX_NAME, client);
142+
await getAndUpdateIndex(INDEX_NAME, client);
143+
await getIndexStatistics(INDEX_NAME, client);
145144
await getServiceStatistics(client);
146145
await listIndexes(client);
147146
} finally {
148-
await deleteIndex(TEST_INDEX_NAME, client);
147+
await deleteIndex(INDEX_NAME, client);
149148
}
150149
}
151150

sdk/search/search-documents/samples/v12-beta/javascript/indexerOperations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { SearchIndexerClient } = require("@azure/search-documents");
10-
11-
require("dotenv").config();
10+
require("dotenv/config");
1211

1312
const endpoint = process.env.ENDPOINT || "";
1413
const dataSourceName = process.env.DATA_SOURCE_NAME || "";

sdk/search/search-documents/samples/v12-beta/javascript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"dependencies": {
2525
"@azure/search-documents": "next",
2626
"dotenv": "latest",
27-
"@azure/identity": "^4.0.1"
27+
"@azure/identity": "^4.5.0"
2828
}
2929
}

sdk/search/search-documents/samples/v12-beta/javascript/searchClientOperations.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { GeographyPoint, SearchClient, SearchIndexClient } = require("@azure/search-documents");
10-
const { createIndex, delay, WAIT_TIME } = require("./setup");
11-
12-
require("dotenv").config();
10+
const { createIndex, delay, WAIT_TIME } = require("./setup.js");
11+
require("dotenv/config");
1312

1413
/**
1514
* This sample is to demonstrate the use of SearchClient.

sdk/search/search-documents/samples/v12-beta/javascript/setup.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
const { KnownAnalyzerNames } = require("@azure/search-documents");
2-
const { env } = require("process");
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
33

4+
/**
5+
* Defines the utility methods.
6+
*/
7+
8+
require("dotenv/config");
9+
const { KnownAnalyzerNames } = require("@azure/search-documents");
10+
const { env } = require("node:process");
411
const WAIT_TIME = 4000;
512

613
const documentKeyRetriever = (document) => {
@@ -16,7 +23,6 @@ function delay(timeInMs) {
1623
return new Promise((resolve) => setTimeout(resolve, timeInMs));
1724
}
1825

19-
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
2026
async function createIndex(client, name) {
2127
const hotelIndex = {
2228
name,

sdk/search/search-documents/samples/v12-beta/javascript/skillSetOperations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { SearchIndexerClient } = require("@azure/search-documents");
10-
11-
require("dotenv").config();
10+
require("dotenv/config");
1211

1312
const endpoint = process.env.ENDPOINT || "";
1413

sdk/search/search-documents/samples/v12-beta/javascript/stickySession.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
const { DefaultAzureCredential } = require("@azure/identity");
1010
const { odata, SearchIndexClient } = require("@azure/search-documents");
11-
const { createIndex, delay, WAIT_TIME } = require("./setup");
12-
13-
require("dotenv").config();
11+
const { createIndex, delay, WAIT_TIME } = require("./setup.js");
12+
require("dotenv/config");
1413

1514
/**
1615
* If you're querying a replicated index, Azure AI Search may target any replica with your queries.

sdk/search/search-documents/samples/v12-beta/javascript/synonymMapOperations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { SearchIndexClient } = require("@azure/search-documents");
10-
11-
require("dotenv").config();
10+
require("dotenv/config");
1211

1312
const endpoint = process.env.ENDPOINT || "";
1413
const TEST_SYNONYM_MAP_NAME = "example-synonymmap-sample-1";

sdk/search/search-documents/samples/v12-beta/javascript/vectorSearch.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77

88
const { DefaultAzureCredential } = require("@azure/identity");
99
const { GeographyPoint, SearchClient, SearchIndexClient } = require("@azure/search-documents");
10-
const { createIndex, delay, WAIT_TIME } = require("./setup");
11-
12-
const dotenv = require("dotenv");
13-
const { fancyStayEnVector, fancyStayFrVector, luxuryQueryVector } = require("./vectors");
14-
dotenv.config();
10+
const { createIndex, delay, WAIT_TIME } = require("./setup.js");
11+
require("dotenv/config");
12+
const { fancyStayEnVector, fancyStayFrVector, luxuryQueryVector } = require("./vectors.js");
1513

1614
/**
1715
* This sample is to demonstrate the use of SearchClient's vector search feature.

sdk/search/search-documents/samples/v12-beta/javascript/vectors.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
/**
5+
* A bunch of embeddings to be used in the samples.
6+
*/
7+
48
// An embedding of Fancy Stay's English description
59
const fancyStayEnVector = [
610
-0.0038569495, 0.028041067, -0.014854468, -0.02942227, -0.003537709, 0.020001411, -0.03426952,

sdk/search/search-documents/samples/v12-beta/typescript/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP
9090
[stickysession]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v12-beta/typescript/src/stickySession.ts
9191
[synonymmapoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v12-beta/typescript/src/synonymMapOperations.ts
9292
[vectorsearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v12-beta/typescript/src/vectorSearch.ts
93-
[apiref]: https://learn.microsoft.com/javascript/api/@azure/search-documents
93+
[apiref]: https://learn.microsoft.com/javascript/api/@azure/search-documents?view=azure-node-preview
9494
[freesub]: https://azure.microsoft.com/free/
9595
[createinstance_azuresearchdocumentsinstance]: https://learn.microsoft.com/azure/search/search-create-service-portal
9696
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/README.md

sdk/search/search-documents/samples/v12-beta/typescript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"dependencies": {
2929
"@azure/search-documents": "next",
3030
"dotenv": "latest",
31-
"@azure/identity": "^4.0.1"
31+
"@azure/identity": "^4.5.0"
3232
},
3333
"devDependencies": {
3434
"@types/node": "^18.0.0",

sdk/search/search-documents/samples/v12-beta/typescript/src/bufferedSenderAutoFlushSize.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import {
1212
SearchIndexClient,
1313
SearchIndexingBufferedSender,
1414
} from "@azure/search-documents";
15-
import type { Hotel } from "./interfaces";
16-
import { createIndex, delay, documentKeyRetriever, WAIT_TIME } from "./setup";
17-
18-
import * as dotenv from "dotenv";
19-
dotenv.config();
15+
import type { Hotel } from "./interfaces.js";
16+
import { createIndex, delay, documentKeyRetriever, WAIT_TIME } from "./setup.js";
17+
import "dotenv/config";
2018

2119
/**
2220
* This sample is to demonstrate the use of SearchIndexingBufferedSender.

sdk/search/search-documents/samples/v12-beta/typescript/src/bufferedSenderAutoFlushTimer.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import {
1313
SearchIndexClient,
1414
SearchIndexingBufferedSender,
1515
} from "@azure/search-documents";
16-
import type { Hotel } from "./interfaces";
17-
import { createIndex, delay, documentKeyRetriever, WAIT_TIME } from "./setup";
18-
19-
import * as dotenv from "dotenv";
20-
dotenv.config();
16+
import type { Hotel } from "./interfaces.js";
17+
import { createIndex, delay, documentKeyRetriever, WAIT_TIME } from "./setup.js";
18+
import "dotenv/config";
2119

2220
/**
2321
* This sample is to demonstrate the use of SearchIndexingBufferedSender.

sdk/search/search-documents/samples/v12-beta/typescript/src/bufferedSenderManualFlush.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import {
1212
SearchIndexClient,
1313
SearchIndexingBufferedSender,
1414
} from "@azure/search-documents";
15-
import type { Hotel } from "./interfaces";
16-
import { createIndex, delay, documentKeyRetriever, WAIT_TIME } from "./setup";
17-
18-
import * as dotenv from "dotenv";
19-
dotenv.config();
15+
import type { Hotel } from "./interfaces.js";
16+
import { createIndex, delay, documentKeyRetriever, WAIT_TIME } from "./setup.js";
17+
import "dotenv/config";
2018

2119
/**
2220
* This sample is to demonstrate the use of SearchIndexingBufferedSender.

sdk/search/search-documents/samples/v12-beta/typescript/src/dataSourceConnectionOperations.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import { DefaultAzureCredential } from "@azure/identity";
99
import type { SearchIndexerDataSourceConnection } from "@azure/search-documents";
1010
import { SearchIndexerClient } from "@azure/search-documents";
11-
12-
import * as dotenv from "dotenv";
13-
dotenv.config();
11+
import "dotenv/config";
1412

1513
const endpoint = process.env.ENDPOINT || "";
1614
const connectionString = process.env.CONNECTION_STRING || "";

sdk/search/search-documents/samples/v12-beta/typescript/src/indexOperations.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
import { DefaultAzureCredential } from "@azure/identity";
99
import type { SearchIndex, SearchIndexStatistics } from "@azure/search-documents";
1010
import { SearchIndexClient } from "@azure/search-documents";
11-
12-
import * as dotenv from "dotenv";
13-
dotenv.config();
11+
import "dotenv/config";
1412

1513
const endpoint = process.env.ENDPOINT || "";
16-
const TEST_INDEX_NAME = "example-index-sample-1";
14+
const INDEX_NAME = "example-index-sample-1";
1715

1816
async function createIndex(indexName: string, client: SearchIndexClient): Promise<void> {
1917
console.log(`Creating Index Operation`);
@@ -141,13 +139,13 @@ async function main(): Promise<void> {
141139
}
142140
const client = new SearchIndexClient(endpoint, new DefaultAzureCredential());
143141
try {
144-
await createIndex(TEST_INDEX_NAME, client);
145-
await getAndUpdateIndex(TEST_INDEX_NAME, client);
146-
await getIndexStatistics(TEST_INDEX_NAME, client);
142+
await createIndex(INDEX_NAME, client);
143+
await getAndUpdateIndex(INDEX_NAME, client);
144+
await getIndexStatistics(INDEX_NAME, client);
147145
await getServiceStatistics(client);
148146
await listIndexes(client);
149147
} finally {
150-
await deleteIndex(TEST_INDEX_NAME, client);
148+
await deleteIndex(INDEX_NAME, client);
151149
}
152150
}
153151

sdk/search/search-documents/samples/v12-beta/typescript/src/indexerOperations.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import { DefaultAzureCredential } from "@azure/identity";
99
import type { SearchIndexer, SearchIndexerStatus } from "@azure/search-documents";
1010
import { SearchIndexerClient } from "@azure/search-documents";
11-
12-
import * as dotenv from "dotenv";
13-
dotenv.config();
11+
import "dotenv/config";
1412

1513
const endpoint = process.env.ENDPOINT || "";
1614
const dataSourceName = process.env.DATA_SOURCE_NAME || "";

sdk/search/search-documents/samples/v12-beta/typescript/src/searchClientOperations.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
import { DefaultAzureCredential } from "@azure/identity";
99
import type { SelectFields } from "@azure/search-documents";
1010
import { GeographyPoint, SearchClient, SearchIndexClient } from "@azure/search-documents";
11-
import type { Hotel } from "./interfaces";
12-
import { createIndex, delay, WAIT_TIME } from "./setup";
13-
14-
import * as dotenv from "dotenv";
15-
dotenv.config();
11+
import type { Hotel } from "./interfaces.js";
12+
import { createIndex, delay, WAIT_TIME } from "./setup.js";
13+
import "dotenv/config";
1614

1715
/**
1816
* This sample is to demonstrate the use of SearchClient.

0 commit comments

Comments
 (0)