你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

Azure AI 搜索 JavaScript客户端库 - 版本 13.1.0

Azure AI 搜索(前称“Azure 认知搜索”)是一个由 AI 驱动的信息检索平台,帮助开发者构建丰富的搜索体验和生成式 AI 应用,将大型语言模型与企业数据结合在一起。

Azure AI 搜索服务非常适合以下应用程序方案:

  • 将各种内容类型合并到单个可搜索索引中。 若要填充索引,可以推送包含内容的 JSON 文档,或者如果数据已在 Azure 中,请创建索引器以自动拉取数据。
  • 将技能集附加到索引器,以从图像和非结构化文档创建可搜索内容。 技能集利用 Azure AI 服务中的 API 进行内置 OCR、实体识别、关键短语提取、语言检测、文本翻译和情绪分析。 还可以添加自定义技能,以在数据引入期间集成内容的外部处理。
  • 在搜索客户端应用程序中,实现类似于商业 Web 搜索引擎和聊天样式应用的查询逻辑和用户体验。

使用客户端库可以 @azure/search-documents :

  • 使用矢量、关键字和混合查询表单提交查询。
  • 为元数据、地理空间搜索、分面导航或基于筛选条件缩小结果范围实现筛选查询。
  • 创建和管理搜索索引。
  • 在搜索索引中上传和更新文档。
  • 创建和管理将数据从 Azure 拉取到索引的索引器。
  • 创建和管理将 AI 扩充添加到数据引入的技能集。
  • 为高级文本分析或多语言内容创建和管理分析器。
  • 通过语义排名和评分配置文件优化结果,以考虑业务逻辑或新鲜度。

关键链接:

开始

安装 @azure/search-documents 包

npm install @azure/search-documents

版本 13.1.0 默认针对 2026-10-01 GA 服务 API。 从版本 13.0.0 升级时,请查看 GA-to-GA 的破坏性变更。 更新后的 TypeScript 和 JavaScript 示例可在 samples/v13 中获取。

当前支持的环境

有关更多详细信息,请参阅我们的支持政策。

先决条件

若要创建新的搜索服务,可以使用 Azure 门户、 Azure PowerShell 或 Azure CLI。 下面是使用 Azure CLI 创建免费实例以开始使用的示例:

az search service create --name <mysearch> --resource-group <mysearch-rg> --sku free --location westus

有关可用选项的详细信息,请参阅 选择定价层 。

对客户端进行身份验证

要与搜索服务交互,创建合适的客户端: SearchClient 文档、 SearchIndexClient 索引和知识资源、 SearchIndexerClient 数据源/索引器/技能集,或 KnowledgeRetrievalClient 知识库检索。 若要实例化客户端对象,需要 终结点 和 Azure 角色 或 API 密钥。 有关搜索服务支持 的身份验证方法 的详细信息,可以参阅文档。

获取 API 密钥

API 密钥可能是一种更简单的入门方法,因为它不需要预先存在的角色分配。

可以从 Azure 门户中的搜索服务获取终结点和 API 密钥。 有关如何获取 API 密钥的说明,请参阅 文档 。

或者,可以使用以下 Azure CLI 命令从搜索服务检索 API 密钥:

az search admin-key show --resource-group <your-resource-group-name> --service-name <your-resource-name>

有两种类型的密钥用于访问搜索服务: admin(读写) 和 查询(只读) 键。 限制客户端应用中的访问和操作对于保护服务上的搜索资产至关重要。 始终对源自客户端应用的任何查询使用查询密钥,而不是管理密钥。

注意:上面示例的 Azure CLI 片段会获取管理员密钥,这样开始探索 API 会更方便,但需要谨慎管理。

获得 API 密钥后,可按如下所示使用它:

import {
  SearchClient,
  AzureKeyCredential,
  SearchIndexClient,
  SearchIndexerClient,
  KnowledgeRetrievalClient,
} from "@azure/search-documents";

// To query and manipulate documents
const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

