我试图使用Microsoft 和Azure 自动化创建和部署聊天机器人应用程序的过程。
我有一个与我的服务对话的定制模板,我只需要为要部署的每个聊天机器人定制Web.config文件。我还想使用default.htm来主持一个基本的网络聊天,它使用部署的聊天机器人的DirectLine秘密。
我能够使用Azure CLI2.0创建一个WebApp聊天机器人应用程序,并将该聊天机器人与DirectLine通道集成。但是,我无法使用AzureCLI2.0获得DirectLine密钥。
我使用以下说明将通过CLI创建的聊天机器人与DirectLine通道集成:
az bot directline create --name
--resource-group
[--add-disabled {false, true}]
[--disablev1 {false, true}]
[--disablev3 {false, true}]
[--site-name]然而,当我使用show命令时,我没有需要在default.htm文件中添加到网络聊天中的秘密:
az bot directline show --name
--resource-group我可以使用Azure CLI或.NET SDK来实现这一点吗?我正在使用Azure CLI进行测试,但最后我想使用.NET SDK来创建一个REST web服务,该服务创建聊天机器人(基于我的自定义模板)并将URL返回给调用者。当调用者转到URL时,我希望default.htm托管网络聊天。
发布于 2018-07-26 08:39:21
无法使用AzureCLI2.0获得DirectLine密钥
根据我的测试,命令az bot directline show将发出以下请求,以检索有关直接线路通道的详细信息。
GET https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resourcegroup_name}/providers/Microsoft.BotService/botServices
/{bot_id}/channels/DirectLineChannel?api-version=2017-12-01但是key和key2在通过GET返回的响应中总是为null。

要在az bot cli中返回/获取key和key2,可以使用create命令:
az bot directline create --name MyBotName --resource-group MyResourceGroup --site-name site2

此外,要在.NET应用程序中管理僵尸服务,可以尝试使用Microsoft Azure管理Bot服务库。
您还可以在.NET应用程序中使用Azure管理api检索僵尸服务的直接行密钥。下面的示例请求供您参考。

示例请求主体:

注:
在Microsoft.Azure.Management.BotService.Models.DirectLineSite中,我们可以找到:获取主(次要)键。值仅通过POST返回到action,否则为空。
//
// Summary:
// Gets primary key. Value only returned through POST to the action Channel List
// API, otherwise empty.
[JsonProperty(PropertyName = "key")]
public string Key { get; }
//
// Summary:
// Gets secondary key. Value only returned through POST to the action Channel List
// API, otherwise empty.
[JsonProperty(PropertyName = "key2")]
public string Key2 { get; }发布于 2019-01-02 13:57:00
帮助告诉你还有一个论点是为了获得秘密。
PS C:\> az bot directline show --help
Command
az bot directline show : Get details of the Directline Channel on a bot.
Arguments
--name -n [Required] : The resource name of the bot.
--resource-group -g [Required] : Name of resource group. You can configure the default group
using `az configure --defaults group=<name>`.
--with-secrets : Show secrets in response for the channel. Allowed values:
false, true.
Global Arguments
--debug : Increase logging verbosity to show all debug logs.
--help -h : Show this help message and exit.
--output -o : Output format. Allowed values: json, jsonc, table, tsv, yaml.
Default: json.
--query : JMESPath query string. See http://jmespath.org/ for more
information and examples.
--subscription : Name or ID of subscription. You can configure the default
subscription using `az account set -s NAME_OR_ID`.
--verbose : Increase logging verbosity. Use --debug for full debug logs.使用以下命令,您可以获得直接线路频道的秘密:
--with-secrets -订阅"{subscriptionId}“显示-n "{botId}”-g "{resourceGroupName}“
我测试了它,它成功了。
发布于 2019-01-03 20:40:24
我还在这里查看了Azure BotService的Python源代码:factory.py。当我看到他们使用azure.mgmt.botservice库时,我搜索了有关它的源代码,并找到了这个文件operations.py,您可以在这个文件中找到所有可能的通道操作。
如果不想使用Azure Cli命令,也可以使用以下请求获取通道的密钥:
我还测试了它,它成功地应用于DirectLine、WebChat等.
.{channelName}/.参数应为:./DirectLineChannel/.或者./WebChatChannel/.
要使其工作,还需要向请求的授权键头中添加访问标记。
https://stackoverflow.com/questions/51518712
复制相似问题