使用创作和运行时资源密钥Using authoring and runtime resource keys

创作和运行时资源为 LUIS 应用和预测终结点提供身份验证。Authoring and runtime resources provide authentication to your LUIS app and prediction endpoint.

登录 LUIS 门户时,可以选择使用以下项继续操作:When you sign in to the LUIS portal, you can choose to continue with:

  • 免费的试用密钥 - 提供创作和一些预测终结点查询。a free trial key - providing authoring and a few prediction endpoint queries.
  • 新的 Azure LUIS 创作资源 - 创建新的资源。a new Azure LUIS authoring resource - create a new resource. 这不同于预测终结点资源。This is not the same as a prediction endpoint resource.

登录 LUIS 门户并开始创作Sign in to LUIS portal and begin authoring

  1. 登录 LUIS 门户并同意使用条款。Sign in to LUIS portal and agree to the terms of use.

  2. 开始使用 LUIS 应用时,请选择要使用的 LUIS 创作密钥的类型:免费试用密钥或新的 Azure LUIS 创作密钥。Begin your LUIS app by choosing which type of LUIS authoring key you would like to use: free trial key, or new Azure LUIS authoring key.

    选择语言理解创作资源的类型

试用密钥Trial key

试用(初学者)密钥是为你提供的。The trial (starter) key is provided for you. 它用作身份验证密钥,用来查询预测终结点运行时,每月最多可以进行 1000 次查询。It is used as your authentication key to query the prediction endpoint runtime, up to 1000 queries a month.

它在 LUIS 门户中的“用户设置”页和“管理 -> Azure 资源”页上均可见。 It is visible on both the User Settings page and the Manage -> Azure resources pages in the LUIS portal.

准备好发布预测终结点后,请创建并分配创作密钥和预测运行时密钥,替换初学者密钥功能。When you are ready to publish your prediction endpoint, create and assign authoring and prediction runtime keys, to replace the starter key functionality.

在 Azure 门户中创建资源Create resources in the Azure portal

  1. 使用此链接打开 Azure 门户以创建资源。Use this link to open the Azure portal at for resource creation.

  2. 选择“两者”,以便创建创作密钥和预测终结点运行时密钥。 Select Both to create an authoring and a prediction endpoint runtime key.

  3. 输入创建资源所需的信息,然后选择“创建”以完成此过程。 Enter the information required to create the resource then select Create to finish the process.

    创建语言理解资源

    名称Name 目的Purpose
    资源名称Resource name 你选择的自定义名称,用作创作和预测终结点查询的 URL 的一部分。A custom name you choose, used as part of the URL for your authoring and prediction endpoint queries.
    订阅名称Subscription name 将对其收取资源费用的订阅。the subscription that will be billed for the resource.
    资源组Resource group 你选择或创建的自定义资源组名称。A custom resource group name you choose or create. 可以使用资源组将 Azure 资源分组,以便在同一区域进行访问和管理。Resource groups allow you to group Azure resources for access and management in the same region.
    创作位置Authoring location 与模型关联的区域。The region associated with your model.
    创作定价层Authoring pricing tier 定价层决定了每秒和每月的最大事务数。The pricing tier determines the maximum transaction per second and month.
    运行时位置Runtime location 与发布的预测终结点运行时相关联的区域。The region associated with your published prediction endpoint runtime.
    运行时定价层Runtime pricing tier 定价层决定了每秒和每月的最大事务数。The pricing tier determines the maximum transaction per second and month.

    创建这两项资源后,请在 LUIS 门户中分配资源。Once both resources are created, assign the resources in the LUIS portal.

在 Azure CLI 中创建资源Create resources in Azure CLI

使用 Azure CLI 单独创建每项资源。Use the Azure CLI to create each resource individually.

资源 kindResource kind:

  • 创作:LUIS.AuthoringAuthoring: LUIS.Authoring
  • 预测:LUISPrediction: LUIS
  1. 登录 Azure CLI:Sign in to the Azure CLI:

    az cloud set -n AzureChinaCloud
    az login
    

    此时会打开一个浏览器,让你可以选择正确的帐户并提供身份验证。This opens a browser to allow you to select the correct account and provide authentication.

  2. 在名为 my-resource-group 的现有资源组中为 China East 区域创建一个类型为 LUIS.Authoring、名称为 my-luis-authoring-resourceLUIS 创作资源Create a LUIS authoring resource, of kind LUIS.Authoring, named my-luis-authoring-resource in the existing resource group named my-resource-group for the China East region.

    az cognitiveservices account create -n my-luis-authoring-resource -g my-resource-group --kind LUIS.Authoring --sku F0 -l chinaeast --yes
    
  3. 在名为 my-resource-group 的现有资源组中为 chinaeast 区域创建一个类型为 LUIS、名称为 my-luis-prediction-resourceLUIS 预测终结点资源Create a LUIS prediction endpoint resource, of kind LUIS, named my-luis-prediction-resource in the existing resource group named my-resource-group for the chinaeast region. 如果需要比免费层更高的吞吐量,请将 F0 更改为 S0If you want a higher throughput than the free tier, change F0 to S0. 详细了解定价层和吞吐量Learn more about pricing tiers and throughput.

    az cognitiveservices account create -n my-luis-prediction-resource -g my-resource-group --kind LUIS --sku F0 -l chinaeast --yes
    

    Note

    在 LUIS 门户的“管理 -> Azure 资源”上分配此密钥之前,该门户不能使用此密钥。 This keys are not used by the LUIS portal until they are assigned in the LUIS portal on the Manage -> Azure resources.

