azure-ai-document-intelligence-dotnet
它能做什么
这个工具可以帮助你从发票、收据和身份证件等文档中提取重要信息。它能读取文字、表格和结构化数据。
适用场景
- ✓自动整理发票和收据。
- ✓从身份证件中提取数据。
- ✓读取任意文档中的文字和表格。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-document-intelligence-dotnet/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请从这份 PDF 发票中提取供应商名称和总金额。”
每周 5 个新技能,1 分钟读完。
工作原理
你提供一份文档(比如 PDF 或图片),并选择一个预构建模型(比如“invoice”或“receipt”)。工具随后会读取文档,并返回你需要的信息。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Azure.AI.DocumentIntelligence (.NET)
Extract text, tables, and structured data from documents using prebuilt and custom models.
Installation
dotnet add package Azure.AI.DocumentIntelligence
dotnet add package Azure.Identity
Current Version: v1.0.0 (GA)
Environment Variables
DOCUMENT_INTELLIGENCE_ENDPOINT=https://<resource-name>.cognitiveservices.azure.com/
DOCUMENT_INTELLIGENCE_API_KEY=<your-api-key>
BLOB_CONTAINER_SAS_URL=https://<storage>.blob.core.windows.net/<container>?<sas-token>
Authentication
Microsoft Entra ID (Recommended)
using Azure.Identity;
using Azure.AI.DocumentIntelligence;
string endpoint = Environment.GetEnvironmentVariable("DOCUMENT_INTELLIGENCE_ENDPOINT");
var credential = new DefaultAzureCredential();
var client = new DocumentIntelligenceClient(new Uri(endpoint), credential);
Note: Entra ID requires a custom subdomain (e.g.,
https://<resource-name>.cognitiveservices.azure.com/), not a regional endpoint.
API Key
string endpoint = Environment.GetEnvironmentVariable("DOCUMENT_INTELLIGENCE_ENDPOINT");
string apiKey = Environment.GetEnvironmentVariable("DOCUMENT_INTELLIGENCE_API_KEY");
var client = new DocumentIntelligenceClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
Client Types
| Client | Purpose |
|---|---|
DocumentIntelligenceClient |
Analyze documents, classify documents |
DocumentIntelligenceAdministrationClient |
Build/manage custom models and classifiers |
Prebuilt Models
| Model ID | Description |
|---|---|
prebuilt-read |
Extract text, languages, handwriting |
prebuilt-layout |
Extract text, tables, selection marks, structure |
prebuilt-invoice |
Extract invoice fields (vendor, items, totals) |
prebuilt-receipt |
Extract receipt fields (merchant, items, total) |
prebuilt-idDocument |
Extract ID document fields (name, DOB, address) |
prebuilt-businessCard |
Extract business card fields |
prebuilt-tax.us.w2 |
Extract W-2 tax form fields |
prebuilt-healthInsuranceCard.us |
Extract health insurance card fields |
Core Workflows
1. Analyze Invoice
using Azure.AI.DocumentIntelligence;
Uri invoiceUri = new Uri("https://example.com/invoice.pdf");
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(
WaitUntil.Completed,
"prebuilt-invoice",
invoiceUri);
AnalyzeResult result = operation.Value;
foreach (AnalyzedDocument document in result.Documents)
{
if (document.Fields.TryGetValue("VendorName", out DocumentField vendorNameField)
&& vendorNameField.FieldType == DocumentFieldType.String)
{
string vendorName = vendorNameField.ValueString;
Console.WriteLine($"Vendor Name: '{vendorName}', confidence: {vendorNameField.Confidence}");
}
if (document.Fields.TryGetValue("InvoiceTotal", out DocumentField invoiceTotalField)
&& invoiceTotalField.FieldType == DocumentFieldType.Currency)
{
CurrencyValue invoiceTotal = invoiceTotalField.ValueCurrency;
Console.WriteLine($"Invoice Total: '{invoiceTotal.CurrencySymbol}{invoiceTotal.Amount}'");
}
// Extract line items
if (document.Fields.TryGetValue("Items", out DocumentField itemsField)
&& itemsField.FieldType == DocumentFieldType.List)
{
foreach (DocumentField item in itemsField.ValueList)
{
var itemFields = item.ValueDictionary;
if (itemFields.TryGetValue("Description", out DocumentField descField))
Console.WriteLine($" Item: {descField.ValueString}");
}
}
}
2. Extract Layout (Text, Tables, Structure)
Uri fileUri = new Uri("https://example.com/document.pdf");
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(
WaitUntil.Completed,
"prebuilt-layout",
fileUri);
AnalyzeResult result = operation.Value;
// Extract text by page
foreach (DocumentPage page in result.Pages)
{
Console.WriteLine($"Page {page.PageNumber}: {page.Lines.Count} lines, {page.Words.Count} words");
foreach (DocumentLine line in page.Lines)
{
Console.WriteLine($" Line: '{line.Content}'");
}
}
// Extract tables
foreach (DocumentTable table in result.Tables)
{
Console.WriteLine($"Table: {table.RowCount} rows x {table.ColumnCount} columns");
foreach (DocumentTableCell cell in table.Cells)
{
…
常见问题
什么是“预构建模型”?
这些模型是工具已经掌握的,经过训练,能够识别发票、收据等特定类型的文档。
我可以用自己的文档来训练这个工具吗?
可以,对于预构建模型未覆盖的文档,你可以创建自定义模型。
提取出的信息保存在哪里?
工具会提取信息并返回给你,供你的程序使用。具体如何保存,取决于你如何编写代码。
详情
作者的原始描述
Azure AI Document Intelligence SDK for .NET. Extract text, tables, and structured data from documents using prebuilt and custom models.
热度
- GitHub 星标
- 48k
- 排名
- #3884
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。