skip to Main Content

I have created a basic Azure ‘Custom Question Answering’ bot (https://learn.microsoft.com/en-us/azure/cognitive-services/language-service/question-answering/quickstart/sdk?pivots=studio). I created the bot through Language Studio:
bot creation through language studio

I want to add authentication so that only users with who are part of my Azure AD are able to interact with the bot. I’ve tried following the tutorials listed below:

I’ve not been able to follow these tutorials, as they assume the bot is built from either of the following code bases:

Whereas the bot that I deployed through Language Studio looks like it is built from the following framework:

How can I add authentication to the custom question answering bot I deployed through Azure Language Studio (Cognitive services)? Currently anyone would be bale to interact with my bot.

Thanks

2

Answers


  1. To add authentication, there is a need to install a library supportive with Python Programming.

    pip install azure-ai-language-questionanswering
    

    Add the above library to start authentication process.

    Authenticate with Client

    Get an API key from Azure Cognitive Services.

    az cognitiveservices account keys list --resource-group <resource-group-name> --name <resource-name>
    

    To Instantiate QuestioningAnswerClient

    from azure.core.credentials import AzureKeyCredential
    from azure.ai.language.questionanswering import QuestionAnsweringClient
    
    endpoint = "https://{myaccount}.api.cognitive.microsoft.com"
    credential = AzureKeyCredential("{api-key}")
    
    client = QuestionAnsweringClient(endpoint, credential)
    

    For further reference, Check the below link:

    https://pypi.org/project/azure-ai-language-questionanswering/

    https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell

    Login or Signup to reply.
  2. Since these are all samples, they’re all designed to do one thing for simplicity’s sake. What you need to do is actually straightforward (in concept, if not always in practice). You should look at the code and docs of the auth samples and integrate the authentication sections with your CQA bot. Alternatively, you could integrate the CQA sections with an auth bot. Regardless of which base you start with, the goal is the same. Combine the two.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search