Skip to content

Commit 98c7f46

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 6d9e5cf commit 98c7f46

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

samples/vision/content_moderator_text_moderation_samples.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os.path
1+
import os, os.path
22
from pprint import pprint
33

44
from azure.cognitiveservices.vision.contentmoderator import ContentModeratorClient
@@ -7,9 +7,9 @@
77
)
88
from msrest.authentication import CognitiveServicesCredentials
99

10-
SUBSCRIPTION_KEY_ENV_NAME = "CONTENTMODERATOR_SUBSCRIPTION_KEY"
11-
CONTENTMODERATOR_LOCATION = os.environ.get(
12-
"CONTENTMODERATOR_LOCATION", "westcentralus")
10+
# Add your Azure Content Moderator subscription key to your environment variables.
11+
SUBSCRIPTION_KEY = os.environ['CONTENT_MODERATOR_SUBSCRIPTION_KEY']
12+
1313
TEXT_FOLDER = os.path.join(os.path.dirname(
1414
os.path.realpath(__file__)), "text_files")
1515

@@ -25,7 +25,7 @@ def text_moderation(subscription_key):
2525
"""
2626

2727
client = ContentModeratorClient(
28-
endpoint='https://'+CONTENTMODERATOR_LOCATION+'.api.cognitive.microsoft.com',
28+
endpoint=os.environ['CONTENT_MODERATOR_ENDPOINT'], # Add your Content Moderator endpoint to your environment variables.
2929
credentials=CognitiveServicesCredentials(subscription_key)
3030
)
3131

@@ -49,4 +49,4 @@ def text_moderation(subscription_key):
4949
import os.path
5050
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
5151
from tools import execute_samples
52-
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)
52+
execute_samples(globals(), SUBSCRIPTION_KEY)

0 commit comments

Comments
 (0)