web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Release Pipeline to Sandbox Environment - Authentication Issue

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I'm having trouble getting a release pipeline to deploy an *.app artifact of a compiled extension to my sandbox environment.

I've followed this tutorial and it all works well until it tries to connect to my tenant (I think?)

Here's the log:

2022-08-28T19:02:31.0302796Z ##[sectionStarting: PowerShell Script
2022-08-28T19:02:31.0470082Z ==============================================================================
2022-08-28T19:02:31.0470473Z Task         : PowerShell
2022-08-28T19:02:31.0470757Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2022-08-28T19:02:31.0471037Z Version      : 2.200.0
2022-08-28T19:02:31.0471512Z Author       : Microsoft Corporation
2022-08-28T19:02:31.0471869Z Help         : docs.microsoft.com/.../powershell
2022-08-28T19:02:31.0472243Z ==============================================================================
2022-08-28T19:02:32.1938120Z Generating script.
2022-08-28T19:02:32.2421513Z ========================== Starting Command Output ===========================
2022-08-28T19:02:32.2704996Z ##[command"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent\_work\_temp\50730114-9920-4770-9ecb-6599b0954225.ps1'"
2022-08-28T19:02:32.5930405Z Installing BcContainerHelper
2022-08-28T19:02:50.6303516Z Publishing to tenant
2022-08-28T19:02:50.7696266Z BcContainerHelper version 4.0.0-preview690
2022-08-28T19:02:50.9523925Z BcContainerHelper emits usage statistics telemetry to Microsoft
2022-08-28T19:02:53.1242868Z Attempting authentication to api.businesscentral.dynamics.com/.default using clientCredentials...
2022-08-28T19:02:53.9976289Z Authenticated as app ***
2022-08-28T19:02:54.9299813Z ERROR The remote server returned an error: (401) Unauthorized.
2022-08-28T19:02:56.0618857Z Publish-PerTenantExtensionApps Telemetry Correlation Id: a5731c25-f19e-4fb7-b12f-d2c154eb43a7
2022-08-28T19:02:56.1212074Z The remote server returned an error: (401) Unauthorized. {
2022-08-28T19:02:56.1213591Z   "error": {
2022-08-28T19:02:56.1215402Z     "code": "Authentication_InvalidCredentials",
2022-08-28T19:02:56.1217061Z     "message": "The server has rejected the client credentials."
2022-08-28T19:02:56.1218096Z   }
2022-08-28T19:02:56.1218948Z } (ms-correlation-x = a4a04857-2056-48c8-a2b1-28780a48b210)
2022-08-28T19:02:56.1220334Z At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.0\BcSaaS\Publish-PerTenantExtensionApps.ps1:163 
2022-08-28T19:02:56.1221388Z char:9
2022-08-28T19:02:56.1222678Z           throw (GetExtendedErrorMessage $_)
2022-08-28T19:02:56.1224246Z           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-08-28T19:02:56.1225419Z       CategoryInfo          : OperationStopped: (The remote serv...1-28780a48b210):String) [, RuntimeException
2022-08-28T19:02:56.1226861Z       FullyQualifiedErrorId : The remote server returned an error: (401) Unauthorized. {
2022-08-28T19:02:56.1229086Z   "error": {
2022-08-28T19:02:56.1230192Z     "code": "Authentication_InvalidCredentials",
2022-08-28T19:02:56.1232679Z     "message": "The server has rejected the client credentials."
2022-08-28T19:02:56.1234951Z   }
2022-08-28T19:02:56.1235981Z } (ms-correlation-x = a4a04857-2056-48c8-a2b1-28780a48b210)
2022-08-28T19:02:56.1237015Z  
2022-08-28T19:02:56.3124270Z ##[errorPowerShell exited with code '1'.
2022-08-28T19:02:56.3597106Z ##[sectionFinishing: PowerShell Script
According to the tutorial, the pipeline only needs the authorization of BC to allow third party applications to login and install extensions. And that's done through Azure Active Directory. 
Maybe I have to provide user credentials? idk
Here's the script that the release pipeline runs:
Write-Host "Installing BcContainerHelper"
Install-Module BcContainerHelper -Force -AllowPrerelease
Write-Host "Publishing to tenant"
Publish-PerTenantExtensionApps -useNewLine `
-ClientID "$(PublisherAppClientID)" `
-ClientSecret "$(MyThesisAppPublisherSecret)" `
-tenantId "$(TenantId)" `
-environment "$(Environment)" `
-companyName "$(CompanyName)" `
-appFiles @(Get-Item "_ALOps Thesis\ALOps Thesis/*.app" | % { $_.FullName })
The secrets are all correct, if I change them the pipeline doesnt go as far, so I'm all out of ideas of how to solve this.
I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,105 Moderator on at

    I see that blog is a little old.

    Did you perform this step? Giving the app permissions inside BC?

    docs.microsoft.com/.../automation-apis-using-s2s-authentication

  • BFAlves Profile Picture
    5 on at

    I must've done something wrong during that procedure, probably put the wrong App ID. I deleted the record and created a new one and it works now.

    :)

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,105 Moderator on at

    Great that you got it working!

    Please help both the community and me by answer yes where you are asked if your question is answered.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans