Skip to content

Commit 0a3898c

Browse files
authored
Updated key/endpoint
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 59bb02b commit 0a3898c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

samples/vision/content_moderator_image_list_samples.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
)
1414
from msrest.authentication import CognitiveServicesCredentials
1515

16-
SUBSCRIPTION_KEY_ENV_NAME = "CONTENTMODERATOR_SUBSCRIPTION_KEY"
17-
CONTENTMODERATOR_LOCATION = os.environ.get(
18-
"CONTENTMODERATOR_LOCATION", "westcentralus")
16+
# Add your Azure Content Moderator subscription key to your environment variables.
17+
SUBSCRIPTION_KEY = os.environ['CONTENT_MODERATOR_SUBSCRIPTION_KEY']
1918

2019
# The number of minutes to delay after updating the search index before
2120
# performing image match operations against the list.
@@ -50,7 +49,8 @@ def image_lists(subscription_key):
5049
"""
5150

5251
client = ContentModeratorClient(
53-
endpoint='https://'+CONTENTMODERATOR_LOCATION+'.api.cognitive.microsoft.com',
52+
endpoint=os.environ['CONTENT_MODERATOR_ENDPOINT'], # Add your Content Moderator endpoint to your environment variables.
53+
5454
credentials=CognitiveServicesCredentials(subscription_key)
5555
)
5656

@@ -225,4 +225,4 @@ def add_images(list_id, image_url, label):
225225
import os.path
226226
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
227227
from tools import execute_samples
228-
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)
228+
execute_samples(globals(), SUBSCRIPTION_KEY)

0 commit comments

Comments
 (0)