Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.58k stars 2.8k forks source link

Sample for azure-ai-documentintelligence fails with "NameError: name 'AnalyzeDocumentRequest' is not defined" #37924

Open dcasota opened 2 hours ago

dcasota commented 2 hours ago

Describe the bug The python sample in https://learn.microsoft.com/en-us/training/modules/plan-form-recognizer-solution/3-resources?pivots=python fails with "NameError: name 'AnalyzeDocumentRequest' is not defined"

To Reproduce Steps to reproduce the behavior:

  1. Install vanila Windows Server 2025
  2. Python Releases for Windows | Python.org --> download and install python 3.13.0
  3. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  4. Add path to user variable PATH
  5. pip install azure-ai-documentintelligence
  6. Python IDLE shell, open a document and paste the python code
from azure.core.credentials import AzureKeyCredential
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.ai.documentintelligence.models import AnalyzeResult

endpoint = "xxxxx"
key = "xxxxx"

docUrl = "https://www.ensi.ch/en/wp-content/uploads/sites/5/2024/09/Organigramm_E_01.10.2024.pdf"

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, 
    credential=AzureKeyCredential(key))

poller = document_analysis_client.begin_analyze_document("prebuilt-layout", AnalyzeDocumentRequest(url_source=docUrl))
result: AnalyzeResult = poller.result()

Accordingly to https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-documentintelligence_1.0.0b4/sdk/documentintelligence/azure-ai-documentintelligence/MIGRATION_GUIDE.md, the function has been migrated.

Expected behavior Sample runs smoothly.

Screenshots Image

github-actions[bot] commented 2 hours ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.