Skip to content

Commit a32d7df

Browse files
committed
add auth code
1 parent de553a9 commit a32d7df

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

articles/cognitive-services/content-safety/includes/quickstarts/csharp-quickstart-image.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ dotnet add package Azure.AI.ContentSafety --prerelease
7373
From the project directory, open the *Program.cs* file that was created previously. Paste in the following code:
7474

7575
```csharp
76+
// retrieve the endpoint and key from the environment variables created earlier
77+
string endpoint = Environment.GetEnvironmentVariable("CONTENT_SAFETY_ENDPOINT");
78+
string key = Environment.GetEnvironmentVariable("CONTENT_SAFETY_KEY");
79+
80+
ContentSafetyClient client = new ContentSafetyClient(new Uri(endpoint), new AzureKeyCredential(key));
81+
7682
string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Samples", "sample_data", "image.jpg");
7783
ImageData image = new ImageData() { Content = BinaryData.FromBytes(File.ReadAllBytes(datapath)) };
7884

articles/cognitive-services/content-safety/includes/quickstarts/csharp-quickstart-text.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ dotnet add package Azure.AI.ContentSafety --prerelease
7373
From the project directory, open the *Program.cs* file that was created previously. Paste in the following code:
7474

7575
```csharp
76+
// retrieve the endpoint and key from the environment variables created earlier
77+
string endpoint = Environment.GetEnvironmentVariable("CONTENT_SAFETY_ENDPOINT");
78+
string key = Environment.GetEnvironmentVariable("CONTENT_SAFETY_KEY");
79+
80+
ContentSafetyClient client = new ContentSafetyClient(new Uri(endpoint), new AzureKeyCredential(key));
81+
7682
string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Samples", "sample_data", "text.txt");
7783
string text = File.ReadAllText(datapath);
7884

0 commit comments

Comments
 (0)