// To manage indexes and synonymmaps
const indexClient = new SearchIndexClient("<endpoint>", new AzureKeyCredential("<apiKey>"));

// To manage indexers, datasources and skillsets
const indexerClient = new SearchIndexerClient("<endpoint>", new AzureKeyCredential("<apiKey>"));

// To retrieve from a knowledge base
const knowledgeRetrievalClient = new KnowledgeRetrievalClient(
  "<endpoint>",
  "<knowledgeBaseName>",
  new AzureKeyCredential("<apiKey>"),
);

在国家云中进行身份验证

要在 国家云中进行身份验证,您需要对客户端配置进行以下添加:

  • 将AudienceSearchClientOptions
import { DefaultAzureCredential } from "@azure/identity";
import {
  SearchClient,
  KnownSearchAudience,
  SearchIndexClient,
  SearchIndexerClient,
  KnowledgeRetrievalClient,
} from "@azure/search-documents";

const credential = new DefaultAzureCredential({
  authorityHost: "https://login.chinacloudapi.cn",
});

// To query and manipulate documents
const searchClient = new SearchClient("<endpoint>", "<indexName>", credential, {
  audience: KnownSearchAudience.AzureChina,
});

// To manage indexes and synonymmaps
const indexClient = new SearchIndexClient("<endpoint>", credential, {
  audience: KnownSearchAudience.AzureChina,
});

// To manage indexers, datasources and skillsets
const indexerClient = new SearchIndexerClient("<endpoint>", credential, {
  audience: KnownSearchAudience.AzureChina,
});

// To retrieve from a knowledge base
const knowledgeRetrievalClient = new KnowledgeRetrievalClient(
  "<endpoint>",
  "<knowledgeBaseName>",
  credential,
  { audience: KnownSearchAudience.AzureChina },
);

关键概念

Azure AI 搜索服务包含一个或多个索引,这些索引以 JSON 文档的形式提供可搜索数据的持久存储。 (如果你是搜索新手,可以粗略地将索引和数据库表做个类比。) 客户端库通过 @azure/search-documents 四种主要客户端类型公开对这些资源进行操作。

注意:浏览器的使用取决于所选搜索操作和资源是否配置了 CORS。 文件知识源和知识库会暴露 CORS 设置,但许多管理操作是为可信的服务器端应用设计的。

TypeScript/JavaScript 特定概念

文件

存储在搜索索引内的项。 此文档的形状在索引中使用属性 fields 进行描述。 每个都有 SearchField 一个名称、一个数据类型和其他元数据,例如它是可搜索还是可筛选的。

分页

通常,您只希望一次向用户 显示搜索结果的子集 。 若要支持这一点,可以使用 top和 参数 skipincludeTotalCount 在搜索结果之上提供分页体验。

文档字段编码

索引中支持的数据类型会映射到 API 请求/响应中的 JSON 类型。 JS 客户端库主要保留这些库,但有一些例外情况:

  • Edm.DateTimeOffset 被转换为 JS Date。
  • Edm.GeographyPoint 被转换为 GeographyPoint 客户端库导出的类型。
  • 类型(NaN、Infinity、-Infinity)的number特殊值在REST API中序列化为字符串,但由客户端库转换回。number

注意:数据类型是根据值进行转换的,而不是索引架构中的字段类型。 这意味着,如果你有一个ISO8601日期字符串(例如“2020-03-06T18:48:27.896Z”)作为字段的值,它将转换为日期,而不考虑如何在架构中存储它。

例子

以下示例演示了基础知识 - 请 查看我们的示例 以了解更多信息。

下面的示例使用了稳定 2026-10-01 服务 API,这是客户端的默认设置。 它们扩展了现有的索引、索引器、知识源和检索工作流程,而无需另行开发一套客户端。

为了实现完整的可运行工作流, 示例源 还涵盖索引 SQL 内容列、私有摄取和服务选择分析器、内容理解图像描述模型和语义分块、服务/索引器运行时预算以及搜索自有的引用 URL。 可选的资源设置和先决条件列在 sample.env 中。

查找类似文档

