Running the service
Tenants
The Microsoft 365 tenants this deployment publishes into, and the credential each one is reached with.
A tenant is one Microsoft 365 organisation — one Entra directory — together with the app registration ContactMesh signs into it with. Everything else in the product hangs off one: source lists, publications, recipients, delivered contacts, queued work. The tenant selector in the top bar filters every other screen to a single tenant. Under All tenants each list that mixes tenants names the tenant of each row, and the search in the top bar ends each result’s second line with it.
Table or Cards at the top of the page shows the same tenants as rows or as a card each: its name at the
top, the columns you show as its facts, its buttons at the foot. The choice is in the address, as layout=cards, and
this browser opens the page in the one last chosen.
Storing the credential per tenant rather than in the deployment environment is what makes a second tenant possible at all. An app registration belongs to one directory, so the registration configured for this deployment can only ever be used by the directory it was registered in. A tenant without a usable credential of its own is not synced. It is never reached with somebody else’s.
Each tenant has a page of its own, #/tenants/{id}: the row’s name opens it, and so does Open at
the row’s end. Its header holds Refresh directory, Disable or Enable, and, once it is
disabled, Remove under …. Under it, a tab each: Facts — everything the row cuts to a line,
whether it signs in, its credential, its marker check, what it holds and its Graph requests today, with
the source lists and publications it owns, each linked — then Settings, Sign-in (its
credential), Exchange (its Exchange scope and its setup check), Deletion
guard, Directory, and Setup, the Microsoft 365 guide with its identifiers filled in. A link
may open one tab: ?tab=settings, sign-in, exchange, guard, directory or setup; an older
?section=settings, guard, credential or setup opens its tab, and the old address of the edit
dialog, #/tenants?edit=<id>, leads to the page.
Reading the list and the page needs any role. Adding, changing, disabling and removing need Admin —
every mutating route under /api/v1/tenants is Admin-gated on the server, so a Viewer or an Operator
sees the page with every control refused and the role it needs said on it, rather than buttons the API
will refuse. Refreshing the directory is an Operator’s.
What has to be true in Microsoft 365 first
Section titled “What has to be true in Microsoft 365 first”A tenant’s Setup tab holds the sequence, in three tabs of its own — 1. Entra app registration, 2. Exchange RBAC and 3. Verify — with this tenant’s identifiers substituted where they are knowable. Setup, under Tenants in the navigation, opens it for the tenant selected at the top, or the only one there is; under All tenants with several it lists them rather than guessing which tenant somebody meant, each opening its own. A row’s Setup, in its ”…” menu, opens it too, and For tenant above the guide switches to another tenant’s.
What the commands carry: the tenant’s client ID and directory ID, its mailbox sources’ mailboxes in the
source scope, and whatever its Exchange scope holds — the service principal in
New-ServicePrincipal, every role assignment and Test-ServicePrincipalAuthorization, the group or the
attribute and its value in the destination scope. A value nothing stores stays a placeholder, marked on
the page so it stands out among the filled ones; the mailbox to test against is always one.
Three stages, done in three different places and in this order: the Entra app registration and its
consented permissions, the Exchange RBAC assignment that scopes contact access to named mailboxes, and
a verification step. None of it is something the running service can do on an administrator’s behalf —
the Sync Service is deliberately denied Exchange.ManageAsAppV2, because a synchronisation container
able to widen its own mailbox boundary does not have one.
The guide’s one warning worth repeating here: do not grant a Contacts permission in Entra. Entra grants
are directory-wide and Exchange RBAC grants are scoped, and the two are additive — so adding
Contacts.ReadWrite in Entra does not widen the RBAC scopes, it deletes them. Nothing in the product
can detect that, because from Graph’s side the calls simply succeed.
RBAC and group membership are eventually consistent on a scale of hours. A correct command that has not taken effect yet is the commonest “it does not work”, and it is not a fault.
Adding one
Section titled “Adding one”A name and the directory (tenant) ID. That is the whole row. The directory ID has to be unique across the deployment: a second tenant on the same one is refused.
Add tenant, on the Tenants page or under Tenants in the navigation, is five steps. Tenant asks for those two, and Create and continue creates it. App registration and Exchange RBAC are the guide’s first two stages with the new tenant’s identifiers filled in, and Sign-in is its credential: a credential needs a row to hang off, so it is set after the tenant. Verify ends on Test sign-in, Check markers and the setup check. The address keeps the tenant, so a reload resumes the steps, and whatever is left when they are left is finished on its Setup tab. Creating a tenant verifies nothing — no token is acquired, no directory is contacted. A new tenant is a label until a credential is stored and proved.
Two defaults are deliberate, and both are the cautious side:
- Plan mode is on. Nothing is written to any mailbox until somebody turns it off. The server defaults it the same way Add tenant does, so a tenant created by a script starts held too.
- Keep deleted contacts is on. Removals go to the lost and found.
Changing the directory ID later throws away everything proved about the old one: the verified timestamp, the last error and its code are cleared, and the credential version is bumped so every process rebuilds its cached application. Moving a tenant to a different directory can also turn an inherited credential into one that does not belong to it.
The three kinds of credential
Section titled “The three kinds of credential”| Kind | What is stored | When it expires |
|---|---|---|
| Inherited | Nothing — the deployment configuration’s registration, which the containers were started with | The mounted certificate’s own date, shown with a Deployment prefix |
| Client secret | The secret, encrypted | Only if somebody typed the date in |
| Certificate | The PKCS#12 bundle and its passphrase, encrypted | Read from the certificate |
Inheriting is refused when the deployment’s configured application belongs to a different directory. It is refused at the moment of saving rather than stored and left to fail at every sync — a tenant that looks configured and never works is the worse outcome.
A client secret’s expiry is in no token response. Microsoft tells the product nothing about it until the day it starts refusing, so the one moment anybody knows the date is when they copy the secret out of Entra. Typing it in is what earns the tenant the same warning a certificate already gets: the cell turns amber 42 days out and red at 14, and the PRTG sensor alarms on the same two numbers.
Nothing here ever reads a stored secret back out. There is no endpoint that returns one, which is why a credential write replaces the whole thing rather than patching part of it.
Generating the certificate here
Section titled “Generating the certificate here”The better path, and the first control in the Certificate section. ContactMesh creates the key pair on the server: the private half goes straight into the encrypted credential column and is never shown, downloaded or logged, and what the administrator downloads is the public half for the Entra app registration — the part that is not a secret. Validity is 12, 24, 36 or 60 months; the server clamps anything else to between 3 and 60. The certificate is self-signed because Entra matches the thumbprint of what was uploaded and does not check a chain.
Replacing a certificate that is currently signing in takes two presses. The old private key is gone the moment the new row is written, and Entra will not accept the new one until its public half has been uploaded — sync stops for that tenant in between. The first press says so; the second does it.
An uploaded bundle is checked before it is stored: it must be readable as PKCS#12 with the password given, it must carry a private key, and it must not already have expired. Each of those is the same authentication error hours later if it is not caught here.
Proving it works
Section titled “Proving it works”Two buttons, because they answer two different questions, and one tenant answered yes to the first and no to the second for weeks. Both are on the tenant’s Sign-in tab, and under 3. Verify on its Setup tab.
Test sign-in acquires a token and reads one page of the directory. A bare token would prove the secret is current and say nothing about whether the application has admin consent — and consent is the half that is usually missing. Passing stamps the verified time and clears the failure columns. Failing records Microsoft’s own error code and message and deliberately leaves the previous verified time alone, so the row can say worked at 09:00, refused since 11:20. That is the difference between an expired secret and a tenant nobody finished configuring. With the demo Graph in use the button answers Simulated and contacts nothing.
An application not authorised in this tenant’s directory is nearly always a registration made in the wrong tenant: the app registration lives in one directory and the tenant ID names another. Check the ID against the directory the registration is in before replacing anything.
Check markers asks whether this directory gives back the markers ContactMesh writes. It creates a throwaway folder in one destination mailbox, writes a contact, reads it back both by listing the folder and by searching for the marker, then deletes the folder with what it made inside. Adoption, duplicate detection, the unmanaged-contact guard and lost-mapping recovery all reduce to that round trip. It needs a destination mailbox to probe, so a tenant with no recipients yet cannot run it.
The provenance answer goes stale after seven days, and immediately when the credential changes. Stale is still verified, but the gates it opens are closed until it is run again. A check that plan mode or a switched-off tenant refused proves nothing, so it goes stale once plan mode is off or the tenant is on again, and the next reconciliation runs it.
Nothing re-proves a credential on a schedule. An idle tenant makes no Graph calls and therefore mints no tokens, so Not confirmed is an absence of evidence rather than a failure. The sign-in column is not only about the button, though: every real token acquisition the sync makes records its outcome on the row, so a working tenant proves itself by working. Where no token has been recorded, a passed marker check or a read of one of its Microsoft 365 source lists counts as well, provided it happened after the credential last changed: the column then reads Signs in, with Confirmed by the marker check or Confirmed by a source list read and the date. A file or database source signs in to nothing, so its reads do not count.
Refresh directory is the third button, in the tenant’s page header, on its Directory tab and in the row’s ”…” menu. It pulls this tenant’s groups and people into the local cache the audience pickers search. Without it the pickers only know what somebody has already searched for, and a group nobody has typed the name of is unfindable. It reads the row’s own tenant, in the worker, and the verb reads Waiting for the worker… and Checking… until it has.
The setup check
Section titled “The setup check”Setup check, on the tenant’s Exchange tab and under 3. Verify on its Setup tab, runs
every part of the setup above in the order it is done and says which one is wrong. Run check is an
Admin’s, as Check markers is, because it runs it; the last answer stays on the page, with its age and
who ran it, for anybody who can read the tenant.
Scoped by says how the Exchange scope picks its mailboxes, as the setup guide builds it: Group or
Mailbox attribute. Group names the mail-enabled security group a scope by group is built on. Two of
the checks need it. Both start at the tenant’s Exchange scope, and at the last
run’s where none is stored; a run asked through the API with neither asks about the stored one. A link
may land on the section: ?section=setup.
When the last run used a scope or a group the tenant does not hold, or its token named a service
principal the tenant does not hold, Save scope stores them on the tenant, for the guide’s commands.
The service principal comes from the oid claim of the token the check signs in with, which for an
application is its service principal’s object ID — the same value as Object ID on the enterprise
application’s page.
One row per check, each with its status — Passed, Warning, Failed, Not run — what it found in a line, and the remedy: the place that fixes it, or the PowerShell with this tenant’s names filled in.
| Check | What it verifies | What it cannot |
|---|---|---|
| Credential | The tenant is switched on and has a credential, the credential has not expired — a warning in its last 30 days — and Entra issues a token for it | A client secret’s expiry, unless somebody typed the date in |
| Permissions | The Microsoft Graph application permissions in that token: User.Read.All and GroupMember.Read.All, OrgContact.Read.All where a directory source reads organisational contacts, and Sites.Selected where a SharePoint source reads a list. A missing one fails; one beyond them warns, a tenant-wide Contacts.* or Calendars.* grant above all, and Sites.Read.All in place of Sites.Selected | The Exchange RBAC roles, which are not in a Graph token. Member.Read.Hidden is never flagged, because nothing here can tell whether a group needs it |
| Directory | A page of users and a page of groups can be read | — |
| Groups | The group exists, is mail-enabled — Exchange cannot scope by a group it cannot see — and is a security group; no source mailbox is in it; every recipient is a direct member, and each one who is not is named in the command that adds them | Whether the Exchange scope is actually built on this group, which only Exchange can say |
| RBAC scope | A mailbox outside the group refuses a read of its contact folders: an enabled member account that is neither a recipient nor a source mailbox, read, never written to. One that lets the read in means the scope is not in force, most often because of a tenant-wide Contacts.ReadWrite grant | Not run when no such mailbox answers either way; a user without a mailbox proves nothing |
| Groups, by mailbox attribute | What the sync found: a recipient whose mailbox Exchange refused is outside the scope, and is named in a Get-Mailbox line that shows its custom attributes; how many recipients have taken a write. Not run while nobody has | Which mailboxes carry the attribute: Exchange evaluates the scope’s filter, and reading it needs Exchange.ManageAsAppV2, which ContactMesh does not hold. A recipient nothing has written to is not known either way |
| RBAC scope, by mailbox attribute | A mailbox that receives nothing, read until one refuses: one refusal shows the scope narrower than the tenant. Readable ones may carry the attribute, so only every one readable is a warning, with the Test-ServicePrincipalAuthorization line that tells which | Whether a readable mailbox carries the attribute or the scope reaches the whole tenant |
| Mailbox access | Each mailbox source’s permission probe, booked for the worker as Run probe books it and read back as it answers, one row per source | Not booked without a worker answering, or for somebody without sources.run in the tenant |
| SharePoint site | Each SharePoint source’s list, read as its round reads it, one row per source and only where there is one. Graph refusing it fails with the New-MgSitePermission line that grants read on that site, its id and the application’s client id filled in | Whether the grant is read and no more: Graph does not say what else the application could do on the site |
| Markers | The marker round trip, as Check markers runs it | — |
The two checks that write — the permission probe and the marker round trip — are not run while the tenant is in plan mode or the deployment is paused, and their rows say so. Everything else reads, and runs through both. On the demo Graph the section reads Demo: what the fake answers proves nothing about a tenant.
The last check is kept for as long as finished work is, because its findings name people. Each run is in the audit trail, with how many checks failed, warned and were not run.
Its Exchange scope
Section titled “Its Exchange scope”How the tenant’s Exchange scope is built, on the tenant’s Exchange tab above the setup check, saved
together. ContactMesh cannot read any of it: the scope, its filter and the service principal pointer are
Exchange’s, and reading them needs Exchange.ManageAsAppV2, which it does not hold. So each is typed
here or stored from a setup check, and none is ever asked of Exchange. Every one is optional; what is
stored fills the setup guide’s commands and the setup
check’s remedies, and is the scope a check asks about by default. ?tab=exchange lands here.
| Field | What it holds |
|---|---|
| Scoped by | Group or Mailbox attribute, as the destination scope picks its mailboxes; empty when not told |
| Group | The object ID of the mail-enabled security group a scope by group is built on, named beside the box as the tenant’s copy of its directory has it from Graph. Found by its address in the guide’s Get-Group line where the copy has one |
| Attribute, Value | For a scope by mailbox attribute: one of CustomAttribute1 to CustomAttribute15, and the value it carries on every mailbox the scope admits, at most 1,024 characters. A remedy then sets it with Set-Mailbox on a refused recipient |
| Service principal | The object ID of the app’s enterprise application in this directory: Entra admin centre → Enterprise applications → the app → Object ID. Not the Application ID, and not the Object ID under App registrations, which is a different value |
The group and the service principal are GUIDs, and anything else is refused. Each save is in the audit trail, before and after.
Its settings
Section titled “Its settings”On the tenant’s page, a tab each: Settings, saved together, and Deletion guard, with a switch of its own; the Exchange scope is on Exchange. Each row’s “i” says what it decides. Settings for the whole deployment are on Settings.
| Setting | What it decides |
|---|---|
| Display name, Entra tenant ID | What the tenant is called here, and which directory it is |
| Status | Enabled or disabled; see Disabling below |
| Recipients per hour | This tenant’s own ceiling. Empty inherits the deployment’s |
| Plan mode | Read, compare and report; write nothing to any mailbox |
| Keep deleted contacts | Whether removals are written to the lost and found first |
| Renamed folders | Whether a whole-folder removal when offboarding proceeds after a recipient has renamed the folder |
| Report retention | Days a closed report from the tenant’s phones is kept: a year unless changed, from 30 days to ten years |
| Phone region | The country a phone number without a country code is read in when a publication writes its numbers in one format: Switzerland unless changed. See the number format |
| Deletion guard | Whether a removal waits for approval at all, and from how large |
Recipients per hour composes with the deployment rate rather than replacing it: a tenant can be slower than the deployment, never faster. Both brakes are counted separately and either one holds a recipient, so a tenant with no ceiling of its own can still be held by a deployment rate spent on somebody else’s work. Empty means no opinion; zero on the deployment row means unlimited, which is why the two are kept apart. Set it when one tenant’s first activation would otherwise consume the whole allowance.
Plan mode is refused at the Graph client, so it holds for every path alike: scheduled reconciliation, the provenance self-check, the mailbox probe and batched writes. Reads are untouched, so comparison, drift detection and the staged plan all still work. Turning it back off releases the work that was held while it was on — that work is held rather than dead-lettered precisely so pressing the stop button does not cost a rebuild. The Mode column reads Plan mode while it is on and Writing otherwise, and sorting it brings the held tenants to the top; the shell says so on every screen as well.
Keep deleted contacts off means a removed contact has no remaining copy anywhere. While it is off it reads Not kept, and it stands as a fault until it is back on. Removing a whole folder archives its contents regardless of this switch.
Renamed folders decides whether offboarding deletes a folder a recipient has renamed, and is Keep by default. A rename is a recipient saying something, and the name is the only human evidence the folder is still the one that was meant — ContactMesh records the folder’s ID, which a rename does not change, so deleting it anyway is possible rather than necessary. Keep leaves the folder in the mailbox and records why.
Deletion guard is the tenant’s brake on removals: a switch, and three numbers. A removal of up to Floor contacts from one folder goes ahead. A larger one waits for approval when it is over Share per cent of the folder or over Ceiling contacts; either is enough to hold it, so switching one test off leaves the other. A share of 0 holds every removal above the floor; a share of 100 switches the share test off, and a ceiling of 0 the ceiling test. A removal that would empty a source list, or a folder ContactMesh did not create, waits whatever the numbers say, and with the switch off as well.
The switch beside the guard’s title turns the numbers off. Off, no removal from this tenant waits for anybody because of its size, and a set held while it was on goes through with the next pass — except those two, which wait until somebody approves them, however many passes run. A source list’s pictures keep the first of them: with the switch off, a read that would take every picture the list has leaves them where they are, and switching on lets the numbers decide. Switching it off asks first, in one sentence; switching it on does not, and it acts when it is turned rather than waiting for a Save. The three numbers keep their values for when it is on again, and show as facts while it is off.
Share 100 and Ceiling 0 together let every removal through as well, short of an emptied list or a folder ContactMesh did not create. Either way the tenant reads Guard off in its row’s Mode column and in its page’s header, and the bell counts it among the tenants whose deletion guard is off, opening its page, until it holds again — so nobody can switch it off unnoticed. Each change to the switch and the numbers is in the audit trail, before and after.
Disabling
Section titled “Disabling”Disable, on the tenant’s page or in the row’s ”…” menu, does two things: the tenant stops being reachable, and every source list it owns is disabled, which holds delivery from it (see Disabling one). Contacts already delivered stay exactly where they are — nothing is removed from anybody’s mailbox. The Status and Sign-in columns both read Disabled rather than red, because a deliberate pause is not a breakage.
Re-enabling is Enable, on the page or in the row’s ”…” menu, or the Status switch in its settings turned from Disabled to Enabled. Either way it brings the tenant back and does not switch on the source lists that Disable switched off; each one is switched on again on its own, from Source lists.
A tenant must be disabled before it can be removed.
Removing permanently
Section titled “Removing permanently”Only offered once the tenant is disabled, and it asks for the tenant’s name to be typed back exactly. The mistake that catches is not meant to keep it — it is removing the one that was open rather than the one that was meant.
It is refused while the tenant still owns source lists, publications, folders, delivered contacts or queued operations, and the refusal names the counts.
What removal actually destroys is small: the tenant row, the two caches of Entra — the copied users and the copied groups — and the tenant’s field sets, which no publication can be using by then. The caches rebuild from the next directory refresh. Audit events are kept; they carry a nullable tenant ID and no foreign key, and once the row is gone they are the only remaining record that the tenant ever existed.
The refusals are doing real work. The configuration — source lists, publications, field sets, the copied users and groups — holds a key to its tenant, so the database itself refuses to remove a tenant from under it. The queue, the folders and the delivered contacts hold none, and PostgreSQL would delete the row happily and leave them pointing at nothing:
- The queue would never drain. Work is claimed on status, not on tenant, so the removed tenant’s items keep being claimed, fail at credential resolution, and retry to exhaustion. Dead letters are never pruned, and one dead letter puts the whole deployment into Warning permanently.
- The mailboxes would keep the contacts. Every delivered card carries a marker composed from its source list’s ID. Delete the source list and each marker points at nothing: the card cannot be matched, adopted or swept, so removing a tenant and adding it again leaves a permanent duplicate of every contact in every recipient’s folder.
Emptying a live tenant is therefore a drain rather than a button. Disable it, let offboarding remove the contacts, delete the source lists, then remove the tenant.