[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-69553113-490d-4d07-915b-947e9486a72d":3,"$f3vYLZ5RPEyc1ZrmEp-36vtJJu6jPStL7QHZqGpuzgzg":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"69553113-490d-4d07-915b-947e9486a72d","azure-ai-document-intelligence-dotnet","Azure AI 文档智能SDK for .NET。使用预构建和自定义模型从文档中提取文本、表格和结构化数据。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-ai-document-intelligence-dotnet\ndescription: Azure AI Document Intelligence SDK for .NET. Extract text, tables, and structured data from documents using prebuilt and custom models.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure.AI.DocumentIntelligence (.NET)\n\nExtract text, tables, and structured data from documents using prebuilt and custom models.\n\n## Installation\n\n```bash\ndotnet add package Azure.AI.DocumentIntelligence\ndotnet add package Azure.Identity\n```\n\n**Current Version**: v1.0.0 (GA)\n\n## Environment Variables\n\n```bash\nDOCUMENT_INTELLIGENCE_ENDPOINT=https:\u002F\u002F\u003Cresource-name>.cognitiveservices.azure.com\u002F\nDOCUMENT_INTELLIGENCE_API_KEY=\u003Cyour-api-key>\nBLOB_CONTAINER_SAS_URL=https:\u002F\u002F\u003Cstorage>.blob.core.windows.net\u002F\u003Ccontainer>?\u003Csas-token>\n```\n\n## Authentication\n\n### Microsoft Entra ID (Recommended)\n\n```csharp\nusing Azure.Identity;\nusing Azure.AI.DocumentIntelligence;\n\nstring endpoint = Environment.GetEnvironmentVariable(\"DOCUMENT_INTELLIGENCE_ENDPOINT\");\nvar credential = new DefaultAzureCredential();\nvar client = new DocumentIntelligenceClient(new Uri(endpoint), credential);\n```\n\n> **Note**: Entra ID requires a **custom subdomain** (e.g., `https:\u002F\u002F\u003Cresource-name>.cognitiveservices.azure.com\u002F`), not a regional endpoint.\n\n### API Key\n\n```csharp\nstring endpoint = Environment.GetEnvironmentVariable(\"DOCUMENT_INTELLIGENCE_ENDPOINT\");\nstring apiKey = Environment.GetEnvironmentVariable(\"DOCUMENT_INTELLIGENCE_API_KEY\");\nvar client = new DocumentIntelligenceClient(new Uri(endpoint), new AzureKeyCredential(apiKey));\n```\n\n## Client Types\n\n| Client | Purpose |\n|--------|---------|\n| `DocumentIntelligenceClient` | Analyze documents, classify documents |\n| `DocumentIntelligenceAdministrationClient` | Build\u002Fmanage custom models and classifiers |\n\n## Prebuilt Models\n\n| Model ID | Description |\n|----------|-------------|\n| `prebuilt-read` | Extract text, languages, handwriting |\n| `prebuilt-layout` | Extract text, tables, selection marks, structure |\n| `prebuilt-invoice` | Extract invoice fields (vendor, items, totals) |\n| `prebuilt-receipt` | Extract receipt fields (merchant, items, total) |\n| `prebuilt-idDocument` | Extract ID document fields (name, DOB, address) |\n| `prebuilt-businessCard` | Extract business card fields |\n| `prebuilt-tax.us.w2` | Extract W-2 tax form fields |\n| `prebuilt-healthInsuranceCard.us` | Extract health insurance card fields |\n\n## Core Workflows\n\n### 1. Analyze Invoice\n\n```csharp\nusing Azure.AI.DocumentIntelligence;\n\nUri invoiceUri = new Uri(\"https:\u002F\u002Fexample.com\u002Finvoice.pdf\");\n\nOperation\u003CAnalyzeResult> operation = await client.AnalyzeDocumentAsync(\n    WaitUntil.Completed, \n    \"prebuilt-invoice\", \n    invoiceUri);\n\nAnalyzeResult result = operation.Value;\n\nforeach (AnalyzedDocument document in result.Documents)\n{\n    if (document.Fields.TryGetValue(\"VendorName\", out DocumentField vendorNameField)\n        && vendorNameField.FieldType == DocumentFieldType.String)\n    {\n        string vendorName = vendorNameField.ValueString;\n        Console.WriteLine($\"Vendor Name: '{vendorName}', confidence: {vendorNameField.Confidence}\");\n    }\n\n    if (document.Fields.TryGetValue(\"InvoiceTotal\", out DocumentField invoiceTotalField)\n        && invoiceTotalField.FieldType == DocumentFieldType.Currency)\n    {\n        CurrencyValue invoiceTotal = invoiceTotalField.ValueCurrency;\n        Console.WriteLine($\"Invoice Total: '{invoiceTotal.CurrencySymbol}{invoiceTotal.Amount}'\");\n    }\n    \n    \u002F\u002F Extract line items\n    if (document.Fields.TryGetValue(\"Items\", out DocumentField itemsField)\n        && itemsField.FieldType == DocumentFieldType.List)\n    {\n        foreach (DocumentField item in itemsField.ValueList)\n        {\n            var itemFields = item.ValueDictionary;\n            if (itemFields.TryGetValue(\"Description\", out DocumentField descField))\n                Console.WriteLine($\"  Item: {descField.ValueString}\");\n        }\n    }\n}\n```\n\n### 2. Extract Layout (Text, Tables, Structure)\n\n```csharp\nUri fileUri = new Uri(\"https:\u002F\u002Fexample.com\u002Fdocument.pdf\");\n\nOperation\u003CAnalyzeResult> operation = await client.AnalyzeDocumentAsync(\n    WaitUntil.Completed, \n    \"prebuilt-layout\", \n    fileUri);\n\nAnalyzeResult result = operation.Value;\n\n\u002F\u002F Extract text by page\nforeach (DocumentPage page in result.Pages)\n{\n    Console.WriteLine($\"Page {page.PageNumber}: {page.Lines.Count} lines, {page.Words.Count} words\");\n    \n    foreach (DocumentLine line in page.Lines)\n    {\n        Console.WriteLine($\"  Line: '{line.Content}'\");\n    }\n}\n\n\u002F\u002F Extract tables\nforeach (DocumentTable table in result.Tables)\n{\n    Console.WriteLine($\"Table: {table.RowCount} rows x {table.ColumnCount} columns\");\n    foreach (DocumentTableCell cell in table.Cells)\n    {\n        Console.WriteLine($\"  Cell ({cell.RowIndex}, {cell.ColumnIndex}): {cell.Content}\");\n    }\n}\n```\n\n### 3. Analyze Receipt\n\n```csharp\nOperation\u003CAnalyzeResult> operation = await client.AnalyzeDocumentAsync(\n    WaitUntil.Completed, \n    \"prebuilt-receipt\", \n    receiptUri);\n\nAnalyzeResult result = operation.Value;\n\nforeach (AnalyzedDocument document in result.Documents)\n{\n    if (document.Fields.TryGetValue(\"MerchantName\", out DocumentField merchantField))\n        Console.WriteLine($\"Merchant: {merchantField.ValueString}\");\n        \n    if (document.Fields.TryGetValue(\"Total\", out DocumentField totalField))\n        Console.WriteLine($\"Total: {totalField.ValueCurrency.Amount}\");\n        \n    if (document.Fields.TryGetValue(\"TransactionDate\", out DocumentField dateField))\n        Console.WriteLine($\"Date: {dateField.ValueDate}\");\n}\n```\n\n### 4. Build Custom Model\n\n```csharp\nvar adminClient = new DocumentIntelligenceAdministrationClient(\n    new Uri(endpoint), \n    new AzureKeyCredential(apiKey));\n\nstring modelId = \"my-custom-model\";\nUri blobContainerUri = new Uri(\"\u003Cblob-container-sas-url>\");\n\nvar blobSource = new BlobContentSource(blobContainerUri);\nvar options = new BuildDocumentModelOptions(modelId, DocumentBuildMode.Template, blobSource);\n\nOperation\u003CDocumentModelDetails> operation = await adminClient.BuildDocumentModelAsync(\n    WaitUntil.Completed, \n    options);\n\nDocumentModelDetails model = operation.Value;\n\nConsole.WriteLine($\"Model ID: {model.ModelId}\");\nConsole.WriteLine($\"Created: {model.CreatedOn}\");\n\nforeach (var docType in model.DocumentTypes)\n{\n    Console.WriteLine($\"Document type: {docType.Key}\");\n    foreach (var field in docType.Value.FieldSchema)\n    {\n        Console.WriteLine($\"  Field: {field.Key}, Confidence: {docType.Value.FieldConfidence[field.Key]}\");\n    }\n}\n```\n\n### 5. Build Document Classifier\n\n```csharp\nstring classifierId = \"my-classifier\";\nUri blobContainerUri = new Uri(\"\u003Cblob-container-sas-url>\");\n\nvar sourceA = new BlobContentSource(blobContainerUri) { Prefix = \"TypeA\u002Ftrain\" };\nvar sourceB = new BlobContentSource(blobContainerUri) { Prefix = \"TypeB\u002Ftrain\" };\n\nvar docTypes = new Dictionary\u003Cstring, ClassifierDocumentTypeDetails>()\n{\n    { \"TypeA\", new ClassifierDocumentTypeDetails(sourceA) },\n    { \"TypeB\", new ClassifierDocumentTypeDetails(sourceB) }\n};\n\nvar options = new BuildClassifierOptions(classifierId, docTypes);\n\nOperation\u003CDocumentClassifierDetails> operation = await adminClient.BuildClassifierAsync(\n    WaitUntil.Completed, \n    options);\n\nDocumentClassifierDetails classifier = operation.Value;\nConsole.WriteLine($\"Classifier ID: {classifier.ClassifierId}\");\n```\n\n### 6. Classify Document\n\n```csharp\nstring classifierId = \"my-classifier\";\nUri documentUri = new Uri(\"https:\u002F\u002Fexample.com\u002Fdocument.pdf\");\n\nvar options = new ClassifyDocumentOptions(classifierId, documentUri);\n\nOperation\u003CAnalyzeResult> operation = await client.ClassifyDocumentAsync(\n    WaitUntil.Completed, \n    options);\n\nAnalyzeResult result = operation.Value;\n\nforeach (AnalyzedDocument document in result.Documents)\n{\n    Console.WriteLine($\"Document type: {document.DocumentType}, confidence: {document.Confidence}\");\n}\n```\n\n### 7. Manage Models\n\n```csharp\n\u002F\u002F Get resource details\nDocumentIntelligenceResourceDetails resourceDetails = await adminClient.GetResourceDetailsAsync();\nConsole.WriteLine($\"Custom models: {resourceDetails.CustomDocumentModels.Count}\u002F{resourceDetails.CustomDocumentModels.Limit}\");\n\n\u002F\u002F Get specific model\nDocumentModelDetails model = await adminClient.GetModelAsync(\"my-model-id\");\nConsole.WriteLine($\"Model: {model.ModelId}, Created: {model.CreatedOn}\");\n\n\u002F\u002F List models\nawait foreach (DocumentModelDetails modelItem in adminClient.GetModelsAsync())\n{\n    Console.WriteLine($\"Model: {modelItem.ModelId}\");\n}\n\n\u002F\u002F Delete model\nawait adminClient.DeleteModelAsync(\"my-model-id\");\n```\n\n## Key Types Reference\n\n| Type | Description |\n|------|-------------|\n| `DocumentIntelligenceClient` | Main client for analysis |\n| `DocumentIntelligenceAdministrationClient` | Model management |\n| `AnalyzeResult` | Result of document analysis |\n| `AnalyzedDocument` | Single document within result |\n| `DocumentField` | Extracted field with value and confidence |\n| `DocumentFieldType` | String, Date, Number, Currency, etc. |\n| `DocumentPage` | Page info (lines, words, selection marks) |\n| `DocumentTable` | Extracted table with cells |\n| `DocumentModelDetails` | Custom model metadata |\n| `BlobContentSource` | Training data source |\n\n## Build Modes\n\n| Mode | Use Case |\n|------|----------|\n| `DocumentBuildMode.Template` | Fixed layout documents (forms) |\n| `DocumentBuildMode.Neural` | Variable layout documents |\n\n## Best Practices\n\n1. **Use DefaultAzureCredential** for production\n2. **Reuse client instances** — clients are thread-safe\n3. **Handle long-running operations** — Use `WaitUntil.Completed` for simplicity\n4. **Check field confidence** — Always verify `Confidence` property\n5. **Use appropriate model** — Prebuilt for common docs, custom for specialized\n6. **Use custom subdomain** — Required for Entra ID authentication\n\n## Error Handling\n\n```csharp\nusing Azure;\n\ntry\n{\n    var operation = await client.AnalyzeDocumentAsync(\n        WaitUntil.Completed, \n        \"prebuilt-invoice\", \n        documentUri);\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"Error: {ex.Status} - {ex.Message}\");\n}\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.AI.DocumentIntelligence` | Document analysis (this SDK) | `dotnet add package Azure.AI.DocumentIntelligence` |\n| `Azure.AI.FormRecognizer` | Legacy SDK (deprecated) | Use DocumentIntelligence instead |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FAzure.AI.DocumentIntelligence |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fazure.ai.documentintelligence |\n| GitHub Samples | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fdocumentintelligence\u002FAzure.AI.DocumentIntelligence\u002Fsamples |\n| Document Intelligence Studio | https:\u002F\u002Fdocumentintelligence.ai.azure.com\u002F |\n| Prebuilt Models | https:\u002F\u002Faka.ms\u002Fazsdk\u002Fformrecognizer\u002Fmodels |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,158,1319,"2026-05-16 13:05:13",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"6e36e6e8-4128-438a-b1bc-98f20c681c41","1.0.0","azure-ai-document-intelligence-dotnet.zip",3528,"uploads\u002Fskills\u002F69553113-490d-4d07-915b-947e9486a72d\u002Fazure-ai-document-intelligence-dotnet.zip","53733cbe504baff26518bab7478341d9eb81dcd884119fa409c655c686dd6b88","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":11371}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]