Creating a Knowledge Base Using SDK

Learn to create a knowledge base using the Azure QnA maker's Python SDK.


In this lesson, we’re going to build a knowledge base using the Azure QnA Maker SDK for Python. We’ll use the same QnA maker resource that we created in the earlier lesson.


To work with this chapter and run the code snippets on your local machine, you need to install the following package:

  • azure-cognitiveservices-knowledge-qnamaker==0.2.0

To learn how to install the packages, please visit the Appendix section.


We’ll follow the steps mentioned below to create a knowledge base and publish it so that it can be consumed in any application:

  • Step 1: We’ll create a client object using the QnAMakerClient class. Then, we will create a knowledge base using the CreateKbDTO class. In this lesson, we will use the same Azure FAQ URL as the data source.

  • Step 2: We’ll publish the knowledge base.

  • Step3: We’ll query the knowledge base using the questions related to Azure.

  • Step4: We’ll explore how to delete a knowledge base using the Python SDK.

Creating a knowledge base

Let’s start with creating the knowledge base.

Get hands-on with 1200+ tech skills courses.