您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

快速入门:在门户中创建 Azure 认知搜索服务Quickstart: Create an Azure Cognitive Search service in the portal

Azure 认知搜索是用于在自定义应用中插入搜索体验的独立资源。Azure Cognitive Search is a standalone resource used to plug in a search experience in custom apps. 虽然 Azure 认知搜索可以与其他 Azure 服务轻松集成,但它也可以作为单独的组件使用,或与网络服务器上的应用或在其他云平台上运行的软件集成。Although Azure Cognitive Search integrates easily with other Azure services, you can also use it as a standalone component, or integrate it with apps on network servers, or with software running on other cloud platforms.

本文介绍如何在 Azure 门户中创建资源。In this article, learn how to create a resource in the Azure portal.

动画 GIFAnimated GIF

更喜欢 PowerShell?Prefer PowerShell? 使用 Azure 资源管理器服务模板Use the Azure Resource Manager service template. 有关如何入门的帮助,请参阅使用 PowerShell 管理 Azure 认知搜索For help with getting started, see Manage Azure Cognitive Search with PowerShell.

订阅(免费或付费)Subscribe (free or paid)

打开免费的 Azure 帐户并使用免费信用额度试用付费 Azure 服务。Open a free Azure account and use free credits to try out paid Azure services. 信用额度用完后,请保留帐户并继续使用免费的 Azure 服务,如网站。After credits are used up, keep the account and continue to use free Azure services, such as Websites. 除非显式更改设置并要求付费,否则不会对信用卡收取任何费用。Your credit card is never charged unless you explicitly change your settings and ask to be charged.

还可以激活 MSDN 订户权益Alternatively, activate MSDN subscriber benefits. MSDN 订阅每月提供可用来试用付费版 Azure 服务的信用额度。An MSDN subscription gives you credits every month you can use for paid Azure services.

  1. 登录到 Azure 门户Sign in to the Azure portal.
  2. 单击左上角的加号(“+ 创建资源”)。Click the plus sign ("+ Create Resource") in the top-left corner.
  3. 使用搜索栏查找“Azure 认知搜索”,或通过“Web” > “Azure 认知搜索”导航到资源 。Use the search bar to find "Azure Cognitive Search" or navigate to the resource through Web > Azure Cognitive Search.

在门户中创建资源Create a resource in the portal

选择订阅Choose a subscription

如果有多个订阅,请选择一个用于搜索服务。If you have more than one subscription, choose one for your search service.

设置资源组Set a resource group

资源组是必需的,它用于全方面地管理所有资源,包括成本。A resource group is required and is useful for managing resources all-up, including costs. 一个资源组可以包含一个服务,也可以包含同时使用的多个服务。A resource group can consist of one service, or multiple services used together. 例如,如果使用 Azure 认知搜索为 Azure Cosmos DB 数据库编制索引,则可以将这两个服务纳入同一个资源组进行管理。For example, if you are using Azure Cognitive Search to index an Azure Cosmos DB database, you could make both services part of the same resource group for management purposes.

若不将资源合并到单个组中,或现有资源组中包含的资源用于不相关的解决方案,请新建一个仅用于 Azure 认知搜索资源的资源组。If you aren't combining resources into a single group, or if existing resource groups are filled with resources used in unrelated solutions, create a new resource group just for your Azure Cognitive Search resource.

创建新的资源组Create a new resource group

经过一段时间以后,可以跟踪当前成本和预计的汇总成本(如屏幕截图中所示),或者向下滚动以查看各个资源的费用。Over time, you can track current and projected costs all-up (as shown in the screenshot) or scroll down to view charges for individual resources. 以下屏幕截图显示了在将多个资源合并到一个组时,最终可以看到的成本信息的种类。The following screenshot shows the kind of cost information you can eventually expect to see when you combine multiple resources into one group.

在资源组级别管理成本Manage costs at the resource group level


资源组可以简化清理,因为删除组也会删除其中的服务。Resource groups simplify cleanup because deleting a group also deletes the services within it. 对于使用多个服务项目的原型,将它们放在同一资源组中可在项目结束后更加轻松地进行清理。For prototype projects utilizing multiple services, putting all of them in the same resource group makes cleanup easier after the project is over.

为服务命名Name the service

在“实例详细信息”中的“URL”字段内提供服务名称。 In Instance Details, provide a service name in the URL field. 该名称是 URL 终结点的一部分,API 调用针对此终结点发出:https://your-service-name.search.windows.netThe name is part of the URL endpoint against which API calls are issued: https://your-service-name.search.windows.net. 例如,如果希望终结点为 https://myservice.search.windows.net,则输入 myserviceFor example, if you want the endpoint to be https://myservice.search.windows.net, you would enter myservice.

