Azure Document Intelligence for Enterprise Architecture and Secure Deployment
Prerequisites
- Azure subscription with permission to create Cognitive Services, Storage, and Function App resources
- Working knowledge of Azure CLI, Microsoft Entra ID, and secure secret management
Steps
Azure Document Intelligence enables enterprises to extract structured data from forms, invoices, contracts, and unstructured documents using prebuilt and custom AI models. This guide explains architecture, deployment, CLI-based implementation, security hardening, and operational best practices for production environments.
Overview
Azure Document Intelligence, formerly Azure Form Recognizer, is an Azure AI service for extracting text, key-value pairs, tables, and semantic structure from documents such as invoices, receipts, IDs, contracts, and custom business forms. Enterprises use it to reduce manual processing, improve accuracy, and integrate document understanding into workflows across finance, HR, legal, and operations.
Key enterprise use cases include:
- Accounts payable automation for invoice extraction and validation
- Claims and onboarding document ingestion
- Contract analytics and metadata extraction
- Compliance workflows for searchable, structured records
It supports prebuilt models, custom extraction models, classification, and layout analysis, with APIs suited for batch and event-driven processing.
Architecture
Core components typically include:
- Azure AI Document Intelligence resource for model inference and training
- Azure Storage Account for source documents and result archival
- Azure Key Vault for secrets and CMK integration
- Azure Functions, Logic Apps, or AKS for orchestration
- Microsoft Entra ID for identity and access control
- Azure Monitor and Log Analytics for observability
Deployment models:
- Managed Azure service for fastest adoption and elastic scale
- Container deployment for controlled runtime placement, useful for connected edge or data residency requirements
View as text
[User/App] ---- 1. upload document ----> [Blob Storage] [Blob Storage] ---- 2. event ----> [Azure Function] [Azure Function] ---- 3. submit analyze request ----> [Azure Document Intelligence] [Azure Document Intelligence] ---- 4. JSON result ----> [Azure Function] [Azure Function] ---- 5. persist output ----> [Cosmos DB / SQL / Search] [Azure Function] ---- 6. logs ----> [Azure Monitor] [Key Vault] | v [Azure Function]
Data flow considerations:
- Documents land in Blob Storage via application upload or SFTP gateway.
- Event Grid triggers processing.
- Function retrieves secrets from Key Vault and calls the Document Intelligence API.
- Results are normalized and stored in downstream systems.
- Monitoring captures latency, failures, and model drift indicators.
Implementation Guide
- Create a resource group and storage account.
- Provision Azure AI Document Intelligence.
- Secure access with managed identity and Key Vault.
- Configure private endpoints if required.
- Deploy an event-driven processor.
az group create --name rg-docintel-prod --location westeurope
az storage account create --name stdocintelprod01 --resource-group rg-docintel-prod --location westeurope --sku Standard_LRS --min-tls-version TLS1_2 --allow-blob-public-access false
az cognitiveservices account create --name di-prod-01 --resource-group rg-docintel-prod --kind FormRecognizer --sku S0 --location westeurope --yes
az keyvault create --name kv-docintel-prod-01 --resource-group rg-docintel-prod --location westeurope --enable-rbac-authorization true
az functionapp create --name func-docintel-prod-01 --resource-group rg-docintel-prod --storage-account stdocintelprod01 --consumption-plan-location westeurope --runtime python --runtime-version 3.11 --functions-version 4
az functionapp identity assign --name func-docintel-prod-01 --resource-group rg-docintel-prod
Store the endpoint and key only if Entra ID is not yet used:
DI_ENDPOINT=$(az cognitiveservices account show --name di-prod-01 --resource-group rg-docintel-prod --query properties.endpoint -o tsv)
DI_KEY=$(az cognitiveservices account keys list --name di-prod-01 --resource-group rg-docintel-prod --query key1 -o tsv)
az keyvault secret set --vault-name kv-docintel-prod-01 --name di-endpoint --value "$DI_ENDPOINT"
az keyvault secret set --vault-name kv-docintel-prod-01 --name di-key --value "$DI_KEY"
Recommended app settings:
DOCUMENT_INTELLIGENCE_ENDPOINTKEY_VAULT_URIMODEL_IDSTORAGE_CONTAINER_INPUTSTORAGE_CONTAINER_OUTPUT
Code Examples
1. Bash: analyze an invoice
curl -X POST "$DI_ENDPOINT/documentintelligence/documentModels/prebuilt-invoice:analyze?api-version=2024-02-29-preview" \
-H "Ocp-Apim-Subscription-Key: $DI_KEY" \
-H "Content-Type: application/json" \
-d '{"urlSource":"https://stdocintelprod01.blob.core.windows.net/input/invoice-1001.pdf"}' -i
2. YAML: Function App settings
appSettings:
- name: DOCUMENT_INTELLIGENCE_ENDPOINT
value: "https://di-prod-01.cognitiveservices.azure.com/"
- name: KEY_VAULT_URI
value: "https://kv-docintel-prod-01.vault.azure.net/"
- name: MODEL_ID
value: "prebuilt-invoice"
- name: AzureWebJobsStorage
value: "@Microsoft.KeyVault(SecretUri=https://kv-docintel-prod-01.vault.azure.net/secrets/storage-conn/)"
3. Python: poll analysis result
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.core.credentials import AzureKeyCredential
endpoint = "https://di-prod-01.cognitiveservices.azure.com/"
key = "<retrieved-from-key-vault>"
client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
with open("invoice-1001.pdf", "rb") as f:
poller = client.begin_analyze_document("prebuilt-invoice", body=f)
result = poller.result()
for doc in result.documents:
print(doc.fields.get("VendorName").content)
print(doc.fields.get("InvoiceTotal").value_currency.amount)
Security Hardening
- Use private endpoints for Storage, Key Vault, and Document Intelligence where supported by your design.
- Prefer managed identities over static keys.
- Enforce RBAC with least privilege, such as
Key Vault Secrets Useronly for runtime identities. - Enable customer-managed keys where mandated.
- Restrict egress with Azure Firewall or approved outbound rules from AKS or Functions.
- Log all access through Azure Monitor, Diagnostic Settings, and Defender for Cloud.
- Classify extracted data and apply Microsoft Purview and DLP controls if outputs contain sensitive information.
Comparison
| Feature | Azure Document Intelligence | Google Document AI | Amazon Textract |
|---|---|---|---|
| Pricing model | Per page, model-specific tiers | Per page, processor-specific | Per page, feature-specific |
| Deployment | Managed service and containers | Managed service | Managed service |
| Scalability | Native Azure regional scaling and event-driven integration | Strong Google Cloud scaling | Strong AWS scaling |
| Security | Entra ID, Private Link, Key Vault, CMK, Azure Policy | IAM, VPC Service Controls, CMEK | IAM, KMS, VPC endpoints |
| Enterprise fit | Strong for Microsoft-centric estates and governance | Strong for GCP-centric AI pipelines | Strong for AWS-native document workflows |
Troubleshooting
- 401 Unauthorized
2026-11-15T09:14:22Z Error azure.core.exceptions.ClientAuthenticationError: (401) Access denied due to invalid subscription key or wrong API endpoint.
Fix: verify the endpoint matches the resource region and rotate the key in Key Vault.
- Unsupported file format
2026-11-15T09:16:03Z Error InvalidRequest: The file format is unsupported or corrupted. Content-Type=application/octet-stream, filename=claim.msg
Fix: convert to supported formats such as PDF, TIFF, JPEG, PNG, or Office formats supported by the API version.
- Model not found
2026-11-15T09:18:41Z Error ResourceNotFound: Document model custom-contract-v4 was not found.
Fix: confirm the modelId, target resource, and API version; custom models are resource-scoped.
Best Practices
Do
- Separate environments by subscription or resource group for dev, test, and prod.
- Version custom models and pin applications to tested model IDs.
- Store raw documents and normalized JSON for replay and audit.
- Use queue-based retries with idempotent processing for transient failures.
Don't
- Don't embed API keys in code or CI variables without Key Vault references.
- Don't send all documents to a single custom model if classification should route them first.
- Don't ignore confidence scores; for example, route invoices with low
InvoiceTotalconfidence to human review. - Don't skip retention controls when extracted data includes PII, financial, or contractual records.
Have a project in mind?
Get an instant AI price estimate for it, or talk directly to our team.
One email a month on what we learn building with AI