QnaMaker Where are my Subscription Keys?

by Michael Szul on

As I'm sure you are all aware, I've been going through all of the Bot Framework v4 command line utilities, and playing around with what's possible. I just wrapped up an emulator tutorial series that also included the MSBot CLI, and I'm currently working on a Chatdown tutorial series. Eventually, I'll get to the QnAMaker CLI, but in playing around with it, I hit a bit of a snag.

Well… it wasn't so much a snag, as a realization. I've been showing demos of QnAMaker as a "no code" solution for months now: in preview, in release, and with the recent CLI documentation. What I've noticed is that in each of those scenarios the necessary property names needed when integrating with a chatbot in the Azure Bot Service have changed.

I just wrapped up the QnAMaker appendix in the Bot Framework book that I'm working on, and this realization crept up again. I thought now would be a good opportunity to blog about it.

There are four primary components that are good to have handy when you're creating a chatbot in Azure that uses the QnAMaker service:

  • Subscription Key
  • Endpoint Key
  • Hostname
  • Knowledge Base ID

The confusion often arises in the difference between a "subscription key" versus a "subscription ID." It also doesn't help that the properties added to the Azure Bot Service you create when starting with a questions and answers template have changed on several occasions. Currently, it asks for:

  • QnAAuthKey
  • QnAEndpointHostName
  • QnAKnowledgebaseId

The hostname and the knowledge base ID are self explanatory, but note that the authorization key is a name not to be found anywhere.

On QnAMaker, you get the following configuration information:

POST /knowledgebases/5faeac0a-e812-4939-91bc-daecfaaf60df/generateAnswer
      Host: https://tutorial-qnamaker.azurewebsites.net/qnamaker
      Authorization: EndpointKey 83aeba1e-fa63-416b-9dcc-0fd651294670
      Content-Type: application/json
      {"question":"<Your question>"}
      

TheQnAEndpointHostName for the Azure Bot Service is what is provided in the above snippet by "Host," while the QnAKnowledgebaseId is the GUID seen in the "POST" URL.

For the QnAAuthKey, is this the authorization endpoint key above? Is it something else?

If you have the QnaMaker CLI installed, and you drop into a command line and type qnamaker -h, you will see a help statement that lists out all of the configuration keys you need, including both a subscription key and an endpoint key.

The endpoint key, you can grab from the snippet above, but the subscription key you have to get from the Cognitive Service in the Azure Portal that spins up to compliment your QnAMaker services. Find the Cognitive Service in your Azure Portal, click on it, then find the "Keys" menu item under "Resource Management." Clicking on this will give you your subscription key.

So which one do you need to plug into the web app bot properties?

According to the Azure documentation, your QnAAuthKey is going to be the endpoint key you can find in the deployment settings snippet as the EndpointKey. For both the QnAMaker CLI and the Bot Emulator v4, when you add a service, the subscription key that it asks for is your Cognitive Service subscription key from the "Resource Management" heading, and not your subscription ID from your Azure subscription.