在 LUIS 门户中为所有应用分配创作资源Assign an authoring resource in the LUIS portal for all apps

可以在 LUIS 中为单个应用或所有应用分配创作资源。You can assign an authoring resource for a single app or for all apps in LUIS. 以下过程将所有应用分配给单个创作资源。The following procedure assigns all apps to a single authoring resource.

  1. 登录到 LUIS 门户Sign in to the LUIS portal.
  2. 在右上角的导航栏中选择用户帐户,然后选择“设置”。 At the top navigation bar, to the far right, select your user account, then select Settings.
  3. 在“用户设置”页上选择“添加创作资源”,然后选择现有的创作资源。 On the User Settings page, select Add authoring resource then select an existing authoring resource. 选择“保存” 。Select Save.

将资源分配给应用Assign a resource to an app

可以通过以下过程将单个资源、创作或预测终结点运行时分配给应用。You can assign a single resource, authoring or prediction endpoint runtime, to an app with the following procedure.

  1. 登录 LUIS 门户,然后从“我的应用”列表中选择一个应用。 Sign in to the LUIS portal, then select an app from the My apps list.

  2. 导航到“管理 -> Azure 资源”页。 Navigate to the Manage -> Azure resources page.

    在 LUIS 门户中选择“管理 -> Azure 资源”,以便为应用分配资源。

  3. 选择“预测或创作资源”选项卡,然后选择“添加预测资源”或“添加创作资源”按钮。 Select the Prediction or Authoring resource tab then select the Add prediction resource or Add authoring resource button.

  4. 选择窗体中的字段以查找正确的资源,然后选择“保存”。 Select the fields in the form to find the correct resource, then select Save.

在不使用 LUIS 门户的情况下分配运行时资源Assign runtime resource without using LUIS portal

出于 CI/CD 管道等自动化目的,可能需要将 LUIS 运行时资源自动分配给 LUIS 应用。For automation purposes such as a CI/CD pipeline, you may want to automate the assignment of a LUIS runtime resource to a LUIS app. 为此,需要执行以下步骤:In order to do that, you need to perform the following steps:

  1. 从此网站获取 Azure 资源管理器令牌。Get an Azure Resource Manager token from this website. 此令牌即将过期,请立即使用。This token does expire so use it immediately. 该请求将返回 Azure 资源管理器令牌。The request returns an Azure Resource Manager token.

    请求 Azure 资源管理器令牌和接收 Azure 资源管理器令牌

  2. 使用该令牌从用户帐户有权访问的获取 LUIS azure 帐户 API 跨订阅请求 LUIS 运行时资源。Use the token to request the LUIS runtime resources across subscriptions, from the Get LUIS azure accounts API, which your user account has access to.

    此 POST API 需要以下设置:This POST API requires the following settings:

    标头Header ValueValue
    Authorization Authorization 的值为 Bearer {token}The value of Authorization is Bearer {token}. 请注意,单词 Bearer 和空格前面必须是令牌值。Notice that the token value must be preceded by the word Bearer and a space.
    Ocp-Apim-Subscription-Key 你的创作密钥。Your authoring key.

    此 API 将返回 LUIS 订阅的 JSON 对象的数组,包括订阅 ID、资源组和资源名称(作为帐户名称返回)。This API returns an array of JSON objects of your LUIS subscriptions including subscription ID, resource group, and resource name, returned as account name. 在要将 LUIS 资源分配给 LUIS 应用的数组中查找一个项。Find the one item in the array that is the LUIS resource to assign to the LUIS app.

  3. 使用将 LUIS azure 帐户分配给应用程序 API,将令牌分配给 LUIS 资源。Assign the token to the LUIS resource with the Assign a LUIS azure accounts to an application API.

    此 POST API 需要以下设置:This POST API requires the following settings:

    类型Type 设置Setting ValueValue
    标头Header Authorization Authorization 的值为 Bearer {token}The value of Authorization is Bearer {token}. 请注意,单词 Bearer 和空格前面必须是令牌值。Notice that the token value must be preceded by the word Bearer and a space.
    标头Header Ocp-Apim-Subscription-Key 你的创作密钥。Your authoring key.
    标头Header Content-type application/json
    QuerystringQuerystring appid LUIS 应用 ID。The LUIS app ID.
    正文Body {"AzureSubscriptionId":"ddda2925-af7f-4b05-9ba1-2155c5fe8a8e",{"AzureSubscriptionId":"ddda2925-af7f-4b05-9ba1-2155c5fe8a8e",
    "ResourceGroup": "resourcegroup-2","ResourceGroup": "resourcegroup-2",
    "AccountName": "luis-uswest-S0-2"}"AccountName": "luis-uswest-S0-2"}

    此 API 成功时,将返回“201 - 已创建状态”。When this API is successful, it returns a 201 - created status.

