azure ai content understanding custom analyzer is not showing from portal with python sdk.

Mahesh Sanga 20 Reputation points Microsoft Employee
2025-08-25T08:50:39.25+00:00

Hi Team,

I am trying to Build a retrieval-augmented generation solution with Azure AI Content understanding with Python, and I have been following every step from https://learn.microsoft.com/en-us/azure/ai-services/content-understanding/tutorial/build-rag-solution?tabs=document#create-analyzers and trying to create aa custom analyzer with python code and from logs it is saying analyzers are created for given objects but unable to access it from AI Foundry as it is not showing from there,

πŸš€ Creating Content Understanding client with endpoint: https://masanga-aiplatform-poc-resource-westus.cognitiveservices.azure.com/ πŸ”¨ Creating analyzer: doc-analyzer6b9f6016-e22b-482f-b573-9f994fa3889c πŸ”¨ Creating analyzer: doc-analyzer6b9f6016-e22b-482f-b573-9f994fa3889c ❌ Failed to create analyzer: doc-analyzer6b9f6016-e22b-482f-b573-9f994fa3889c Error: 400 Client Error: Bad Request for url: https://aiplatform-poc-resource-westus.cognitiveservices.azure.com/contentunderstanding/analyzers/doc-analyzer6b9f6016-e22b-482f-b573-9f994fa3889c?api-version=2024-12-01-preview πŸ”¨ Creating analyzer: image-analyzer106a9604-27de-450f-ad70-8dfcec037511 ❌ Failed to create analyzer: doc-analyzer6b9f6016-e22b-482f-b573-9f994fa3889c Error: 400 Client Error: Bad Request for url: https://aiplatform-poc-resource-westus.cognitiveservices.azure.com/contentunderstanding/analyzers/doc-analyzer6b9f6016-e22b-482f-b573-9f994fa3889c?api-version=2024-12-01-preview πŸ”¨ Creating analyzer: image-analyzer106a9604-27de-450f-ad70-8dfcec037511 βœ… Successfully created analyzer: image-analyzer106a9604-27de-450f-ad70-8dfcec037511 πŸ”¨ Creating analyzer: audio-analyzer395f13a3-57f6-4af7-aedf-c023919a8739 βœ… Successfully created analyzer: image-analyzer106a9604-27de-450f-ad70-8dfcec037511 πŸ”¨ Creating analyzer: audio-analyzer395f13a3-57f6-4af7-aedf-c023919a8739 ❌ Failed to create analyzer: audio-analyzer395f13a3-57f6-4af7-aedf-c023919a8739 Error: 400 Client Error: Bad Request for url: https://aiplatform-poc-resource-westus.cognitiveservices.azure.com/contentunderstanding/analyzers/audio-analyzer395f13a3-57f6-4af7-aedf-c023919a8739?api-version=2024-12-01-preview

...

πŸ“‹ Configuration Summary: Endpoint: https://masanga-aiplatform-poc-resource-westus.cognitiveservices.azure.com/ API Version: 2024-12-01-preview

Azure AI Document Intelligence
{count} votes

Accepted answer
  1. Manas Mohanty 9,655 Reputation points Microsoft External Staff Moderator
    2025-08-28T06:12:27.2333333+00:00

    Hi Mahesh,

    Good morning!

    Regarding 400- client error - The api-version=2024-12-01-preview might not work for analyzing as per product group

    Recommended API version -

        api_version="2025-05-01-preview",
    
    
    

    Attached working code for reference

    from pathlib import Path
    import sys
    ANALYZER_SAMPLE_FILE = './azure-ai-content-understanding-python/data/invoice.pdf'
    
    
    from azure.identity import DefaultAzureCredential, get_bearer_token_provider
    
    credential = DefaultAzureCredential()
    token_provider = get_bearer_token_provider(credential, "https://cognitiveservices.azure.com/.default")
    import requests
    import json
    import sys
    import uuid
    from pathlib import Path
    
    #set analyzer configs
    analyzer_configs = [
        {
            "id": "doc-analyzer" + str(uuid.uuid4()),
            "template_path": "./azure-ai-content-understanding-python/analyzer_templates/content_document.json",
            "location": "./data/sample_layout.pdf",
       },
       
    
    ]
    
    # Create Content Understanding client
    content_understanding_client = AzureContentUnderstandingClient(
        endpoint="https://testagentmm02.cognitiveservices.azure.com/",
        api_version="2025-05-01-preview",
        token_provider=token_provider,
        x_ms_useragent="azure-ai-content-understanding-python/content_extraction", # This header is used for sample usage telemetry, please comment out this line if you want to opt out.
    )
    
    # Iterate through each config and create an analyzer
    for analyzer in analyzer_configs:
        analyzer_id = analyzer["id"]
        template_path = analyzer["template_path"]
        file_location = analyzer["location"]
    
        try:
    
            # Create the analyzer using the content understanding client
            response = content_understanding_client.begin_create_analyzer(
                analyzer_id=analyzer_id,
                analyzer_template_path=template_path,
                #location = file_location
            )
            result = content_understanding_client.poll_result(response)
            print(f"Successfully created analyzer: {analyzer_id}")
    
        except Exception as e:
            print(f"Failed to create analyzer: {analyzer_id}")
            print(f"Error: {e}")
    
    
    
    ANALYZER_SAMPLE_FILE = './azure-ai-content-understanding-python/data/invoice.pdf'
    #ANALYZER_ID = 'prebuilt-documentAnalyzer'
    
    # Analyze document file
    response = content_understanding_client.begin_analyze(analyzer["id"], file_location=ANALYZER_SAMPLE_FILE)
    result_json = content_understanding_client.poll_result(response)
    
    print(json.dumps(result_json, indent=2))
    
    
    You found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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