服务名称要求:Service name requirements:

  • 它必须在 search.windows.net 命名空间中唯一It must be unique within the search.windows.net namespace
  • 2 到 60 个字符长度2 and 60 characters in length
  • 使用小写字母、数字或短划线(“-”)Use lowercase letters, digits, or dashes ("-")
  • 前两个字符或最后一个字符不能为短划线(“-”)Avoid dashes ("-") in the first 2 characters or as the last single character
  • 任何位置都不能有连续的短划线(“--”)No consecutive dashes ("--") anywhere


如果你认为今后会用到多个服务,我们建议根据命名约定在服务名称中包含区域(或位置)。If you think you'll be using multiple services, we recommend including the region (or location) in the service name as a naming convention. 同一区域中的服务可以免费交换数据,因此,如果 Azure 认知搜索位于美国西部,而你在美国西部还有其他服务,则在决定如何合并或附加资源时,使用类似于 mysearchservice-westus 的名称就无需导航到属性页。Services within the same region can exchange data at no charge, so if Azure Cognitive Search is in West US, and you have other services also in West US, a name like mysearchservice-westus can save you a trip to the properties page when deciding how to combine or attach resources.

选择位置Choose a location

作为 Azure 服务,Azure 认知搜索可托管在世界各地的数据中心中。As an Azure service, Azure Cognitive Search can be hosted in datacenters around the world. 支持的区域列表可在定价页中找到。The list of supported regions can be found in the pricing page.

为多个服务选择同一位置可以最大程度地减少或避免带宽费用。You can minimize or avoid bandwidth charges by choosing the same location for multiple services. 例如,在为另一 Azure 服务(Azure 存储、Azure Cosmos DB、Azure SQL 数据库)提供的数据编制索引时,在同一区域中创建 Azure 认知搜索服务可以避免带宽费用(当服务位于同一区域时,出站数据不会产生费用)。For example, if you are indexing data provided by another Azure service (Azure storage, Azure Cosmos DB, Azure SQL Database), creating your Azure Cognitive Search service in the same region avoids bandwidth charges (there are no charges for outbound data when services are in the same region).

此外,如果你使用的是 AI 扩充,请在认知服务所在的相同区域中创建你的服务。Additionally, if you are using AI enrichment, create your service in the same region as Cognitive Services. 将 Azure 认知搜索和认知服务归置在同一区域中是 AI 扩充的必要条件Co-location of Azure Cognitive Search and Cognitive Services in the same region is a requirement for AI enrichment.


印度中部目前无法提供新服务。Central India is currently unavailable for new services. 对于已在印度中部的服务,你可以无限制地纵向扩展,并且你的服务在该区域是完全受支持的。For services already in Central India, you can scale up with no restrictions, and your service is fully supported in that region. 对此区域的限制是临时的,仅限于新服务。The restriction on this region is temporary and limited to new services only. 如果该限制不再适用,我们将删除此说明。We will remove this note when the restriction no longer applies.

选择定价层 (SKU)Choose a pricing tier (SKU)

Azure 认知搜索当前以多个定价层提供:免费、基本或标准。Azure Cognitive Search is currently offered in multiple pricing tiers: Free, Basic, or Standard. 每个层都有自己的容量和限制Each tier has its own capacity and limits. 有关相关指南,请参阅选择定价层或 SKUSee Choose a pricing tier or SKU for guidance.

“基本”和“标准”是生产工作负荷的最常用选项,但大多数客户会从“免费”服务开始。Basic and Standard are the most common choices for production workloads, but most customers start with the Free service. 各个层之间的主要差别在于分区大小和速度,以及可创建的对象数限制。Key differences among tiers is partition size and speed, and limits on the number of objects you can create.

请记住,创建服务后无法更改定价层。Remember that a pricing tier cannot be changed once the service is created. 如果以后需要更高或较低的层,则需要重新创建该服务。If you need a higher or lower tier later, you have to re-create the service.

创建服务Create your service

提供所需的输入后,继续创建服务。After you've provided the necessary inputs, go ahead and create the service.

查看并创建服务Review and create the service

服务将在几分钟内部署,你可以通过 Azure 通知对其进行监视。Your service is deployed within minutes, which you can monitor through Azure notifications. 考虑将该服务固定到仪表板,以方便将来访问。Consider pinning the service to your dashboard for easy access in the future.

监视和固定服务Monitor and pin the service

获取密钥和 URL 终结点。Get a key and URL endpoint

除非使用门户访问新服务,否则以编程方式访问新服务需要提供 URL 终结点和身份验证 API 密钥。Unless you are using the portal, programmatic access to your new service requires that you provide the URL endpoint and an authentication api-key.

  1. 在“概览” 页的右侧找到并复制 URL 终结点。On the Overview page, locate and copy the URL endpoint on the right side of the page.

  2. 在“密钥” 页上,复制其中一个管理密钥(它们等同)。On the Keys page, copy either one of the admin keys (they are equivalent). 在服务上创建、更新和删除对象需要管理员 API 密钥。Admin api-keys are required for creating, updating, and deleting objects on your service. 相反,查询键提供索引内容的读取访问权限。In contrast, query keys provide read-access to index content.

    包含 URL 终结点的服务概览页Service overview page with URL endpoint

