See: Description
Package | Description |
---|---|
com.azure.ai.anomalydetector |
Package containing the classes for AnomalyDetectorClient.
|
com.azure.ai.anomalydetector.models |
Package containing the data models for AnomalyDetectorClient.
|
Microsoft Azure Cognitive Services Anomaly Detector API enables you to monitor and detect abnormalities in your time series data with machine learning.
Source code | Package (Maven) | API reference documentation | Product Documentation | Samples
For more information about creating the resource or how to get the location and sku information see here.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-anomalydetector</artifactId>
<version>3.0.0-beta.1</version>
</dependency>
In order to interact with the Anomaly Detector service, you'll need to create an instance of the AnomalyDetectorClient
class. You will need an endpoint and an API key to instantiate a client object.
You can obtain the endpoint and API key from the resource information in the Azure Portal.
Alternatively, you can use the Azure CLI snippet below to get the API key from the Anomaly Detector resource.
az cognitiveservices account keys list --resource-group <your-resource-group-name> --name <your-resource-name>
You can authenticate with Azure Active Directory using the Azure Identity library. Note that regional endpoints do not support AAD authentication. Create a custom subdomain for your resource in order to use this type of authentication.
To use the DefaultAzureCredential provider shown below, or other credential providers provided with the Azure SDK, please include the azure-identity
package:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.0</version>
</dependency>
You will also need to register a new AAD application and grant access to Anomaly Detector by assigning the "Cognitive Services User"
role to your service principal.
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURECLIENTID, AZURETENANTID, AZURECLIENTSECRET.
String endpoint = "<anomaly-detector-resource-endpoint>";
HttpHeaders headers = new HttpHeaders()
.put("Accept", ContentType.APPLICATION_JSON);
String defaultScope = "https://cognitiveservices.azure.com/.default";
HttpPipelinePolicy authPolicy = new BearerTokenAuthenticationPolicy(new DefaultAzureCredentialBuilder().build(),
defaultScope);
AddHeadersPolicy addHeadersPolicy = new AddHeadersPolicy(headers);
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(HttpClient.createDefault())
.policies(authPolicy, addHeadersPolicy).build();
AnomalyDetectorAsyncClient anomalyDetectorAsyncClient = new AnomalyDetectorClientBuilder()
.pipeline(httpPipeline)
.endpoint(endpoint)
.buildAsyncClient();
String endpoint = "<anomaly-detector-resource-endpoint>";
HttpHeaders headers = new HttpHeaders()
.put("Accept", ContentType.APPLICATION_JSON);
String defaultScope = "https://cognitiveservices.azure.com/.default";
HttpPipelinePolicy authPolicy = new BearerTokenAuthenticationPolicy(new DefaultAzureCredentialBuilder().build(),
defaultScope);
AddHeadersPolicy addHeadersPolicy = new AddHeadersPolicy(headers);
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(HttpClient.createDefault())
.policies(authPolicy, addHeadersPolicy).build();
AnomalyDetectorClient anomalyDetectorClient = new AnomalyDetectorClientBuilder()
.pipeline(httpPipeline)
.endpoint(endpoint)
.buildClient();
More examples can be found in samples.
Azure SDKs for Java offer a consistent logging story to help aid in troubleshooting application errors and expedite their resolution. The logs produced will capture the flow of an application before reaching the terminal state to help locate the root issue. View the [logging][logging] wiki for guidance about enabling logging.
This project welcomes contributions and suggestions. Most contributions require you to agree to a [Contributor License Agreement (CLA)][cla] declaring that you have the right to, and actually do, grant us the rights to use your contribution.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][cocfaq] or contact [opencode@microsoft.com][coccontact] with any additional questions or comments.
Copyright © 2021 Microsoft Corporation. All rights reserved.