Categories
DevOps HOW TO Microsoft PowerShell

Automated Releases on Environments with Application Family different of Business Central

The following PowerShell script is useful to automate the deployment of extensions, topically via DevOps Release Pipelines in the scenario of an Environment with Application Family different of Business Central, hosted in tenants not managed by Microsoft.
This script installs the BcContainerHelper, imports its module as it uses the function Publish-PerTenantExtensionApps. The apiBaseUrl environment variable is changed with the one of the ISV (in this example, lscentral of LS Retail).

Write-Host "Installing BcContainerHelper"
Install-Module BcContainerHelper -Force -AllowPrerelease
Import-Module BcContainerHelper -DisableNameChecking

$bcContainerHelperConfig.apiBaseUrl = "https://lscentral.api.bc.dynamics.com"

$bcauthContext = New-BcAuthContext -clientID $(PublisherAppClientID)" -clientSecret $(PublisherAppClientSecret)" -tenantID "$(TenantId)" -scopes "https://api.businesscentral.dynamics.com/.default"

Write-Host "Publishing to tenant"
Publish-PerTenantExtensionApps -useNewLine -bcauthContext $bcauthContext -environment "$(Environment)" -companyName "$(CompanyName)"-appFiles @(Get-Item "Artifacts/output/Apps/*.app" | % { $_.FullName })

PublisherAppClientID, PublisherAppClientSecret, TenantId, Environment are variables declared in the Release Pipeline that will contain Client ID and Secret to authenticate via OAuth 2.0, the guid of the Tenant ID and the Environment name.

Did my post help you? Leave a reply.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.