Azure.AI.Language.QuestionAnswering.Inference 1.0.0-beta.1

Prefix Reserved
This is a prerelease version of Azure.AI.Language.QuestionAnswering.Inference.
dotnet add package Azure.AI.Language.QuestionAnswering.Inference --version 1.0.0-beta.1
                    
NuGet\Install-Package Azure.AI.Language.QuestionAnswering.Inference -Version 1.0.0-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.AI.Language.QuestionAnswering.Inference" Version="1.0.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Azure.AI.Language.QuestionAnswering.Inference" Version="1.0.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="Azure.AI.Language.QuestionAnswering.Inference" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Azure.AI.Language.QuestionAnswering.Inference --version 1.0.0-beta.1
                    
#r "nuget: Azure.AI.Language.QuestionAnswering.Inference, 1.0.0-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Azure.AI.Language.QuestionAnswering.Inference@1.0.0-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Azure.AI.Language.QuestionAnswering.Inference&version=1.0.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Azure.AI.Language.QuestionAnswering.Inference&version=1.0.0-beta.1&prerelease
                    
Install as a Cake Tool

Azure Cognitive Language Services Question Answering (Inference) client library for .NET

The Question Answering service lets you build a conversational question–answering layer over your data. It can extract questions and answers from semi‑structured content (FAQs, manuals, documents) and improve relevance over time.

Source code | Samples | Product documentation | [REST API documentation][questionanswering_rest_docs]

This package provides runtime inference (querying) only.
To create/update/deploy projects (authoring operations), use the Authoring package Azure.AI.Language.QuestionAnswering (namespace: Azure.AI.Language.QuestionAnswering.Authoring).

Getting started

Service API version targeted: 2025-05-15-preview
Package version: 1.0.0-beta.1 (preview).

Install the package

dotnet add package Azure.AI.Language.QuestionAnswering.Inference --prerelease

Prerequisites

  • An Azure subscription
  • A Cognitive Services Language resource with a deployed Question Answering project (created via Authoring SDK or Language Studio)
  • Endpoint (e.g. https://<resource>.cognitiveservices.azure.com/)
  • API key or AAD credential (Reader role)

Language Studio remains the preferred experience for creating and managing projects; the Authoring SDK enables CI/CD automation.

Authenticate the client

You need an endpoint plus either an API key or AAD credential.

API key
using Azure.Core;
using Azure.AI.Language.QuestionAnswering;
Uri endpoint = new Uri("https://myaccount.cognitiveservices.azure.com/");
AzureKeyCredential credential = new AzureKeyCredential("{api-key}");

QuestionAnsweringClient client = new QuestionAnsweringClient(endpoint, credential);
Azure Active Directory (AAD)
using Azure.Identity;
Uri endpoint = new Uri("https://myaccount.cognitiveservices.azure.com");
DefaultAzureCredential credential = new DefaultAzureCredential();

QuestionAnsweringClient client = new QuestionAnsweringClient(endpoint, credential);

Regional endpoints do not support AAD directly; configure a custom domain to use AAD authentication.

Key concepts

  • QuestionAnsweringClient: asks questions against a deployed project (knowledge base).
  • QuestionAnsweringProject: identifies the project and deployment.
  • AnswersOptions: optional tuning (top answers, confidence threshold, follow‑up context).
  • AnswersResult / KnowledgeBaseAnswer: structured answers (confidence, source, answer text, optional short answer).
  • Follow‑up (chit‑chat) uses KnowledgeBaseAnswerContext(previousAnswer.QnaId.Value) for dialog continuity.
  • This package does not include project creation, source ingestion, QnA editing, deployment operations.

Thread safety

Client instances are thread‑safe; reuse them across threads and requests.

Additional concepts

Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime

Examples

Ask a question

string projectName = "{ProjectName}";
string deploymentName = "{DeploymentName}";
QuestionAnsweringProject project = new QuestionAnsweringProject(projectName, deploymentName);
Response<AnswersResult> response = client.GetAnswers("How long should my Surface battery last?", project);

foreach (KnowledgeBaseAnswer answer in response.Value.Answers)
{
    Console.WriteLine($"({answer.Confidence:P2}) {answer.Answer}");
    Console.WriteLine($"Source: {answer.Source}");
    Console.WriteLine();
}

Ask a follow‑up question (chit‑chat)

string projectName = "{ProjectName}";
string deploymentName = "{DeploymentName}";
// Answers are ordered by their ConfidenceScore so assume the user choose the first answer below:
KnowledgeBaseAnswer previousAnswer = answers.Answers.First();
QuestionAnsweringProject project = new QuestionAnsweringProject(projectName, deploymentName);
AnswersOptions options = new AnswersOptions
{
    AnswerContext = new KnowledgeBaseAnswerContext(previousAnswer.QnaId.Value)
};

Response<AnswersResult> response = client.GetAnswers("How long should charging take?", project, options);

foreach (KnowledgeBaseAnswer answer in response.Value.Answers)
{
    Console.WriteLine($"({answer.Confidence:P2}) {answer.Answer}");
    Console.WriteLine($"Source: {answer.Source}");
    Console.WriteLine();
}

Troubleshooting

Common HTTP status codes map directly from service responses (e.g. 400 invalid project/deployment, 404 not found).

Bad request example:

try
{
    QuestionAnsweringProject project = new QuestionAnsweringProject("invalid-knowledgebase", "test");
    Response<AnswersResult> response = client.GetAnswers("Does this knowledge base exist?", project);
}
catch (RequestFailedException ex)
{
    Console.WriteLine(ex.ToString());
}

Enable console diagnostics:

using Azure.Core.Diagnostics;
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();

Next steps

  • Explore samples.
  • Use Authoring SDK or Language Studio to evolve your knowledge base.
  • Review the migration guide

Contributing

See CONTRIBUTING.md. This project follows the Microsoft Open Source Code of Conduct.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Azure.AI.Language.QuestionAnswering.Inference:

Package Downloads
Azure.AI.Language.QuestionAnswering.Authoring

This is the Azure.AI.Language.QuestionAnswering.Authoring client library for developing .NET applications with rich experience.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-beta.1 966 12/3/2025