基于门户的任务不需终结点和密钥。An endpoint and key are not needed for portal-based tasks. 门户已链接到具有管理员权限的 Azure 认知搜索资源。The portal is already linked to your Azure Cognitive Search resource with admin rights. 有关门户演练,请从快速入门:在门户中创建 Azure 认知搜索索引For a portal walkthrough, start with Quickstart: Create an Azure Cognitive Search index in the portal.

扩展服务Scale your service

预配服务后,可以对其进行扩展以满足需求。After your service is provisioned, you can scale it to meet your needs. 如果为 Azure 认知搜索服务选择了“标准”层,则可以采用两个维度扩展服务:副本和分区。If you chose the Standard tier for your Azure Cognitive Search service, you can scale your service in two dimensions: replicas and partitions. 如果已选择基本层,仅可以添加副本。Had you chosen the Basic tier, you can only add replicas. 如果预配了免费服务,则扩展不可用。If you provisioned the free service, scale is not available.

分区允许服务存储和搜索更多文档。Partitions allow your service to store and search through more documents.

副本允许服务处理负载更高的搜索查询。Replicas allow your service to handle a higher load of search queries.

添加资源会增加每月账单费用。Adding resources increases your monthly bill. 可以通过定价计算器来了解添加资源对账单明细的影响。The pricing calculator can help you understand the billing ramifications of adding resources. 请记住,可以根据负载来调整资源。Remember that you can adjust resources based on load. 例如,可以通过增加资源来创建完整的初始索引,在以后再将资源减少到与增量索引编制相适应的某个程度。For example, you might increase resources to create a full initial index, and then reduce resources later to a level more appropriate for incremental indexing.

  1. 在 Azure 门户中转到“搜索服务”页。Go to your search service page in the Azure portal.
  2. 在左侧导航窗格中,选择“设置” > “缩放” 。In the left-navigation pane, select Settings > Scale.
  3. 使用滑块添加任一类型的资源。Use the slidebar to add resources of either type.

添加容量Add capacity


所在的层级越高,每个分区的存储大小和速度就越高。Per-partition storage and speed increases at higher tiers. 有关详细信息,请参阅容量和限制For more information, see capacity and limits.

何时添加第二个服务When to add a second service

大多数客户只使用定价层上预配的一个服务,以提供适当的资源平衡Most customers use just one service provisioned at a tier providing the right balance of resources. 一个服务可以托管多个索引(但受制于所选层的最大限制),各索引之间相互隔离。One service can host multiple indexes, subject to the maximum limits of the tier you select, with each index isolated from another. 在 Azure 认知搜索中,请求只能定向到一个索引,从而将从同一服务中的其他索引意外或故意检索数据的可能性降至最低。In Azure Cognitive Search, requests can only be directed to one index, minimizing the chance of accidental or intentional data retrieval from other indexes in the same service.

尽管大多数客户只使用一个服务,但若有以下操作要求,则可能需要提供服务冗余:Although most customers use just one service, service redundancy might be necessary if operational requirements include the following:

  • 灾难恢复(数据中心服务中断)。Disaster recovery (data center outage). Azure 认知搜索在发生服务中断时不提供即时故障转移。Azure Cognitive Search does not provide instant failover in the event of an outage. 请参阅服务管理获取相关建议和指南。For recommendations and guidance, see Service administration.
  • 通过调查多租户建模,确定附加服务是最佳设计。Your investigation of multi-tenancy modeling has determined that additional services is the optimal design. 有关详细信息,请参阅多租户设计For more information, see Design for multi-tenancy.
  • 对于在全球部署的应用程序,可能需要在多个区域运行 Azure 认知搜索实例,以尽量减少应用程序国际流量的延迟。For globally deployed applications, you might require an instance of Azure Cognitive Search in multiple regions to minimize latency of your application’s international traffic.


在 Azure 认知搜索中,无法分离索引操作和查询操作;因此永远无需为分离的工作负荷创建多个服务。In Azure Cognitive Search, you cannot segregate indexing and querying operations; thus, you would never create multiple services for segregated workloads. 查询索引时,始终是在创建该索引时所在的服务中查询(不能在一个服务中创建索引,然后将其复制到另一个服务)。An index is always queried on the service in which it was created (you cannot create an index in one service and copy it to another).

无需为实现高可用性添加第二个服务。A second service is not required for high availability. 在同一服务中使用 2 个或更多个副本,便可实现查询的高可用性。High availability for queries is achieved when you use 2 or more replicas in the same service. 副本更新是连续的,这意味着当服务更新推出时,至少有一个副本能正常工作。有关运行时间的详细信息,请参阅服务级别协议Replica updates are sequential, which means at least one is operational when a service update is rolled out. For more information about uptime, see Service Level Agreements.

后续步骤Next steps

预配服务后,可以继续在门户中创建第一个索引。After provisioning a service, you can continue in the portal to create your first index.