sdk/onlineexperimentation/Azure.Analytics.OnlineExperimentation/README.md
Azure Online Experimentation is a managed service that enables developers to create and manage experiment metrics for evaluating online A/B tests.
Source code | API reference documentation | Product documentation | Samples
Install the Azure Online Experimentation client library for .NET with NuGet:
dotnet add package Azure.Analytics.OnlineExperimentation --prerelease
You need an Azure subscription with an Azure Online Experimentation workspace resource.
The Azure Online Experimentation client library initialization requires two parameters:
endpoint property value from the Microsoft.OnlineExperimentation/workspaces resource.TokenCredential for authentication, the simplest approach is to use DefaultAzureCredential.var endpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_ONLINEEXPERIMENTATION_ENDPOINT"));
var client = new OnlineExperimentationClient(endpoint, new DefaultAzureCredential());
You can explicitly select a supported service API version when instantiating a client:
var endpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_ONLINEEXPERIMENTATION_ENDPOINT"));
var options = new OnlineExperimentationClientOptions(OnlineExperimentationClientOptions.ServiceVersion.V2025_05_31_Preview);
var client = new OnlineExperimentationClient(endpoint, new DefaultAzureCredential(), options);
Always ensure that the chosen API version is fully supported and operational for your specific use case and aligns with the service's versioning policy.
The Azure Online Experimentation client library provides the following key classes:
OnlineExperimentationClient: Main client class for interacting with the service.DiagnosticDetail: Represents diagnostic details for experiment metrics.All client instances are thread-safe. It's recommended to reuse client instances across threads.
Client options | Accessing the response | Handling failures | Diagnostics
Explore common scenarios using the samples:
Common exceptions include:
RequestFailedException: Indicates a failure in the request. Inspect the exception message and status code for details.Enable logging and diagnostics to debug issues:
var endpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_ONLINEEXPERIMENTATION_ENDPOINT"));
var options = new OnlineExperimentationClientOptions()
{
Diagnostics =
{
IsLoggingContentEnabled = true
}
};
var client = new OnlineExperimentationClient(endpoint, new DefaultAzureCredential(), options);
See CONTRIBUTING.md for details on contributing to this library.