Azure Document Intelligence (formerly "Form Recognizer") is part of Microsoft's Azure AI services. It uses machine learning to:
- Automatically extract structured data from unstructured documents.
- Understand documents like invoices, receipts, contracts, ID cards, and more.
- Work with both English and non-English content (e.g., Polish).
- Use prebuilt models (like
prebuilt-invoice) or custom-trained models.
It supports various input formats:
- JPEG, PNG, PDF, TIFF, or document URLs.
- REST API, SDKs (.NET, Python, etc.), and Azure Studio (GUI).
The analysis can be performed both in the Azure portal and from the .NET application side.
This C# program reads scanned invoice files (e.g., .jpg) and extracts key invoice data using Azure Document Intelligence.
- Uses the prebuilt-invoice model from Azure.
- Accepts both local files and web URLs as input.
- Extracts vendor, buyer, invoice number, dates, tax info, and line items.
- Outputs a clean, readable invoice summary to the console.
- Uses free-tier (F0) plan – 500 free transactions/month.
-
Configuration
The program reads Azure endpoint, key, and file path fromjsonconfig files (appsettings.json,aiset.json). -
Connecting to Azure
It authenticates usingAzureKeyCredentialand creates aDocumentIntelligenceClient. -
Sending Invoice for Analysis
The file is uploaded as aBinaryDatastream, and analyzed with theAnalyzeDocumentAsyncmethod.
-
Processing Results
Extracted fields like:- Invoice Number, Date, Due Date
- Vendor and Buyer names, NIP (VAT)
- Items (description, quantity, tax, amount)
- Totals: Subtotal, Tax, and Total
-
Console Output
A formatted summary is printed in a readable, structured way.
===== INVOICE SUMMARY =====
Invoice Number : 001437/07/18
Invoice Date : 2018-07-14
Due Date : 2018-07-20
Payment Term : Przelew 5 dni
IBAN : 31 1522 6409 0000 0008 5552 7782
-- Seller --
Name : Computer CORE
Company : Media Computer CORE sp. j.
Address : 26-314 Radom, ul. Mickiewicza 16
NIP : 555-111-99-22
-- Buyer --
Name : CD TAPE Ryszard Morowski
Company : CD TAPE Ryszard Morowski
Address : 01-574 Warszawa ul. Marszałkowska 15/17
NIP : 555-111-44-77
-- Items --
---|----------------------|----------|-----------|--------|---------|----------|
| Description |UnitPrice | Quantity |TaxRate | Tax | Amount |
| | [PLN] | unit | [%] | [PLN] | [PLN] |
---|----------------------|----------|-----------|--------|---------|----------|
1 | SBS Cable USB A | 41,50 | 12 szt. | 23% | 114,54 | 612,54 |
2 | HP-2360 Printer | 455,00 | 4 szt. | 23% | 418,60 | 2238,60 |
3 | Mouse Pad XDS | 11,84 | 1 szt. | 23% | 2,72 | 14,56 |
4 | Ink Printer 10XL | 82,00 | 5 szt. | 23% | 94,30 | 504,30 |
-- Summary --
Subtotal : 2739,84 PLN
Tax : 630,16 PLN
Total : 3370 PLN