取消分配资源Unassign resource

  1. 登录 LUIS 门户,然后从“我的应用”列表中选择一个应用。 Sign in to the LUIS portal, then select an app from the My apps list.
  2. 导航到“管理 -> Azure 资源”页。 Navigate to the Manage -> Azure resources page.
  3. 对于此资源,选择“预测或创作资源”选项卡,然后选择“取消分配资源”按钮。 Select the Prediction or Authoring resource tab then select the Unassign resource button for the resource.

取消分配资源时,不会将其从 Azure 中删除。When you unassign a resource, it is not deleted from Azure. 只会将其从 LUIS 取消链接。It is only unlinked from LUIS.

重置创作密钥Reset authoring key

对于创作资源已迁移的应用:如果创作密钥已泄露,请在该创作资源的“密钥” 页上重置 Azure 门户中的密钥。For authoring resource migrated apps: if your authoring key is compromised, reset the key in the Azure portal on the Keys page for that authoring resource.

对于尚未迁移的应用:可在 LUIS 门户的所有应用中重置此密钥。For apps that have not migrated yet: the key is reset on all your apps in the LUIS portal. 如果通过创作 API 创作应用,则需将 Ocp-Apim-Subscription-Key 的值更改为新密钥。If you author your apps via the authoring APIs, you need to change the value of Ocp-Apim-Subscription-Key to the new key.

重新生成 Azure 密钥Regenerate Azure key

在 Azure 门户的“密钥”页上重新生成 Azure 密钥。 Regenerate the Azure keys from the Azure portal, on the Keys page.

删除帐户Delete account

要了解删除帐户时一并删除了哪些数据,请参阅数据存储和删除See Data storage and removal for information about what data is deleted when you delete your account.

更改定价层Change pricing tier

  1. Azure 中查找你的 LUIS 订阅。In Azure, find your LUIS subscription. 选择该 LUIS 订阅。Select the LUIS subscription. 查找 LUIS 订阅Find your LUIS subscription
  2. 选择“定价层”以查看可用的定价层 。Select Pricing tier in order to see the available pricing tiers. 查看定价层View pricing tiers
  3. 选择定价层,然后选择“选择”以保存更改 。Select the pricing tier and select Select to save your change. 更改 LUIS 支付层Change your LUIS payment tier
  4. 定价更改完成后,页面将出现一个供于验证新定价层的弹出窗口。When the pricing change is complete, a pop-up window verifies the new pricing tier. 验证 LUIS 支付层Verify your LUIS payment tier
  5. 请记住在“发布”页分配此终结点密钥,并将其用于所有终结点查询 。Remember to assign this endpoint key on the Publish page and use it in all endpoint queries.

查看 Azure 资源指标Viewing Azure resource metrics

查看 Azure 资源使用摘要Viewing Azure resource summary usage

可在 Azure 中查看 LUIS 使用情况信息。You can view LUIS usage information in Azure. “概述”页显示包含调用和错误在内的最新摘要信息 。The Overview page shows recent summary information including calls and errors. 如果发出 LUIS 终结点请求并立即查看“概述”页,则最多需要五分钟才会显示使用情况 。If you make a LUIS endpoint request, then immediately watch the Overview page, allow up to five minutes for the usage to show up.

查看使用概况

自定义 Azure 资源使用图表Customizing Azure resource usage charts

通过指标可更加详细地了解数据。Metrics provides a more detailed view into the data.

默认指标

可针对时间期限和指标类型配置度量值图表。You can configure your metrics charts for time period and metric type.

自定义指标

总事务数阈值警报Total transactions threshold alert

如果希望在达到特定事务阈值(例如 10,000 个事务)时收到通知,则可以创建警报。If you would like to know when you have reached a certain transaction threshold, for example 10,000 transactions, you can create an alert.

默认警报

添加针对特定时间段内“总调用数”指标的指标警报 。Add a metric alert for the total calls metric for a certain time period. 添加应接收该警报的所有人员的电子邮件地址。Add email addresses of all people that should receive the alert. 添加应接收该警报的所有系统的 Webhook。Add webhooks for all systems that should receive the alert. 还可在触发警报时运行逻辑应用。You can also run a logic app when the alert is triggered.

后续步骤Next steps

了解如何使用版本管理对 LUIS 应用的更改。Learn how to use versions to manage changes to your LUIS app.