Skip to content

Commit 0ea19e6

Browse files
authored
Updated endpoint and key
Endpoints are not region-based anymore, but rather custom domain -based. Although regional endpoints will still work. Also, the authentication information is moving to a standard of getting it from environment variables.
1 parent 1739692 commit 0ea19e6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

samples/anomaly_detector_samples.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
import pandas as pd
77
import os
88

9-
SUBSCRIPTION_KEY_ENV_NAME = "ANOMALYDETECTOR_SUBSCRIPTION_KEY"
10-
ANOMALYDETECTOR_LOCATION = os.environ.get(
11-
"ANOMALYDETECTOR_LOCATION", "westcentralus")
9+
# Add your Azure Anomaly Detector subscription key to your environment variables.
10+
SUBSCRIPTION_KEY = os.environ.get["ANOMALY_DETECTOR_SUBSCRIPTION_KEY"]
1211

1312
CSV_FOLDER = os.path.join(os.path.dirname(
1413
os.path.realpath(__file__)), "csv_files")
@@ -30,9 +29,9 @@ def get_request():
3029

3130
def entire_detect(subscription_key):
3231
print("Sample of detecting anomalies in the entire series.")
33-
34-
endpoint = "https://{}.api.cognitive.microsoft.com".format(
35-
ANOMALYDETECTOR_LOCATION)
32+
# Add your Azure Anomaly Detector subscription key to your environment variables.
33+
endpoint = os.environ.get["ANOMALY_DETECTOR_ENDPOINT"]
34+
3635
try:
3736
client = AnomalyDetectorClient(
3837
endpoint, CognitiveServicesCredentials(subscription_key))
@@ -55,9 +54,9 @@ def entire_detect(subscription_key):
5554

5655
def last_detect(subscription_key):
5756
print("Sample of detecting whether the latest point in series is anomaly.")
58-
59-
endpoint = "https://{}.api.cognitive.microsoft.com".format(
60-
ANOMALYDETECTOR_LOCATION)
57+
# Add your Azure Anomaly Detector subscription key to your environment variables.
58+
endpoint = os.environ.get["ANOMALY_DETECTOR_ENDPOINT"]
59+
6160
try:
6261
client = AnomalyDetectorClient(
6362
endpoint, CognitiveServicesCredentials(subscription_key))
@@ -80,4 +79,4 @@ def last_detect(subscription_key):
8079
import os.path
8180
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
8281
from tools import execute_samples
83-
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)
82+
execute_samples(globals(), SUBSCRIPTION_KEY)

0 commit comments

Comments
 (0)