MSBA-353 · Lesson 9 of 12 · 19 min
Per-tenant extensions and Marketplace apps
▶ Video coming soon A video version of this lesson is on the way.
Halfway through November, Noor realized she had written the same code three times. The lot best-before logic in CF Roastery, which warns when a wholesale shipment would leave with less than six weeks of freshness on a roast lot, was almost identical to code she had written for a tea blender and a small bakery supplier, both Quarrystone customers. Each copy lived in its own per-tenant extension, with its own bugs and its own upgrade history. Quarrystone's managing partner asked the obvious question: should this be one product, sold on Microsoft's marketplace, instead of three custom extensions? This lesson compares the two kinds of extension and the decisions that come with each. The catalog topic used to say "AppSource apps"; Microsoft now lists Business Central apps in the Microsoft Marketplace, and its documentation and the MB-820 outline use that name, while some tools, such as the AppSourceCop analyzer, keep the old one.
The layers of a Business Central environment
Every Business Central online environment is a stack of apps. At the bottom, the System Application provides platform-level modules that any app can use: Isolated Storage helpers, the AI module from lesson 4, upgrade tags, telemetry, email, retention policies and many more. Above it, the Base Application contains the business functionality: finance, sales, purchasing and inventory, with its tables, pages and posting routines. Microsoft also ships separate first-party apps, such as localization features, Shopify and the Sales Order Agent. Partner extensions sit on top, depending on the layers below. The MB-820 outline asks candidates to differentiate the base application and system applications, because knowing which one owns a feature tells a developer where to look for events and APIs.
Two kinds of partner extension
A per-tenant extension (PTE) is built for one customer and deployed only to that customer's environments. A Marketplace app is built once by a publisher, validated by Microsoft, listed in the Microsoft Marketplace, and installed by any customer who chooses it. Both are written in AL with the same tools, but almost everything around the code differs.
| Aspect | Per-tenant extension | Marketplace app |
|---|---|---|
| Audience | One customer | Any Business Central customer in the markets chosen |
| Object IDs | The customer range, 50,000 to 99,999 | A range registered to the publisher |
| Affixes | Recommended | Required, registered with Microsoft |
| Code analysis | PerTenantExtensionCop, CodeCop, UICop | AppSourceCop in addition, with breaking-change checks |
| Validation | None by Microsoft; the partner and customer decide | Technical and marketing validation before publishing |
| Deployment | Uploaded to each environment by an admin or pipeline | Installed by customers from the marketplace; updated by the publisher |
| Updates with Microsoft releases | Partner must keep it compatible; failures block the environment update | Validated against each version; publisher must keep it compatible |
| Business model | Paid as project work | Free, trial or paid, possibly through Microsoft's licensing |
The MB-820 outline also asks for the types of apps, including connect, add-on, library and dependency apps. An add-on app extends Business Central with AL code installed in the tenant, as both CF Roastery and a freshness app would. A connect app is an external service that integrates with Business Central through its APIs without installing AL code, such as a shipping platform that reads orders through the salesOrders API. A library app contains shared code with little or no user interface, used by other apps. A dependency app is any app that another app declares in its dependencies; a library is usually one, and so is a base app that several add-ons extend.
Corbel & Finch will run two per-tenant extensions from Quarrystone at go-live: CF Roastery, the integration extension built in this course, in object IDs 50000 to 50099, and Corbel & Finch Warranty, built in MSBA-352, AL Development for Business Central, in 50100 to 50149. Separate ranges and prefixes keep the two from colliding even though one partner writes both.
Deploying a per-tenant extension
During development, Noor published CF Roastery from Visual Studio Code to developer sandboxes, which installs it in a development scope meant for testing. That route is not allowed for production. A PTE reaches CONFIG and PROD in one of two ways: an administrator uploads the app file on the Extension Management page with the upload action, or a pipeline does the same through the automation API, as AL-Go's Publish To Environment does. When uploading, the administrator chooses whether the new version deploys now, with the current version, or when the environment moves to the next minor or next major version, which lets a version compiled against an upcoming release wait for it.
| Route | Where it is allowed | Use |
|---|---|---|
| Publish from Visual Studio Code | Sandboxes | Development and debugging |
| Upload in Extension Management | Sandboxes and production | Manual deployment by an administrator |
| Automation API from a pipeline | Sandboxes and production | Repeatable deployment from releases |
Each upload must have a higher version number than the installed one, unless it is the same version being republished in a sandbox. The extension's app ID identifies it across versions; changing it makes a different app with separate data, which is almost never what anyone wants. Microsoft also rules that a PTE and a Marketplace app cannot share an app ID, which becomes relevant if a PTE is later turned into a product.
Becoming a Marketplace publisher
Turning the freshness logic into a product starts with paperwork. Quarrystone needs a publisher account in Partner Center, the portal where Microsoft partners create offers for the commercial marketplace. It must register affixes, short prefixes or suffixes that it adds to every object and field name, so that its names never collide with Microsoft's or another publisher's; Quarrystone registered QFW for the freshness product. It must register an object ID range for its publisher. And it needs a code-signing certificate, because Marketplace app packages must be digitally signed.
With those in place, the app is developed under stricter rules. AppSourceCop is on in every build. Every table field has a data classification other than ToBeClassified. Permission sets cover every object so that users never need SUPER. Labels are translatable and translation files are included for each language offered. The app's application property in app.json sets the oldest Business Central version it supports, which also sets the range of versions Microsoft validates against.
Designing for many customers
A product cannot hard-code one customer's habits. CF Roastery's freshness code assumed roast lots, a six-week threshold and the BLEND and SINGLE ORIGIN categories. The product version, Quarrystone Freshness Window, needed settings instead: a setup table for default thresholds, per item category or item overrides, a choice of whether to warn or block, and a choice of which date on the lot to measure from. Customer-specific behavior, such as Corbel & Finch's extra rule for café transfers, stays in CF Roastery, which declares a dependency on the product and subscribes to its events.
codeunit 70450101 "QFW Freshness Check"
{
Access = Public;
procedure DaysOfFreshnessLeft(ItemNo: Code[20]; LotNo: Code[50]; ShipmentDate: Date): Integer
begin
// calculates from the lot's best-before or roast date per QFW setup
end;
[IntegrationEvent(false, false)]
procedure OnBeforeDecideAction(ItemNo: Code[20]; LotNo: Code[50]; DaysLeft: Integer; var Action: Enum "QFW Freshness Action"; var IsHandled: Boolean)
begin
end;
}Every public procedure, table field and event in a Marketplace app becomes a promise. Other partners may build on them, and AppSourceCop rejects a new version that removes or changes them without the obsolete process from lesson 6. Noor therefore marked most codeunits Access = Internal and kept the public surface small and documented: one setup API, two procedures and four events.
Licensing and entitlements
A Marketplace app can be free, offered with a free trial, or paid. Publishers can sell through their own contracts, or use Microsoft's marketplace licensing, where customers buy licenses for the app through Microsoft and the publisher maps the offer's plans to AL entitlement objects. Entitlements decide which permission sets a license grants, and the MB-820 outline asks candidates to create and manage entitlement and permission set objects, including overriding entitlements with inherent permissions for code that must run regardless of the user's license, such as reading the app's own setup. Quarrystone chose a simple paid subscription through its own contracts for the first year, and recorded marketplace licensing as a later option.
Worked problem
PTE or product?
Quarrystone has three customers wanting freshness warnings and expects perhaps ten more in two years. Building the product takes about six weeks more than maintaining three PTEs. What should guide the decision?
Show solution
- Maintenance: three PTEs mean three code bases, three upgrade paths and three sets of tests for every fix. One product means one.
- Microsoft releases: each PTE must be checked against every update; the product is checked once, by Quarrystone's pipeline and Microsoft's validation.
- Customization: customers' special rules can live in small PTEs that depend on the product and use its events.
- Cost: six extra weeks now, against repeated work for every new customer and every update.
- Commitment: a product needs a support process, documentation and a release schedule, which Quarrystone must staff.
Answer: Build the product, because the common logic is stable and the customer count is growing, and keep customer-specific rules in small dependent PTEs. The support commitment is the real cost and must be planned.
Installing and updating Marketplace apps
Customers find Marketplace apps in the Microsoft Marketplace or in Business Central's own Extension Marketplace page, and install them into an environment, usually after trying them in a sandbox. Business Central keeps installed Marketplace apps current: when the environment receives a major or minor update, the latest compatible versions of installed apps are applied, and administrators can also update apps from the admin center. Publishers can push urgent fixes as hotfixes to specific environments through the admin center API. Because a publisher's new version reaches many customers at once, release discipline matters even more than for a PTE: the pipeline, the tests and Microsoft's validation are the safety net.
Dependencies run one way. A PTE can depend on a Marketplace app, as CF Roastery will depend on Freshness Window. A Marketplace app cannot depend on a PTE, because the PTE does not exist in other tenants. And two Marketplace apps can depend on each other only in one direction, with the dependency also published and validated. Before installing Freshness Window in Corbel & Finch's environments, Noor will need to remove the old freshness code from CF Roastery in a new version, so the two never warn twice.
Who owns the code
A per-tenant extension raises a question that customers often forget to ask: who owns it? Corbel & Finch pays for CF Roastery, but the code was written by Quarrystone's staff. The services agreement Bettina signed in September says that Corbel & Finch owns the extension built for it and receives the source in its own GitHub organization at the end of the project, while Quarrystone keeps the right to reuse general techniques. That clause mattered once the freshness product appeared: the generic freshness logic became Quarrystone's product, built fresh in its own repository, and CF Roastery will depend on it rather than contain it. Clear ownership also decides who can grant access to the repository, who pays for the Azure resources the extension uses and who may take over support if the partner relationship changes.
Visibility of per-tenant extensions
A PTE is installed per environment. Uploading it to PROD does not make it appear in CONFIG or TRAINING; each environment receives it separately, which is why the pipeline deploys to each environment named in its settings. Within an environment, an installed extension is available to all companies, so setup that differs by company belongs in company-scoped tables. When a sandbox is created as a copy of PROD, the copy includes the installed PTEs at their current versions, which is what makes copies useful for reproducing problems.
| Situation | What happens to CF Roastery |
|---|---|
| New sandbox created empty | Not installed; deploy it if needed |
| Sandbox created as a copy of PROD | Copied with PROD's version and data |
| New company created in PROD | Available at once; install code runs per company |
| Microsoft major update of PROD | Recompiled and upgraded; must be compatible |
Microsoft treats a PTE that breaks an update seriously but practically: the environment's update can be postponed while the partner fixes the extension, and administrators and partners receive notifications. For that reason Noor added the notification recipients for each Corbel & Finch environment in the admin center to include Quarrystone's support mailbox, alongside Callum.
Common mistakes
MistakePublishing a PTE to production from Visual Studio Code.
InsteadUpload it in Extension Management or deploy through the automation API.
MistakeChanging an app ID to "start fresh".
InsteadKeep the app ID; a new ID makes a separate app with separate data.
MistakeMaking most of a Marketplace app Public.
InsteadKeep the public surface small; everything public becomes a compatibility promise.
MistakePutting customer-specific rules in the product.
InsteadExpose events and settings; keep customer rules in dependent PTEs.
MistakeAssuming a Marketplace app can depend on a PTE.
InsteadDependencies run from PTE to Marketplace app, not the reverse.
Summary and key terms
- Environments stack the platform, System Application, Base Application, Microsoft apps and partner extensions.
- Per-tenant extensions serve one customer in the 50,000 to 99,999 range; Marketplace apps serve many with registered ranges and affixes.
- App types include add-on, connect, library and dependency apps.
- PTEs reach production by upload in Extension Management or the automation API, not from Visual Studio Code.
- Marketplace apps need a Partner Center account, registered affixes and ID range, signing, AppSourceCop and validation.
- Products keep a small public surface with events so customers' PTEs can extend them.
- Per-tenant extension
- An extension built for and deployed to one customer's environments.
- Marketplace app
- An extension published by a partner in the Microsoft Marketplace for any customer.
- Affix
- A registered prefix or suffix added to object and field names to avoid collisions.
- System Application
- Microsoft's layer of platform-level modules used by other apps.
- Base Application
- Microsoft's app containing Business Central's business functionality.
- Connect app
- An external service that integrates through Business Central APIs without installing AL code.
- Entitlement
- An object that maps a license or plan to the permissions it grants.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why can CF Roastery depend on Freshness Window but not the other way round?
Show answer
A Marketplace app must work in every tenant, and a PTE exists only in one.
What does the deploy-to choice in the upload dialog allow?
Show answer
Deploying the version now, or holding it until the environment moves to the next minor or major version.
Which three registrations does a new Marketplace publisher need before submitting?
Show answer
A Partner Center publisher account, registered affixes and a registered object ID range, plus a code-signing certificate for the package.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.