Orchardcore content transfer

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore content transfer is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for bulk content import and export in Orchard Core with CrestApps Content Transfer. Covers CSV and Excel formats, the OpenXml and Azure Blob Storage features, ContentImportOptions, BackgroundWork pacing, Redis locks, per-type permissions, the stalled-row watchdog, queued exports, telemetry, im

How to use this skill

Skill file

CrestApps Content Transfer

Configure bulk import and export

You are an Orchard Core expert. CrestApps Content Transfer bulk imports and exports content items through pluggable file formats. The base feature supports CSV; OpenXml adds .xlsx; Azure Blob Storage keeps the transfer files in a shared container for scaled-out sites.

Guidelines

Feature overview

| Feature ID | Purpose |

|---|---|

| CrestApps.OrchardCore.ContentTransfer | CSV import and export, Content > Import and Content > Export, background processing |

| CrestApps.OrchardCore.ContentTransfer.OpenXml | Excel .xlsx reader and writer |

| CrestApps.OrchardCore.ContentTransfer.Azure | Stores import and export files in Azure Blob Storage |

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.ContentTransfer",
        "CrestApps.OrchardCore.ContentTransfer.OpenXml"
      ],
      "disable": []
    }
  ]
}

Permissions

ContentTransferPermissions (namespace CrestApps.OrchardCore.ContentTransfer) declares descriptions with LocalizationSource. The four non-typed permissions go to Administrator by default.

| Permission | Grants |

|---|---|

| ListContentTransferEntries | Content > Import menu and the Bulk Import list |

| DeleteContentTransferEntries | Deleting entries (implies list) |

| ImportContentFromFile | Importing any type, templates, error files, pause and resume |

| ImportContentFromFile_{ContentType} | The same for one type (implied by ImportContentFromFile) |

| Target's own permission | Importing into a non-content import target (IContentTransferImportTarget.AuthorizeAsync); ImportContentFromFile does not grant it |

| ExportContentFromFile | Content > Export menu and exporting any type |

| ExportContentFromFile_{ContentType} | The same for one type (implied by ExportContentFromFile) |

Build a typed permission with ContentTransferPermissions.CreateDynamicPermission(ContentTransferPermissions.ImportContentFromFileOfType, "Product").

Import processing

  1. An upload is stored through IContentTransferFileStore as a Pending ContentTransferEntry and processing starts immediately. The Imported Files Processor background task (ImportFilesBackgroundTask, schedule * * * * *, every minute) picks up pending entries and resumes imports a restart interrupted or that stalled. Every run, including one started from the admin, is linked to the host stopping, so a shutdown does not mark the import failed.
  2. One run works on an import at a time under a lock named after the entry. The lock lasts 30 minutes, so a run reads rows for at most 15 minutes, saves progress after the batch in flight, and the import continues under a fresh lock.
  3. A watchdog names any row slower than a minute in a warning, abandons a row still running after 10 minutes or a run past 28 minutes (releasing the lock), and skips a row that stops two runs, listing it in the error file. An abandoned run cannot save progress later.
  4. A run that fails with an unexpected error (for example a database timeout) does not fail the import: the same run retries it after a pause growing from 15 seconds to two minutes, up to five times, then leaves it to the next scheduled run. The import is marked Failed only after the same row failed three runs in a row with no progress between them.
  5. Statuses: Pending, Processing, Paused, Deleting, Completed, Completed with errors, Failed. A Processing entry with no saved progress for 10 minutes is stalled; Resume import continues paused, failed, pending and stalled imports from the last saved batch, and reports when a run is still working.
  6. Deleting an entry removes it and its file in the background; it never deletes imported content.
  7. An export a stopping host interrupted is not stored as completed with a partial file; it starts over on the next run. A notification that cannot be sent no longer marks a completed export as failed.

ContentTransferEntry documents are indexed by ContentTransferEntryIndex, declared .ExclusiveToDocumentType().SingleRecordPerDocument().

The admin lists use Orchard Core's AdminList standard (List or Grid layout, filters in the toolbar); see the framework orchardcore-admin-lists skill for customizing rows.

Configuration

All values are read from the tenant shell configuration (OrchardCore:CrestApps:ContentTransfer in the root appsettings.json, or CrestApps:ContentTransfer in App_Data/Sites/{Tenant}/appsettings.json). Restart the tenant after changing them.

{
  "OrchardCore": {
    "CrestApps": {
      "ContentTransfer": {
        "ImportBatchSize": 100,
        "ExportBatchSize": 200,
        "ExportQueueThreshold": 500,
        "MaxUploadFileSize": 1073741824,
        "MaxUploadChunkSize": 26214400,
        "TemporaryFileLifetime": "01:00:00"
      },
      "BackgroundWork": {
        "Pacing": {
          "DatabaseShare": 0.25,
          "MaxPause": "00:00:30"
        }
      }
    }
  }
}

| ContentImportOptions | Default | Meaning |

|---|---|---|

| ImportBatchSize | 100 | Rows per import batch |

| ExportBatchSize | 200 | Items per export batch |

| ExportQueueThreshold | 500 | Item count above which an export is queued |

