Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextAnalytics] Default authentication to Token Credential #47405

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion sdk/textanalytics/Azure.AI.TextAnalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica

```C# Snippet:CreateTextAnalyticsClientTokenCredential
Uri endpoint = new("<endpoint>");
TextAnalyticsClient client = new(endpoint, new DefaultAzureCredential());
var credential = new DefaultAzureCredential();
TextAnalyticsClient client = new(endpoint, credential);
```

## Key concepts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void ExtractiveSummarize()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public async Task ExtractiveSummarizeAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void ExtractiveSummarizeConvenience()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public async Task ExtractiveSummarizeConvenienceAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample11_ExtractiveSummarizeConvenienceAsync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void AbstractiveSummarize()
TestEnvironment.IgnoreIfNotPublicCloud();

Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task AbstractiveSummarizeAsync()
TestEnvironment.IgnoreIfNotPublicCloud();

Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void AbstractiveSummarizeConvenience()
TestEnvironment.IgnoreIfNotPublicCloud();

Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task AbstractiveSummarizeConvenienceAsync()
TestEnvironment.IgnoreIfNotPublicCloud();

Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample12_AbstractiveSummarizeConvenienceAsync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void DetectLanguage()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample1_DetectLanguage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public async Task DetectLanguageAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample1_DetectLanguageAsync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public void DetectLanguageBatch()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample1_DetectLanguageBatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public async Task DetectLanguageBatchAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public void DetectLanguageBatchConvenience()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample1_DetectLanguageBatchConvenience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public async Task DetectLanguageBatchConvenienceAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public void AnalyzeSentimentWithOpinionMining()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample2_AnalyzeSentimentWithOpinionMining
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class TextAnalyticsSamples
public async Task AnalyzeSentimentWithOpinionMiningAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string reviewA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples
public void AnalyzeSentiment()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample2_AnalyzeSentiment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public async Task AnalyzeSentimentAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public void AnalyzeSentimentBatch()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample2_AnalyzeSentimentBatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public async Task AnalyzeSentimentBatchAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public void AnalyzeSentimentBatchConvenience()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample2_AnalyzeSentimentBatchConvenience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public async Task AnalyzeSentimentBatchConvenienceAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples
public void ExtractKeyPhrases()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample3_ExtractKeyPhrases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public async Task ExtractKeyPhrasesAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public void ExtractKeyPhrasesBatch()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample3_ExtractKeyPhrasesBatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class TextAnalyticsSamples
public async Task ExtractKeyPhrasesBatchAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public void ExtractKeyPhrasesBatchConvenience()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample3_ExtractKeyPhrasesBatchConvenience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class TextAnalyticsSamples
public async Task ExtractKeyPhrasesBatchConvenienceAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples
public void RecognizeEntities()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample4_RecognizeEntities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public async Task RecognizeEntitiesAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample4_RecognizeEntitiesAsync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public void RecognizeEntitiesBatch()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample4_RecognizeEntitiesBatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public async Task RecognizeEntitiesBatchAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public void RecognizeEntitiesBatchConvenience()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample4_RecognizeEntitiesBatchConvenience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples
public async Task RecognizeEntitiesBatchConvenienceAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void RecognizePiiEntities()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample5_RecognizePiiEntities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public async Task RecognizePiiEntitiesAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void RecognizePiiEntitiesBatch()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample5_RecognizePiiEntitiesBatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public async Task RecognizePiiEntitiesBatchAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void RecognizePiiEntitiesBatchConvenience()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample5_RecognizePiiEntitiesBatchConvenience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public async Task RecognizePiiEntitiesBatchConvenienceAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string documentA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples : TextAnalyticsSampleBase
public void RecognizePiiEntitiesWithCategories()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class TextAnalyticsSamples
public void RecognizeLinkedEntities()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

#region Snippet:Sample6_RecognizeLinkedEntities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TextAnalyticsSamples
public async Task RecognizeLinkedEntitiesAsync()
{
Uri endpoint = new(TestEnvironment.Endpoint);
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
var credential = TestEnvironment.Credential;
TextAnalyticsClient client = new(endpoint, credential, CreateSampleOptions());

string document =
Expand Down
Loading
Loading