Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Online Experimentation Service
Please rely heavily on our REST client docs to use this library
Key links:
Getting started
Currently supported environments
- LTS versions of Node.js
Prerequisites
- You must have an Azure subscription to use this package.
Install the @azure-rest/onlineexperimentation package
Install the Azure OnlineExperimentation REST client REST client library for JavaScript with npm:
npm install @azure-rest/onlineexperimentation
Create and authenticate a OnlineExperimentationClient
The Azure Online Experimentation client library initialization requires two parameters:
- The
endpointproperty value from theMicrosoft.OnlineExperimentation/workspacesresource. - A
TokenCredentialfor authentication, the simplest approach is to useDefaultAzureCredentialfrom the@azure/identitylibrary.
import { DefaultAzureCredential } from "@azure/identity";
import { OnlineExperimentationClient } from "@azure-rest/onlineexperimentation";
const endpoint = process.env.AZURE_ONLINEEXPERIMENTATION_ENDPOINT || "<endpoint>";
const credential = new DefaultAzureCredential();
// Initialize a client with default API version
const client = OnlineExperimentationClient(endpoint, credential);
Examples
- Full set of examples demonstrating individual API operations.
- Example demonstrating experiment metrics management lifecycle: TypeScript and JavaScript.
Quick Start - Initialize Client and List Experiment Metrics
The Azure OnlineExperimentation REST client library initialization requires two parameters:
- The
endpointproperty value from theMicrosoft.OnlineExperimentation/workspacesresource. - A
TokenCredentialfor authentication, the simplest approach is to useDefaultAzureCredential.
import { DefaultAzureCredential } from "@azure/identity";
import {
OnlineExperimentationClient,
isUnexpected,
paginate,
} from "@azure-rest/onlineexperimentation";
const endpoint = process.env.AZURE_ONLINEEXPERIMENTATION_ENDPOINT || "<endpoint>";
const credential = new DefaultAzureCredential();
const client = OnlineExperimentationClient(endpoint, credential);
const listResponse = await client.path("/experiment-metrics").get({
queryParameters: {
top: 10,
skip: 0,
},
});
if (isUnexpected(listResponse)) {
throw listResponse;
}
for await (const metric of paginate(client, listResponse)) {
// Access metric properties
const id = metric.id;
const name = metric.displayName;
}
Troubleshooting
Logging
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL environment variable to info. Alternatively, logging can be enabled at runtime by calling setLogLevel in the @azure/logger:
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.
Azure SDK for JavaScript