CognitiveServices Language TextAnalytics API is not working

Narayanasetti, Vinodh Kumar 20 Reputation points
2025-10-15T11:30:20.7+00:00

I have used this package Microsoft.Azure.CognitiveServices.Language.TextAnalytics version 3.0.0 in one of my legacy application.

var client = new TextAnalyticsClient(new ApiKeyServiceClientCredentials(cognitiveConfiguration))
 {
     Endpoint = cognitiveConfiguration.Endpoint
 };

 var kpResults = await client.KeyPhrasesAsync(
                true,
                new MultiLanguageBatchInput(
                    new List<MultiLanguageInput>
                    {
         new MultiLanguageInput(language, "1", query)
                    }));
  • client.KeyPhrasesAsync method is throwing below exception suddenly.

Error response:

"StatusCode": 3,

"ActivityId": "4000000a-0001-fd00-b63f-84710c7967bb",

"Errors": 

        "Code": -2146233088,

        "Message": "Operation returned an invalid status code 'Gone'",

        "FullMessage": "Exception: Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Models.ErrorResponseException\r\n

After troubleshooting i've found that client.KeyPhrasesAsync uses this request url https://{{region}}.api.cognitive.microsoft.com//text/analytics/v2.1/keyPhrases?showStats=true and most of the articles were saying v2.1 has been retired on February 2024 but am not getting, how this was working till Oct 7th 2025.

Is anyone facing similar issue ? Can someone please provide suggestion on fixing this issue.

Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Sina Salam 25,761 Reputation points Volunteer Moderator
    2025-10-15T13:17:54.3933333+00:00

    Hello Narayanasetti, Vinodh Kumar,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that your CognitiveServices Language TextAnalytics API is not working.

    This is not simply an intermittent service fault; it is a direct result of Microsoft officially retiring the Text Analytics v2.x API on February 29, 2024, which your existing SDK still uses. The recent “Operation returned an invalid status code 'Gone'” message indicates that the v2.1 endpoint (https://{region}.api.cognitive.microsoft.com/text/analytics/v2.1/keyPhrases) has now been permanently disabled for your Azure region, causing all requests routed through this legacy path to fail. You can confirm this by running a simple curl test that returns an HTTP 410 (Gone) status. Azure Cognitive Services Text Analytics v2.x Retirement Notice

    Therefore, to restore functionality, you must migrate to the current Azure AI Language or Azure.AI.TextAnalytics SDK that uses the unified API endpoint format — https://<your-language-resource-endpoint>/language/:analyze-text?api-version=2024-11-01. This endpoint uses a new request structure with "kind": "KeyPhraseExtraction" and an analysisInput payload instead of the older MultiLanguageBatchInput. The updated SDKs also use modern authentication mechanisms such as AzureKeyCredential or DefaultAzureCredential, replacing the deprecated ApiKeyServiceClientCredentials. Migrate to the Latest Azure AI Language Service

    To implement the fix, first update your NuGet package with:

    dotnet add package Azure.AI.TextAnalytics Then, replace your old client initialization code with the new SDK syntax. The latest client now supports key phrase extraction using a simplified asynchronous call pattern:

    using Azure;
    using Azure.AI.TextAnalytics;
    var credential = new AzureKeyCredential("<your-key>");
    var client = new TextAnalyticsClient(new Uri("<your-endpoint>"), credential);
    Response<KeyPhraseCollection> response = await client.ExtractKeyPhrasesAsync("Azure Cognitive Services are powerful AI tools.", "en");
    foreach (string phrase in response.Value)
    {
        Console.WriteLine(phrase);
    }
    

    Azure.AI.TextAnalytics .NET SDK Reference

    If you prefer to use the REST API instead of the SDK, the request body must now follow this unified format:

    POST https://<your-language-resource-endpoint>/language/:analyze-text?api-version=2024-11-01
    Content-Type: application/json
    Ocp-Apim-Subscription-Key: <your-key>
    {
      "kind": "KeyPhraseExtraction",
      "parameters": { "modelVersion": "latest" },
      "analysisInput": {
        "documents": [
          { "id": "1", "language": "en", "text": "Azure Text Analytics helps extract meaningful insights." }
        ]
      }
    }
    

    Azure Language Service REST API – Analyze Text

    Finally, update your Azure resource configuration by verifying the endpoint in your Azure Portal under Keys and Endpoint. Use the FQDN format such as https://<your-resource-name>.cognitiveservices.azure.com/, not the retired regional domain. Authenticate requests to Azure AI Services

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.