| MaxUploadFileSize | 1 GB | Total upload size in bytes (64-bit, can exceed 1 GB); 0 disables the check |

| MaxUploadChunkSize | 25 MB | Chunk size per request; 0 disables chunking |

| TemporaryFileLifetime | 1 hour | Retention of unfinished chunked uploads |

BackgroundWorkPacingOptions (CrestApps:BackgroundWork:Pacing) paces imports and Local DNC list work: after each batch the job pauses in proportion to how long the batch took. DatabaseShare (0.05 to 1, 1 disables pacing) and MaxPause cap it. Batches from all tenants take turns on one in-memory gate per instance; a batch waiting more than five minutes runs anyway.

Environment variable form: OrchardCore__CrestApps__ContentTransfer__MaxUploadFileSize=5368709120.

Hosting and proxy limits

The module raises the Kestrel request-body limit for the import endpoint to one chunk plus overhead. Two layers enforce limits before the app runs, and the default 25 MB chunk stays below both:

With chunking disabled every layer must accept the whole file in one request.

Scaled-out sites and Azure Blob Storage

Files default to App_Data/Sites/{tenant}/Temp on local disk, which other instances cannot read and containers lose on restart. Enable CrestApps.OrchardCore.ContentTransfer.Azure and configure CrestApps:ContentTransfer:AzureBlobStorage:

{
  "OrchardCore": {
    "CrestApps": {
      "ContentTransfer": {
        "AzureBlobStorage": {
          "ConnectionString": "",
          "ContainerName": "content-transfer-{{ ShellSettings.Name }}",
          "BasePath": "",
          "CreateContainer": true,
          "RemoveContainer": true
        }
      }
    }
  }
}

Also enable OrchardCore.Redis.Lock so two instances never import the same file, and keep session affinity (or point OrchardCore:TempDirectory:Path at a shared mount) so all chunks of an upload reach one instance.

Telemetry

The module emits OpenTelemetry traces and metrics on the meter and activity source CrestApps.OrchardCore.ContentTransfer (ContentTransferDiagnostics, namespace CrestApps.OrchardCore.ContentTransfer.Telemetry). Instruments are named crestapps.contenttransfer.* (for example import.duration, import.rows, import.rows.skipped, import.stalled_rows, upload.size, export.duration, export.rows) and carry bounded tags such as content_type, format, outcome and reason; ids, file names and row data go on spans and logs only. A row filter's SkipReasonCode (snake_case, never localized) labels skipped rows. Subscribe with the CrestApps.OrchardCore.* source wildcard.

Import targets and multi-type rows

Extend the pipeline

IContentImportManager.GetColumnsAsync() gathers columns from registered handlers, the selected IContentTransferFileFormatProvider reads or writes the file, and handlers map rows. Read references/extensibility.md for complete examples.

| Extension point | Use it for | Registration |

|---|---|---|

| IContentImportHandler | Content-item-level columns (GetColumnsAsync, ImportAsync, ExportAsync) | services.AddScoped<IContentImportHandler, T>() |

| IContentPartImportHandler | Columns owned by a part | services.AddContentPartImportHandler<TPart, THandler>() |

| StandardFieldImportHandler / IContentFieldImportHandler | Columns of a field ({Part}_{Field}_{Property}) | services.AddContentFieldImportHandler<TField, THandler>() |

| IContentImportRowFilter | Skip rows before mapping (InitializeAsync, PrepareBatchAsync, ShouldSkipRowAsync) | services.AddScoped<IContentImportRowFilter, T>() |

| IContentTransferFileReaderTransformer | Read another system's layout (for example Shopify product exports) | services.AddScoped<IContentTransferFileReaderTransformer, T>() |

| IContentTransferFileFormatProvider | Another file format | services.AddSingleton<IContentTransferFileFormatProvider, T>() |

| IDisplayDriver<ExportRequest> | Extra options on the export form | services.AddScoped<IDisplayDriver<ExportRequest>, T>() |

| IContentExportBatchHandler | Preload data for a page of exported items | Forward from the same scoped handler instance |

| IContentTransferNotificationHandler | Notify when a queued export completes | services.AddScoped<IContentTransferNotificationHandler, T>() |

| IContentTransferRecordImporter | Import records that are not content items | services.AddContentTransferImportTarget<T>() in a startup with [RequireFeatures(ContentTransferConstants.Feature.ModuleId)] |

| IContentImportRowTypeProvider | Rows of several related content types in one file | services.AddSingleton<IContentImportRowTypeProvider, T>() |

AddContentPartImportHandler and AddContentFieldImportHandler live in namespace CrestApps.OrchardCore.ContentTransfer; StandardFieldImportHandler in CrestApps.OrchardCore.ContentTransfer.Handlers. Built-in handlers cover TitlePart, HtmlBodyPart, MarkdownBodyPart, common fields and taxonomy fields ({Part}_{Field}_Terms by name, or {Part}_{Field}_TermContentItemIds).

Omnichannel Management contributes contact-specific import options (duplicate phone filtering, lead country, DNC checks) and an export CRM last activity section; see the orchardcore-omnichannel-management skill.

Upgrading from 2.x

Troubleshooting

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.