教程:创建和发布产品Tutorial: Create and publish a product

在 Azure API 管理中,一个产品包含一个或多个 API 以及使用配额和使用条款。In Azure API Management, a product contains one or more APIs as well as a usage quota and the terms of use. 一旦产品发布,开发人员可以订阅该产品,并开始使用产品的 API。Once a product is published, developers can subscribe to the product and begin to use the product's APIs.

在本教程中,你将了解如何执行以下操作:In this tutorial, you learn how to:

  • 创建和发布产品Create and publish a product
  • 将 API 添加到产品Add an API to the product

门户中的 API 管理产品

先决条件Prerequisites

创建和发布产品Create and publish a product

  1. 登录到 Azure 门户,并导航到 API 管理实例。Sign in to the Azure portal, and navigate to your API Management instance.

  2. 在左侧导航栏中,选择“产品” > “+ 添加” 。In the left navigation, select Products > + Add.

  3. 在“添加产品”窗口中,输入下表中描述的值以创建产品。In the Add product window, enter values described in the following table to create your product.

    在门户中添加产品

    名称Name 说明Description
    显示名称Display name 要在开发人员门户中显示的名称。The name as you want it to be shown in the developer portal.
    说明Description 提供有关该产品的信息,如其用途、它提供访问权的 API 和其他详细信息。Provide information about the product such as its purpose, the APIs it provides access to, and other details.
    州省/自治区/直辖市State 如果希望发布该产品,请选择“发布”。Select Published if you want to publish the product. 在产品中的 API 可调用前,必须先发布该产品。Before the APIs in a product can be called, the product must be published. 默认情况下新产品未发布,并仅对“管理员”组可见。By default, new products are unpublished, and are visible only to the Administrators group.
    需要订阅Requires subscription 如果需要用户订阅才能使用该产品,请选中该项。Select if a user is required to subscribe to use the product.
    需要批准Requires approval 如果希望管理员审查并接受或拒绝此产品的订阅尝试,请选中该项。Select if you want an administrator to review and accept or reject subscription attempts to this product. 如果未选中此项,则会自动批准订阅尝试。If not selected, subscription attempts are auto-approved.
    订阅计数限制Subscription count limit (可选)限制多个同步订阅的计数。Optionally limit the count of multiple simultaneous subscriptions.
    法律条款Legal terms 可以包含产品的使用条款,订阅者必须接受这些条款才能使用该产品。You can include the terms of use for the product which subscribers must accept in order to use the product.
    APIAPIs 选择一个或多个 API。Select one or more APIs. 还可以在创建产品后添加 API。You can also add APIs after creating the product. 有关详细信息,请参阅本文稍后的将 API 添加到产品For more information, see Add APIs to a product later in this article.
  4. 选择“创建”以创建新产品。Select Create to create the new product.

添加更多配置Add more configurations

保存产品后继续对其进行配置。Continue configuring the product after saving it. 在 API 管理实例中,从“产品”窗口中选择产品。In your API Management instance, select the product from the Products window. 添加或更新:Add or update:

Item 说明Description
设置Settings 产品元数据和状态Product metadata and state
APIAPIs 与产品关联的 APIAPIs associated with the product
策略Policies 应用于产品 API 的策略Policies applied to product APIs
访问控制Access control 对开发人员或来宾可见的产品Product visibility for developers or guests
订阅Subscriptions 产品订阅者Product subscribers

将 API 添加到产品Add APIs to a product

产品是一个或多个 API 的关联。Products are associations of one or more APIs. 可以包含多个 API,并通过开发人员门户将其提供给开发人员。You can include a number of APIs and offer them to developers through the developer portal. 可以在创建产品期间添加一个或多个现有的 API。During the product creation, you can add one or more existing APIs. 之后,也可以通过产品的“设置”页或在创建 API 时将 API 添加到产品。You can also add APIs to the product later, either from the Products Settings page or while creating an API.

开发人员必须先订阅产品才能访问 API。Developers must first subscribe to a product to get access to the API. 订阅时,他们会得到一个订阅密钥,此密钥对该产品中的任何 API 都有效。When they subscribe, they get a subscription key that is good for any API in that product. 如果创建了 APIM 实例,那么你已是管理员,因此默认情况下订阅了每个产品。If you created the APIM instance, you are an administrator already, so you are subscribed to every product by default.

将 API 添加到现有产品Add an API to an existing product

  1. 在 API 管理实例的左侧导航栏中,选择“产品”。In the left navigation of your API Management instance, select Products.
  2. 选择一个产品,然后选择“API”。Select a product, then select APIs.
  3. 选择“+ 添加” 。Select + Add.
  4. 选择一个或多个 API,然后点击“选择”。Select one or more APIs and then Select.

将 API 添加到现有产品

提示

可以通过 REST API 或 PowerShell 命令使用自定义订阅密钥来创建或更新用户对产品的订阅。You can create or update a user's subscription to a product with custom subscription keys through a REST API or PowerShell command.

后续步骤Next steps

在本教程中,你将了解:In this tutorial, you learned how to:

  • 创建和发布产品Create and publish a product
  • 将 API 添加到产品Add an API to the product

转到下一教程:Advance to the next tutorial: