-1

There is a requirement, need to create Azure Devops(CICD) pipeline for QNA - KB with below

Import excel file into Knowledge base Save & Train the Knowledge base Publish Knowledge base

How it can be done through Azure Devops Pipeline. Any documentation or steps could be helpful.

  • 2
    What have you tried so far? What hasn't worked? What problems are you having? Stack Overflow is not a code-writing service -- you are expected to attempt a solution yourself. – Daniel Mann May 13 '20 at 14:02

1 Answers1

0

You really need to give this a go so we can give more targeted advice, but I can give you some high level guidelines. First, you need to review the QnA Maker Programmatic APIs. These should allow you to access all of the functions you require. You can use a number of different tasks in DevOps Release Pipeline to call these, but I prefer Azure CLI for reasons I mention below.

With the API alone, you would need to hard code in values such as your subscription key, KBID, etc. To avoid hard coding these values, you can get them programmatically as well via the Azure CLI. If you set task version to 2.X, you can use PowerShell. Here is my script to get the QnA Maker key, subscription key, KBID, and Endpoint Key.

$QNAKEY= & az cognitiveservices account keys list -g "YOUR_RESOURCE_GROUP" --name "YOUR_COGNITIVE_SERVICE" --query key1 -o tsv

$header = @{"Ocp-Apim-Subscription-Key"="$QNAKEY"}

$res = Invoke-RestMethod -Uri "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases" -Method 'Get' -Headers $header

$kb = $res.knowledgebases | Where-Object name -eq "YOUR_KB_NAME"
$kbId = $kb.id

$res = Invoke-RestMethod -Uri "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/endpointkeys" -Method "Get" -Headers $header
$endpointKey = $res.primaryEndpointKey

Note the above is assuming you have the KB created already. Just take a look at the import API call and see what you need and adjust accordingly. Do note that if you are creating a new KB, QnA Maker does not ensure uniqueness of the KB name. Without some sort of check, you will end up creating duplicate KBs.

You should be able to use these methods (QnA Maker API and Azure CLI to call it within pipelines) to access any feature of KB management you need.

billoverton
  • 2,705
  • 2
  • 9
  • 32
  • Thanks Billoverton for brief insight, I am able to get knowledge base I’d with rest api Problem is I have an excel file which we use to import into qnamaker portal(qnamaker.ai) & publish it In azure pipeline with qna maker rest api , we need to convert excel into Json ($convertfromexceltojson) and use $res = Invoke-RestMethod -Uri "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebase/"+ $Kbid -method Put -body $convertfromexceltojson Do we have any other alternative approach? Like pass the exact excel using rest method? – Prabhuram A May 14 '20 at 17:42
  • I'm not aware of a method to do that directly. But if you add your repo as an artifact to the pipeline, you'll have access to the file and should be able to read it in and convert the file to JSON via PowerShell commands. I haven't had any experience with this personally, however. – billoverton May 14 '20 at 19:29