Skip to content

Commit 59bb02b

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 3315d47 commit 59bb02b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

samples/vision/content_moderator_image_job_samples.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
from azure.cognitiveservices.vision.contentmoderator import ContentModeratorClient
55
from msrest.authentication import CognitiveServicesCredentials
66

7-
SUBSCRIPTION_KEY_ENV_NAME = "CONTENTMODERATOR_SUBSCRIPTION_KEY"
8-
CONTENTMODERATOR_LOCATION = os.environ.get(
9-
"CONTENTMODERATOR_LOCATION", "westcentralus")
10-
7+
# Add your Azure Content Moderator subscription key to your environment variables.
8+
SUBSCRIPTION_KEY = os.environ["CONTENT_MODERATOR_SUBSCRIPTION_KEY"]
119

1210
def image_review_jobs(subscription_key):
1311
"""ImageReviewJobs.
@@ -35,7 +33,7 @@ def image_review_jobs(subscription_key):
3533
call_back_endpoint = "https://requestb.in/1l64pe71"
3634

3735
client = ContentModeratorClient(
38-
endpoint='https://'+CONTENTMODERATOR_LOCATION+'.api.cognitive.microsoft.com',
36+
endpoint=os.environ['CONTENT_MODERATOR_ENDPOINT'], # Add your Content Moderator endpoint to your environment variables.
3937
credentials=CognitiveServicesCredentials(subscription_key)
4038
)
4139

@@ -108,4 +106,4 @@ def image_review_jobs(subscription_key):
108106
import os.path
109107
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
110108
from tools import execute_samples
111-
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)
109+
execute_samples(globals(), SUBSCRIPTION_KEY)

0 commit comments

Comments
 (0)