azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

Issue with Migrating from Form Recognizer SDK to Document Intelligence SDK: "404 Resources Not Found" Error

Open Anguschang582 opened this issue 1 year ago • 2 comments

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Hi, all

Background

I am currently developing an web app that allows users to upload their files and ask questions based on the uploaded data. At the moment, I am using an older version of the code (tag rel071723) that has a Flask backend and, due to personal reasons I am not able to update it to the newest(even the one with quart backend) one.

Issue

Recently, I am now working on supporting additional file types (.docx, .xlsx, .pptx) by switching from the Form Recognizer SDK to the Document Intelligence SDK. However, when I attempt to make this change, I encounter a "404 resources not found" error.

I have already checked the endpoint, API version, and the code itself, and have also checked the migration guide, but the issue still remains.

Code

old version (which works perfectly fine)

from azure.ai.formrecognizer import DocumentAnalysisClient
# === other import ===

service = cog-fr-xxxxxx
azure_credential = DefaultAzureCredential()

client = DocumentAnalysisClient(
    endpoint=f"https://{service}.cognitiveservices.azure.com/",
    header={"x-ms-useragent": "azuredemo/1.0"}
    credential=AzureKeyCredential(THE_KEY)
)

// data is download from azure blob
fraw = io.BytesIO(BlobServiceClient(f"https://{STORAGE_ACCOUNT_NAME}.blob.core.windows.net", azure_credential)
                  .get_blob_client(container = source_container, blob = source)
                  .download_blob().readall())

poller = client.begin_analyze_document(model_id="prebuilt-layout", document=fraw)
results = poller.result()

New code (which throw 404 resource not found error)

from azure.ai.documentintelligence import DocumentIntelligenceClient
# === other import ===

service = cog-fr-xxxxxx  
azure_credential = DefaultAzureCredential()

client = DocumentIntelligenceClient(
    endpoint=f"https://{service}.cognitiveservices.azure.com/",
    credential=AzureKeyCredential(THE_KEY)
)

// data is download from azure blob
fraw = io.BytesIO(BlobServiceClient(f"https://{STORAGE_ACCOUNT_NAME}.blob.core.windows.net", azure_credential)
                  .get_blob_client(container = source_container, blob = source)
                  .download_blob().readall())

poller = client.begin_analyze_document(
    model_id="prebuilt-layout", analyze_request=fraw, content_type="application/octet-stream"
)
results = poller.result()

Notice that i am using exact same endpoint/key on both code

Versions

azure-ai-formrecognizer: 3.2.1 azure-ai-documentintelligence: 1.0.0b2

Questions

  1. From my understanding, the Form Recognizer and Document Intelligence services are basically the same (using the same endpoint). Therefore, there should be no need to revise the endpoint and key or changing any configuration on Azure portal when migrating to the Document Intelligence SDK. Is this correct?
  2. If this is not the cause of the error, what other potential issues could be triggering the "404 resources not found" error?

Any help would be greatly appreciated. Thank you!

Anguschang582 avatar Sep 17 '24 06:09 Anguschang582