Skip to main content

GraphOneTimeUserOnboarder

GraphOneTimeUserOnboarder is the production Microsoft mailbox import worker. It consumes authorized Kafka commands and prepares the mailbox workspace. Start with Microsoft Graph setup.

Start a mailbox import​

Use the numbered Connect and provision one mailbox procedure. It requires an available Microsoft connector backed by a prepared tenant connection and actor permission mail.onboarding. Select your owned connected account before choosing Start onboarding or Set up mailbox.

The start handler does not require a pre-existing mailbox row or mailboxId. The worker verifies the Graph user against the authorized Entra subject and creates or updates the local mailbox. This is distinct from creating the deployment's first tenant connection before the connector button becomes available.

Responsibilities​

The worker resolves provider identity, creates or resumes checkpoints, reads folders and reference data, and imports message metadata. It writes body.html objects and updates newMails metadata. It exports raw.fts through Graph exportItems, parses attachments with FTS_Parser_Lib, and stores their files and metadata.

Production import requires Graph Application permission MailboxItem.Export.All and tenant administrator consent. Mail.Read or Mail.ReadWrite alone does not authorize exportItems. Export and FastTransfer attachment extraction are mandatory completion prerequisites. See Graph export permission setup.

After storage and indexing barriers pass, it assigns stable Kafka partition ownership. It releases held work, emits lifecycle states, and queues mailbox.onboarding.initializingDone. See the full sequence.

DependencyUse
Microsoft GraphFolder/message delta and mailbox export
KafkaCommands, lifecycle events, failures, final initialization operation
PostgreSQLMetadata, checkpoints, retries, and export state
S3Bodies, raw export objects, attachment files
FTS_Parser_LibAttachment extraction from FastTransfer bytes
DB_LibShared database context and models

Runtime selection​

The unified runtime selects this worker. Use the supported development lifecycle for that environment. Do not start a second standalone worker beside it.

For a separately prepared standalone development environment, the legacy launcher runs from mailGen/ECS_MovePST_To_TempSQL:

bash scripts/run-onetimedev.sh

The root resetDevServers.sh erases the selected complete instance, not just this worker. Use it only for an intentional full data reset with required backups. Do not run it beside another active complete stack.

Configuration reference​

GraphOneTimeUserOnboarder/.env.example lists standalone settings, but its Graph credential names are stale. The actual worker requires the BACKEND_* names below, including standalone execution. Root Compose passes these names through unchanged. Keep one credential source for that runtime.

VariableMeaning and formatRequired when
POSTGRES_CONNECTION_STRINGNpgsql string with host, port, database, username, and password. Use the database selected for this instanceEvery run
KAFKA_CLIENT_IDKafka client identityKafka consumption/publication
KAFKA_NETWORKSelected lan or tailscale networkKafka consumption/publication
KAFKA_LAN_BOOTSTRAP_SERVERS, KAFKA_TAILSCALE_BOOTSTRAP_SERVERSComma-separated host:port broker list for the selected networkKafka consumption/publication. All advertised brokers must be reachable
KAFKA_SECURITY_PROTOCOL, KAFKA_SASL_MECHANISMProtocol and authentication mechanismKafka connection
KAFKA_ADMIN_USERNAME, KAFKA_ADMIN_PASSWORD, KAFKA_APP_USERNAME, KAFKA_APP_PASSWORDSeparate cluster admin and app credentialsAuthenticated Kafka connection
BACKEND_TENANT_ID, BACKEND_CLIENT_ID, BACKEND_CLIENT_SECRETEntra tenant, app ID, and application credentialMicrosoft import
GRAPH_WEBHOOK_URL, GRAPH_LIFECYCLE_WEBHOOK_URLPublic HTTPS WebhookCatcher callbacksSubscription creation. Use this deployment's hostname
GRAPH_WEBHOOK_CLIENT_STATEStable random validation secretGraph subscriptions
S3_ENDPOINT, S3_REGION, S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET_EMAIL_BODIES, S3_FORCE_PATH_STYLEObject-store endpoint, region, credentials, bucket, and addressing mode. Local examples: http://127.0.0.1:8333, us-east-1, trueBody, raw-export, and attachment writes
OPENSEARCH_URL, OPENSEARCH_INDEX, OPENSEARCH_USERNAME, OPENSEARCH_PASSWORDEndpoint, target index, and credentials. Credentials can be absent when authentication is disabledIndexing
ONBOARDING_RETRY_*Per-step attempts, delays, and jitter in millisecondsOptional tuning. Consult the committed example for individual settings
ONBOARDING_REPLAY_RUN_ID, ONBOARDING_REPLAY_STEPExplicit run and checkpoint for authorized replayPlanned replay only. Leave unset otherwise

Implementation locations​

Paths are relative to the motherrepo:

PathContract
mailGen/ECS_MovePST_To_TempSQL/GraphOneTimeUserOnboarder/Configuration/OnboardingRuntimeOptions.csRequired runtime variable names
mailGen/ECS_MovePST_To_TempSQL/GraphOneTimeUserOnboarder/Processing/OnboardingPipeline.csCheckpoints, export barrier, lifecycle publication, final queue command
mailGen/ECS_MovePST_To_TempSQL/GraphOneTimeUserOnboarder/Services/GraphMailboxDumpService.csGraph metadata and export calls
mailGen/msmicroservices-architexture/src/services/GraphPullPoller/modules/graph-sync/graph-sync-scheduler.tsLater Graph synchronization scheduling
mailGen/msmicroservices-architexture/src/services/QueProcessor/modules/sync/apply-handler.tsOrdered application of fetched changes

Storage contract​

users/{providerMailboxUserId}/emails/{emailId}/body.html
users/{providerMailboxUserId}/emails/{emailId}/raw.fts
users/{providerMailboxUserId}/emails/{emailId}/attachments/{emailId}_|_{filename}

Current imports use the users/ layout. See storage reference for metadata and compatibility reads. The worker does not adopt destructive startup cleanup from GraphExportApiTester. Use import recovery for incomplete work.