Publishing apps to a Business Central Online by Powershell

Publishing apps to a Business Central Online by Powershell

#1 Kinds of Apps

There are 2 kinds of apps: AppSource Apps and Per Tenant Extensions (PTEs). These apps can be installed in two kinds of environments: Sandbox and Production.

In Production, AppSource Apps are installed in the global scope (Global) and Per Tenant Extensions are installed in the Tenant Scope (PTE). In Sandbox environments, you can also install apps to the development scope (Dev – like what VS Code does).

Example: Global, PTE, Dev

#2 Using “Publish-PerTenantExtensionApps” to Publishing PTEs to the Tenant Scope in a Production or Sandbox Environment

The easiest way to create a BcAuthContext is by issuing this command: $authContext = New-BcAuthContext –includeDeviceLogin – //TOKEN REQUEST

DEMO SCRIPT

#INSTALL APPS USING –includeDeviceLogin GET TOKEN
$authContext = New-BcAuthContext –includeDeviceLogin  #GET TOKEN
$environment = ‘Production’  #Production Env
$apps = ‘c:\temp\Apps\’

Publish-PerTenantExtensionApps -bcAuthContext $authContext
-environment $environment `
-appFiles $apps

Put sample APPS in this folder

Execute the Powershell script

TOKEN REQUEST BY GIVEN TEMPO AUTH CODE

Token retrieved, authorization granted

Apps Publishing and Installing..

Apps have been installed

#3 – To check if App is installed on Business Central Online

To check if the apps have been installed and which version has actually been installed, you can use the same script by running it without indicating the APP to be installed. The system extracts the list of all installed apps and their version.

2 thoughts on “Publishing apps to a Business Central Online by Powershell

  • 9 September 2022 at 5:25 PM
    Permalink

    Hi
    I have followed your instructions exactly however I am prompted for bcAuthContext

    Authenticated to common, using tenant id xxxxxxxx
    cmdlet Publish-PerTenantExtensionApps at command pipeline position 1
    Supply values for the following parameters:
    bcAuthContext:

    Why am I prompted for the parameters if I am providing them to the Publish-PerTenantExtensionApps function and if I need to provide them what am I supposed to enter in bcAuthContext:

    Thanks

    • 7 February 2023 at 5:07 PM
      Permalink

      Hi!
      I have the same issue 🙁
      If you resolved it somehow please let me know 🙂
      thanks, Sergey

Comments are closed.