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

Azure 认知搜索是用于在自定义应用中插入搜索体验的独立资源。Azure Cognitive Search is a standalone resource used to plug a search experience into custom apps. 认知搜索可与其他 Azure 服务、网络服务器上的应用或其他云平台上运行的软件轻松集成。Cognitive Search integrates easily with other Azure services, 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.

开始之前Before you start

以下服务属性在服务生存期内是固定的,更改任何属性都需要新的服务。The following service properties are fixed for the lifetime of the service - changing any of them requires a new service. 因为它们是固定的,所以在填写每个属性时,请考虑以下与用法相关的注意事项:Because they are fixed, consider the usage implications as you fill in each property:

  • 服务名称变为 URL 终结点的一部分(查看提示,了解有用的服务名称)。Service name becomes part of the URL endpoint (review tips for helpful service names).
  • 服务层会影响计费,应设置容量上限。Service tier affects billing and sets an upward limit on capacity. 某些功能在免费层上不可用。Some features are not available on the free tier.
  • 服务区域可能决定某些方案的可用性。Service region can determine the availability of certain scenarios. 如果需要高安全性功能AI 扩充,则需要将 Azure 认知搜索放置在与其他服务相同的区域中,或放置在提供相关功能的区域中。If you need high security features or AI enrichment, you will need to place Azure Cognitive Search in the same region as other services, or in regions that provide the feature in question.

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

打开试用版 Azure 帐户并使用免费额度试用付费 Azure 服务。Open a trial Azure account and use free credits to try out paid Azure services.

或者,通过 Azure 预付购买模式注册付费版 Azure 服务。Alternatively, sign up Azure Pay-in-Advance purchase 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. 如果要实现双重加密或依赖于托管服务标识的其他功能,请选择与用于 Azure Key Vault 或对其使用托管标识的其他服务相同的订阅。If you are implementing double encryption or other features that depend on managed service identities, choose the same subscription as the one used for Azure Key Vault or other services for which managed identities are used.

设置资源组Set a resource group

资源组是用于保存 Azure 解决方案相关资源的容器。A resource group is a container that holds related resources for your Azure solution. 它对于搜索服务而言是必需的。It is required for the search service. 它还可用于统一管理资源(包括成本)。It is also 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 or you can view charges for individual resources. 以下屏幕截图显示了在将多个资源合并到一个组时,可以看到的成本信息的种类。The following screenshot shows the kind of cost information you can 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 deletes all of 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.azure.cnThe name is part of the URL endpoint against which API calls are issued: https://your-service-name.search.azure.cn. 例如,如果希望终结点为 https://myservice.search.azure.cn,则输入 myserviceFor example, if you want the endpoint to be https://myservice.search.azure.cn, you would enter myservice.

服务名称要求:Service name requirements:

  • 它必须在 search.azure.cn 命名空间中唯一It must be unique within the search.azure.cn namespace
  • 它的长度必须为 2 到 60 个字符。It must be between 2 and 60 characters in length
  • 必须使用小写字母、数字或短划线(“-”)You must use lowercase letters, digits, or dashes ("-")
  • 前 2 个字符或最后一个字符不能为短划线(“-”)Do not use dashes ("-") in the first 2 characters or as the last single character
  • 不能在任何位置使用连续的短划线(“--”)You may not use 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 认知搜索位于中国东部 2 区域,而你在中国东部 2 区域还有其他服务,则在决定如何合并或附加资源时,使用类似于 mysearchservice-chinaeast2 的名称就无需导航到属性页。Services within the same region can exchange data at no charge, so if Azure Cognitive Search is in China East 2, and you have other services also in China East 2, a name like mysearchservice-chinaeast2 can save you a trip to the properties page when deciding how to combine or attach resources.

选择位置Choose a location

Azure 认知搜索在大多数区域中可用。Azure Cognitive Search is available in most regions. 支持的区域列表可在定价页中找到。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).

要求Requirements

如果使用 AI 扩充,请在认知服务所在的相同区域中创建搜索服务。If you are using AI enrichment, create your search 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.

具有业务连续性和灾难恢复 (BCDR) 要求的客户应在区域对中创建其服务。Customers with business continuity and disaster recovery (BCDR) requirements should create their services in regional pairs. 例如,如果在上海操作,可以为每个服务选择中国东部和中国东部 2。For example, if you are operating in Shanghai, you might choose China East and China East 2 for each service.

建议Recommendations

如果使用多个 Azure 服务,请选择同时托管数据或应用程序服务的区域。If you are using multiple Azure services, choose a region that is also hosting your data or application service. 这样做可以最大程度地减少或避免出站数据的带宽费用(当服务位于同一区域时,出站数据没有任何费用)。Doing so minimizes or voids bandwidth charges for outbound data (there are no charges for outbound data when services are in the same region).

选择定价层 (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 are partition size and speed, and limits on the number of objects you can create.

请记住,创建服务后无法更改定价层。Remember, a pricing tier cannot be changed once the service is created. 如果需要更高或较低的层,必须重新创建该服务。If you need a higher or lower tier, you will 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

服务在几分钟内即可部署。Your service is deployed within minutes. 可以通过 Azure 通知监视进度。You can monitor progress 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:

备注

在 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.