sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/README.md
The Question Answering Authoring client library lets you manage Question Answering projects: create and configure projects, add and update knowledge sources, add QnA pairs, deploy a project, and delete it. Use this library to automate lifecycle management while using the runtime (Inference) library to ask questions.
Source code | Package (NuGet) | API reference | Samples | Product documentation | REST API docs
If you only need to query deployed projects, install the runtime package (
Azure.AI.Language.QuestionAnswering.Inference).If you need to create/update/deploy projects (authoring), use the authoring preview package (
Azure.AI.Language.QuestionAnswering.Authoring).
Service API versions:
2022-10-132025-05-15-previewStable (GA) - installs latest released (non-preview) version:
dotnet add package Azure.AI.Language.QuestionAnswering
Preview (opt into new features and 2025-05-15-preview service version):
dotnet add package Azure.AI.Language.QuestionAnswering.Authoring --prerelease
dotnet add package Azure.AI.Language.QuestionAnswering.Inference --prerelease
Install without
--prereleasefor stable; add--prereleaseto opt into preview features and newer service version.
for
https://<resource>.cognitiveservices.azure.com/)You can use an API key or Azure Active Directory (AAD) credentials (including Managed Identity).
Add the authoring namespace:
using Azure.AI.Language.QuestionAnswering.Authoring;
Uri endpoint = new Uri("https://myaccount.cognitiveservices.azure.com/");
AzureKeyCredential credential = new AzureKeyCredential("{api-key}");
QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential);
Uri endpoint = new Uri("https://myaccount.cognitiveservices.azure.com/");
TokenCredential credential = new DefaultAzureCredential();
QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential, new QuestionAnsweringAuthoringClientOptions());
Regional endpoints may require a custom domain configuration to use AAD / Managed Identity. See official authentication docs for details.
| Concept | Description |
|---|---|
| Project | A container for language configuration, knowledge sources, QnA pairs, and deployments. |
| Deployment | A named, queryable snapshot of a project used by runtime clients. |
| Knowledge Source | A URL / file / structured or unstructured content ingested into the project. |
| QnA Pair | A question with one or more answers that can be updated incrementally. |
| Long‑running Operations | Creating deployments, updating sources, updating QnAs, and export operations return Operation<T>. |
Client instances are thread-safe and intended to be reused.
Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime
<!-- CLIENT COMMON BAR -->// Set project name and request content parameters
string newProjectName = "{ProjectName}";
RequestContent creationRequestContent = RequestContent.Create(
new
{
description = "This is the description for a test project",
language = "en",
multilingualResource = false,
settings = new
{
defaultAnswer = "No answer found for your question."
}
}
);
Response creationResponse = client.CreateProject(newProjectName, creationRequestContent);
// Projects can be retrieved as follows
Pageable<QuestionAnsweringProject> projects = client.GetProjects();
Console.WriteLine("Projects: ");
foreach (QuestionAnsweringProject project in projects)
{
Console.WriteLine(project);
}
// Set deployment name and start operation
string newDeploymentName = "{DeploymentName}";
Operation deploymentOperation = client.DeployProject(WaitUntil.Completed, newProjectName, newDeploymentName);
// Deployments can be retrieved as follows
Pageable<ProjectDeployment> deployments = client.GetDeployments(newProjectName);
Console.WriteLine("Deployments: ");
foreach (ProjectDeployment deployment in deployments)
{
Console.WriteLine(deployment);
}
// Set request content parameters for updating our new project's sources
string sourceUri = "{KnowledgeSourceUri}";
RequestContent updateSourcesRequestContent = RequestContent.Create(
new[] {
new {
op = "add",
value = new
{
displayName = "MicrosoftFAQ",
source = sourceUri,
sourceUri = sourceUri,
sourceKind = "url",
contentStructureKind = "unstructured",
refresh = false
}
}
});
Operation updateSourcesOperation = client.UpdateSources(WaitUntil.Completed, newProjectName, updateSourcesRequestContent);
// Knowledge Sources can be retrieved as follows
BinaryData sources = updateSourcesOperation.GetRawResponse().Content;
Console.WriteLine($"Sources: {sources}");
Additional operations (update QnAs, export, delete) follow similar patterns using
Operation<T>or directResponseobjects.
As of the 2.0.0 preview split (use --prerelease to opt in):
Azure.AI.Language.QuestionAnswering) focuses on authoring but continues to expose inference types via type forwarding.Azure.AI.Language.QuestionAnswering.Inference.No code changes are required for upgrading typical projects. Use dotnet add package <package> for stable; add --prerelease only if you need preview features or the newer service version.
| Issue | Possible Cause | Mitigation |
|---|---|---|
| 401/403 | Invalid key or missing AAD role | Regenerate key or assign proper role |
| 404 | Project or deployment name incorrect | Verify spelling and casing |
| 409 | Concurrent modification conflict | Introduce retry / sequence operations |
| Operation timeout | Long-running network or service delay | Poll with backoff; inspect diagnostics / activity IDs |
Enable diagnostics logging:
using Azure.Core.Diagnostics;
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
See the root repository contributing guide for how to build, test, and submit changes.
<!-- LINKS -->