You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Document Intelligence处理1000页PDF超时问题求助

问题描述

使用Premium App Service Plan托管的Azure Function,已设置functionTimeout为00:30:00但仍超时,未找到相关解决信息。

PDF规格

  • 1000页
  • 30MiB
  • 扫描文档,无文本

DocIntel函数代码

from azure.ai.documentintelligence.aio import DocumentIntelligenceClient
from azure.ai.documentintelligence.models import AnalyzeDocumentRequest


async def create_doc_intel_client(credential):
    
    doc_intel_endpoint = f'https://{DOC_INTEL_RESOURCE}.cognitiveservices.azure.com'
    
    try:
        doc_intel_client = DocumentIntelligenceClient(
                                doc_intel_endpoint,
                                credential)
        logging.info(f'#### Doc Intel Client Successfully Created')
        
        return doc_intel_client
    
    except Exception as e:
        logging.error(f'#### Failed to create Doc Intel Client: {e}')

        raise


async def get_doc_layout(doc_client, doc_url):
    try:
        async with doc_client:
            poller = await doc_client.begin_analyze_document(
                "prebuilt-layout",
                AnalyzeDocumentRequest(url_source=doc_url)
            )
            
            minutes_elapsed = 0
            while not poller.done():
                status = poller.status()
                logging.info(f'#### Polling status: {status} | Minutes elapsed: {minutes_elapsed}')
                await asyncio.sleep(60)  # Sleep for 60 seconds (1 minute)
                minutes_elapsed += 1

            doc_analysis = await poller.result()
            doc_analysis_dict = doc_analysis.as_dict()
            doc_analysis_json = json.dumps(doc_analysis_dict)

            logging.info(f'#### Document successfully analyzed')

            return doc_analysis_json
    
    except Exception as e:
        logging.error(f'#### Failed to analyze document: {e}')
        raise

日志信息

2024-05-26T17:21:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 1
2024-05-26T17:22:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 2
2024-05-26T17:23:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 3
2024-05-26T17:24:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 4
2024-05-26T17:25:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 5
2024-05-26T17:26:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 6
2024-05-26T17:27:12Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 7
2024-05-26T17:28:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 8
2024-05-26T17:29:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 9
2024-05-26T17:30:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 10
2024-05-26T17:31:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 11
2024-05-26T17:32:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 12
2024-05-26T17:33:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 13
2024-05-26T17:34:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 14
2024-05-26T17:35:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 15
2024-05-26T17:36:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 16
2024-05-26T17:37:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 17
2024-05-26T17:38:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 18
2024-05-26T17:39:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 19
2024-05-26T17:40:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 20
2024-05-26T17:41:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 21
2024-05-26T17:42:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 22
2024-05-26T17:43:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 23
2024-05-26T17:44:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 24
2024-05-26T17:45:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 25
2024-05-26T17:46:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 26
2024-05-26T17:47:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 27
2024-05-26T17:48:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 28
2024-05-26T17:49:13Z   [Information]   #### Polling status: InProgress | Minutes elapsed: 29
2024-05-26T17:50:11Z   [Error]   Timeout value of 00:30:00 exceeded by function 'Functions.doc-process' (Id: '<guid>'). Initiating cancellation.
2024-05-26T17:50:11Z   [Error]   Executed 'Functions.doc-process' (Failed, Id=<guid>, Duration=1799999ms)

更新1

  • 设置functionTimeout: -1
  • 让Function运行90分钟,仍无响应。

内容的提问来源于stack exchange,提问作者ericOnline

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 05:55:55