nerdexam
Microsoft

AI-102 · Question #338

You are developing a method that uses the Azure AI Vision client library. The method will perform optical character recognition (OCR) in images. The method has the following code. During testing…

The correct answer is B. Add code to verify the read_results.status value. D. Wrap the call to get_read_result within a loop that contains a delay. To ensure the get_read_result method waits for an Azure AI Vision OCR operation to complete, you must repeatedly check the operation status and introduce a delay to avoid excessive polling.

Submitted by viktor_hu· Mar 30, 2026

Question

You are developing a method that uses the Azure AI Vision client library. The method will perform optical character recognition (OCR) in images. The method has the following code. During testing, you discover that the call to the get_read_result method occurs before the read operation is complete. You need to prevent the get_read_result method from proceeding until the read operation is complete. Which two actions should you perform? Each correct answer presents part of the solution. NOTE: Each correct selection is worth one point.

Exhibit

AI-102 question #338 exhibit

Options

  • ARemove the operation_id parameter.
  • BAdd code to verify the read_results.status value.
  • CAdd code to verify the status of the read_operation_location value.
  • DWrap the call to get_read_result within a loop that contains a delay.

How the community answered

(59 responses)
  • A
    15% (9)
  • B
    54% (32)
  • C
    31% (18)

Why each option

To ensure the `get_read_result` method waits for an Azure AI Vision OCR operation to complete, you must repeatedly check the operation status and introduce a delay to avoid excessive polling.

ARemove the operation_id parameter.

The `operation_id` parameter is essential for identifying and retrieving the results of a specific asynchronous OCR operation; removing it would make it impossible to get the results.

BAdd code to verify the read_results.status value.Correct

The `read_results.status` field (or similar field in the API response, often `status` or `readResult.status`) indicates the current state of the asynchronous OCR operation (e.g., 'notStarted', 'running', 'succeeded', 'failed'); checking this status allows the application to determine when the operation has finished.

CAdd code to verify the status of the read_operation_location value.

While `read_operation_location` contains the URL to poll for results, verifying its status value is not the direct way to check the *completion status* of the OCR operation itself; the *response from that URL* contains the actual status.

DWrap the call to get_read_result within a loop that contains a delay.Correct

Wrapping the call to `get_read_result` within a loop that contains a delay (e.g., using `time.sleep()`) implements a polling mechanism, preventing the client from continuously querying the service and providing time for the asynchronous OCR operation to complete.

Concept tested: Asynchronous operation polling for Azure AI Vision OCR

Source: https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/quickstarts-sdk/image-analysis-client-library-40?tabs=windows%2Cterminal&pivots=programming-language-python#optical-character-recognition-ocr

Topics

#Azure AI Vision#OCR#Asynchronous operations#SDK usage

Community Discussion

No community discussion yet for this question.

Full AI-102 Practice