与现有文档密钥搭配使用 moreLikeThis ,省略搜索文本。 明确选择顶层可搜索文本字段:复杂字段不支持此操作。 索引必须包含其他文档以返回有用的匹配。

import { SearchClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchClient("<endpoint>", "<indexName>", new DefaultAzureCredential());

const response = await client.search(undefined, {
  moreLikeThis: "1",
  searchFields: ["hotelName", "description"],
  select: ["hotelId", "hotelName"],
  top: 5,
});
for await (const result of response.results) {
  console.log(result.document);
}

配置知识库

使用配置语义搜索的填充知识源。 部署已配置的聊天模型,并在 Azure OpenAI 资源上将搜索服务的托管身份授予 Cognitive Services OpenAI 用户权限。 部署名称和模型名称是不同的设置;部署可以有自定义名称。 呼叫者需要 Search Service Contributor 来管理知识库。

存储的指令、输出模式和推理努力可以更新,而无需替换知识源。 answerSynthesis 使用配置好的模型; extractiveData 返回提取出来的内容而不合成答案。 GA推理模式为 minimal、 和 lowmedium。 显式请求意图绕过模型查询规划。

import { SearchIndexClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchIndexClient("<endpoint>", new DefaultAzureCredential());

const knowledgeBase = await client.createKnowledgeBase({
  name: "hotel-knowledge-base",
  knowledgeSources: [{ name: "<existingKnowledgeSourceName>" }],
  models: [
    {
      kind: "azureOpenAI",
      azureOpenAIParameters: {
        resourceUrl: "<azureOpenAIEndpoint>",
        deploymentId: "<chatDeploymentName>",
        modelName: "gpt-5.4-mini",
      },
    },
  ],
  retrievalReasoningEffort: { kind: "low" },
  outputMode: "answerSynthesis",
  retrievalInstructions: "Prioritize hotel amenities and pricing information.",
  answerInstructions: "Answer concisely and cite the supporting sources.",
});

knowledgeBase.outputMode = "extractiveData";
await client.createOrUpdateKnowledgeBase(knowledgeBase);

带有分页控件的资源列表

按名称前缀筛选初始列表,并让 SDK 跟随不透明的续写链接。 SearchIndexClient寻呼机显示 byPage()。 现有的同义词映射、索引器、数据源和技能集便利列表方法在收集完所有页面后仍返回数组;协议客户端会公开相应的分页操作。

import { SearchIndexClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchIndexClient("<endpoint>", new DefaultAzureCredential());

for await (const page of client
  .listIndexes({
    search: "hotel",
    searchType: "prefix",
    pageSize: 10,
  })
  .byPage()) {
  console.log(page.map((index) => index.name));
}

配置 SharePoint 文档权限

在创建索引之前,注册 SharePoint 连接器应用程序及其联合凭据。 applicationId federatedCredentialId并且需要一起使用;tenantId当它与搜索服务租户不同时,可以提供。 呼叫者需要 搜索服务贡献者。

组织范围的共享授权在权限字段中使用orgLink:<tenantId>userIds。 organizationAccessExpiration 标识其到期时间戳。 最多只有一个顶层 Edm.DateTimeOffset 字段能启用它。 该服务在权限过滤查询期间验证用户的租户和时间戳;仅声明这些字段并不授予访问权限。

import { SearchIndexClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchIndexClient("<endpoint>", new DefaultAzureCredential());

await client.createIndex({
  name: "sharepoint-permissions",
  permissionFilterOption: "enabled",
  sharePointConnectorAppRegistration: {
    applicationId: "<applicationId>",
    federatedCredentialId: "<federatedCredentialId>",
  },
  fields: [
    { name: "id", type: "Edm.String", key: true },
    { name: "content", type: "Edm.String", searchable: true },
    {
      name: "userIds",
      type: "Collection(Edm.String)",
      filterable: true,
      permissionFilter: "userIds",
    },
    {
      name: "organizationLinkExpiresAt",
      type: "Edm.DateTimeOffset",
      organizationAccessExpiration: true,
    },
  ],
});

索引 SharePoint 站点内容

GA SharePoint 作用域包括 AllSiteLists、 AllSitePages、 AllSiteContent和 ,以及现有的库作用域。 通过环境提供连接器 连接字符串,而不是在源代码中嵌入应用程序密钥。

import { SearchIndexClient, KnownIndexedSharePointContainerName } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchIndexClient("<endpoint>", new DefaultAzureCredential());
const connectionString = process.env.SHAREPOINT_CONNECTION_STRING;
if (!connectionString) {
  throw new Error("Set SHAREPOINT_CONNECTION_STRING before creating the knowledge source.");
}

await client.createKnowledgeSource({
  name: "sharepoint-site",
  kind: "indexedSharePoint",
  indexedSharePointParameters: {
    connectionString,
    containerName: KnownIndexedSharePointContainerName.AllSiteContent,
  },
});

刷新未更改的 ADLS Gen2 权限

对于已存在的 ADLS Gen2 索引器,如果它会摄取权限 refreshAllAcls ,即使文档内容未发生变化,也会刷新权限元数据。 它默认运行 true频率为 ,最多每 24 小时运行一次,且不重新处理内容或内容丰富。 设置为 false 禁用刷新功能。

import { SearchIndexerClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchIndexerClient("<endpoint>", new DefaultAzureCredential());
const indexer = await client.getIndexer("<existingAdlsGen2Indexer>");

indexer.parameters = {
  ...indexer.parameters,
  configuration: {
    ...indexer.parameters?.configuration,
    refreshAllAcls: true,
  },
};
await client.createOrUpdateIndexer(indexer);

从知识库检索

import {
  KnowledgeRetrievalClient,
  AzureKeyCredential,
  KnownKnowledgeRetrievalReasoningEffortKind,
} from "@azure/search-documents";

const client = new KnowledgeRetrievalClient(
  "<endpoint>",
  "<knowledgeBaseName>",
  new AzureKeyCredential("<apiKey>"),
);

const response = await client.retrieve({
  intents: [{ type: "semantic", search: "What information is available?" }],
  retrievalReasoningEffort: { kind: KnownKnowledgeRetrievalReasoningEffortKind.Low },
  includeActivity: true,
});

console.log(response.response);

流知识检索

类型迭代器使用一个 SSE 连接,处理帧和心跳,并在 或 error后response.completed停止。 完成报告可以报告完整(200)或部分206()结果。 打电话 controller.abort() 取消请求。 未知事件名称被忽略;令牌-delta 事件不属于此 API 的一部分。 有关活动相关性和取消处理,请参见流式样本。

import { KnowledgeRetrievalClient, AzureKeyCredential } from "@azure/search-documents";

const client = new KnowledgeRetrievalClient(
  "<endpoint>",
  "<knowledgeBaseName>",
  new AzureKeyCredential("<apiKey>"),
);

const controller = new AbortController();
for await (const event of await client.retrieveStream(
  {
    intents: [{ type: "semantic", search: "Summarize the indexed information." }],
    includeActivity: true,
  },
  { abortSignal: controller.signal },
)) {
  if (event.event === "activity.completed") {
    console.log(`Activity ${event.data.id} took ${event.data.elapsedInMs}ms`);
  } else if (event.event === "response.completed") {
    console.log(event.data.statusCode === 206 ? "Partial results" : "Complete results");
    console.log(event.data.response.response);
  } else if (event.event === "error") {
    throw new Error(event.data.error.message);
  }
}

上传和更新知识源文件

import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents";

const client = new SearchIndexClient("<endpoint>", new AzureKeyCredential("<apiKey>"));
const body = {
  metadata: { fileName: "manuals/example.txt", metadata: { category: "manual" } },
  content: {
    contents: new TextEncoder().encode("Azure AI Search retrieves relevant information."),
    contentType: "text/plain",
    filename: "example.txt",
  },
};

const uploaded = await client.uploadKnowledgeSourceFileMultipart("<knowledgeSourceName>", body);
if (!uploaded.fileId) {
  throw new Error("The service did not return an uploaded file ID.");
}

await client.updateKnowledgeSourceFile("<knowledgeSourceName>", uploaded.fileId, {
  ...body,
  metadata: { ...body.metadata, metadata: { category: "updated-manual" } },
});
for await (const file of client.listKnowledgeSourceFiles("<knowledgeSourceName>", {
  prefix: "manuals/",
  pageSize: 10,
})) {
  console.log(file.fileName, file.parsingMode, file.extractionMode);
}

检查文件知识源容量

文件知识源的状态显示 fileCapacity (KnowledgeSourceFileCapacity),显示剩余的文件数量和每个文件字节的限制。 上传前请先检查;其他类型的知识来源不会报告该字段。 直接上传需要 搜索服务贡献者,而搜索服务的托管身份则需要嵌入资源上的 认知服务OpenAI 用户 。

import { SearchIndexClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";

const client = new SearchIndexClient("<endpoint>", new DefaultAzureCredential());
const status = await client.getKnowledgeSourceStatus("<fileKnowledgeSourceName>");

if (!status.fileCapacity) {
  throw new Error("The knowledge source did not report File upload capacity.");
}
console.log(`Remaining files: ${status.fileCapacity.remainingFileCount}`);
console.log(`Maximum file size: ${status.fileCapacity.maxFileSizeBytes} bytes`);

创建索引

import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents";

const indexClient = new SearchIndexClient("<endpoint>", new AzureKeyCredential("<apiKey>"));

const result = await indexClient.createIndex({
  name: "example-index",
  fields: [
    {
      type: "Edm.String",
      name: "id",
      key: true,
    },
    {
      type: "Edm.Double",
      name: "awesomenessLevel",
      sortable: true,
      filterable: true,
      facetable: true,
    },
    {
      type: "Edm.String",
      name: "description",
      searchable: true,
    },
    {
      type: "Edm.ComplexType",
      name: "details",
      fields: [
        {
          type: "Collection(Edm.String)",
          name: "tags",
          searchable: true,
        },
      ],
    },
    {
      type: "Edm.Int32",
      name: "hiddenWeight",
      hidden: true,
    },
  ],
});

console.log(`Index created with name ${result.name}`);

从索引中检索特定文档

可以通过其主键值检索特定文档:

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const result = await searchClient.getDocument("1234");

将文档添加到索引中

可以将多个文档上传到批内的索引中:

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const uploadResult = await searchClient.uploadDocuments([
  // JSON objects matching the shape of the client's index
  {},
  {},
  {},
]);
for (const result of uploadResult.results) {
  console.log(`Uploaded ${result.key}; succeeded? ${result.succeeded}`);
}

对文档执行搜索

若要列出特定查询的所有结果,可以 search 与使用 简单查询语法的搜索字符串一起使用:

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const searchResults = await searchClient.search("wifi -luxury");
for await (const result of searchResults.results) {
  console.log(result);
}

对于使用 Lucene 语法的更高级搜索,请指定 queryType 为 full:

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const searchResults = await searchClient.search('Category:budget AND "recently renovated"^3', {
  queryType: "full",
  searchMode: "all",
});
for await (const result of searchResults.results) {
  console.log(result);
}

使用 TypeScript 进行查询

在 TypeScript 中, SearchClient 采用通用参数,即索引文档的模型形状。 这样,就可以对结果中返回的字段执行强类型查找。 TypeScript 还能够检查指定 select 参数时返回的字段。

import { SearchClient, AzureKeyCredential, SelectFields } from "@azure/search-documents";

// An example schema for documents in the index
interface Hotel {
  hotelId?: string;
  hotelName?: string | null;
  description?: string | null;
  descriptionVector?: Array<number>;
  parkingIncluded?: boolean | null;
  lastRenovationDate?: Date | null;
  rating?: number | null;
  rooms?: Array<{
    beds?: number | null;
    description?: string | null;
  }>;
}

const searchClient = new SearchClient<Hotel>(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const searchResults = await searchClient.search("wifi -luxury", {
  // Only fields in Hotel can be added to this array.
  // TS will complain if one is misspelled.
  select: ["hotelId", "hotelName", "rooms/beds"],
});

// These are other ways to declare the correct type for `select`.
const select = ["hotelId", "hotelName", "rooms/beds"] as const;
// This declaration lets you opt out of narrowing the TypeScript type of your documents,
// though the AI Search service will still only return these fields.
const selectWide: SelectFields<Hotel>[] = ["hotelId", "hotelName", "rooms/beds"];
// This is an invalid declaration. Passing this to `select` will result in a compiler error
// unless you opt out of including the model in the client constructor.
const selectInvalid = ["hotelId", "hotelName", "rooms/beds"];

for await (const result of searchResults.results) {
  // result.document has hotelId, hotelName, and rooms with only the beds property.
  // Trying to access result.document.description would emit a TS error.
  console.log(result.document.hotelName);
}

使用 OData 筛选器进行查询

使用 filter query 参数,可以使用 OData $filter 表达式的语法查询索引。

import { SearchClient, AzureKeyCredential, odata } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const baseRateMax = 200;
const ratingMin = 4;
const searchResults = await searchClient.search("WiFi", {
  filter: odata`Rooms/any(room: room/BaseRate lt ${baseRateMax}) and Rating ge ${ratingMin}`,
  orderBy: ["Rating desc"],
  select: ["hotelId", "hotelName", "Rating"],
});
for await (const result of searchResults.results) {
  // Each result will have "HotelId", "HotelName", and "Rating"
  // in addition to the standard search result property "score"
  console.log(result);
}

使用矢量进行查询

可以使用搜索参数查询 vector 文本嵌入。 有关详细信息,请参阅查询向量和筛选向量查询。

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const queryVector: number[] = [
  // Embedding of the query "What are the most luxurious hotels?"
];
const searchResults = await searchClient.search("*", {
  vectorSearchOptions: {
    queries: [
      {
        kind: "vector",
        vector: queryVector,
        fields: ["descriptionVector"],
        kNearestNeighborsCount: 3,
      },
    ],
  },
});
for await (const result of searchResults.results) {
  // These results are the nearest neighbors to the query vector
  console.log(result);
}

使用分面进行查询

facets 用于帮助您的应用程序用户根据预设的维度细化搜索。 Facet 语法 提供了对 facet 值进行排序和分类的选项。

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const searchClient = new SearchClient(
  "<endpoint>",
  "<indexName>",
  new AzureKeyCredential("<apiKey>"),
);

const searchResults = await searchClient.search("WiFi", {
  facets: ["category,count:3,sort:count", "rooms/baseRate,interval:100"],
});
console.log(searchResults.facets);

检索结果时,将提供一个 facets 属性,该属性将指示落入每个分面存储桶的结果数。 这可用于推动细化(例如,发出后续搜索, Rating 过滤大于或等于 3 且小于 4。

故障 排除

伐木

启用日志记录有助于发现有关故障的有用信息。 若要查看 HTTP 请求和响应的日志,请将 AZURE_LOG_LEVEL 环境变量设置为 info。 或者,可以通过在 setLogLevel中调用 @azure/logger 在运行时启用日志记录:

import { setLogLevel } from "@azure/logger";

setLogLevel("info");

有关如何启用日志的更详细说明,可以查看 @azure/记录器包文档。

后续步骤

贡献

若要参与此库,请阅读 参与指南 ,详细了解如何生成和测试代码。

此项目欢迎贡献和建议。 大多数贡献要求你同意参与者许可协议(CLA),声明你有权(实际这样做)授予我们使用你的贡献的权利。 有关详细信息,请访问 cla.microsoft.com。

该项目已采用 Microsoft开源行为准则。 有关详细信息,请参阅 行为准则常见问题解答 或与 opencode@microsoft.com 联系,了解任何其他问题或意见。