MS ChatBot - ClientConnector未经授权的异常

Dav*_*ers 3 azure chatbot botframework

我正在尝试使用ConnectorClient从Azure函数发送主动消息,但我获得了授权异常,尽管使用了正确的AppId&AppPassword

var connector = new ConnectorClient(new Uri(queueMessage.ChatBotDetails.ServiceUrl), new MicrosoftAppCredentials(appId, appPassword));

await connector.Conversations.SendToConversationAsync((Activity)message);
Run Code Online (Sandbox Code Playgroud)

但这会产生以下异常:

Microsoft.Bot.Connector.ErrorResponseException: Operation returned an invalid status code 'Unauthorized'

我在日志中输出应用密码和应用ID,它们是正确的.

Dav*_*ers 5

结果我只需要在调用连接器客户端之前添加此调用:

MicrosoftAppCredentials.TrustServiceUrl(queueMessage.ChatBotDetails.ServiceUrl);