Hello,
using the following script to publish App to a sandbox environment we return error 403:
$authContext = New-BcAuthContext -refreshToken XXXXX
$saasEnvironment = "sandbox"
[string[]]$apps = Get-ChildItem 'XXXX' -Recurse -filter "*_SAAS.app" -Exclude "*Test*"
Publish-BcContainerApp -appFile $apps -bcAuthContext $authcontext -environment $saasEnvironment -syncMode ForceSync
That is the output:
Der Remoteserver hat einen Fehler zurückgegeben: (403) Unzulässig. (ms-correlation-x = 2a3ee4f0-34ba-441f-a72d-f07439d029eb)
In C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.5\BcSaaS\Get-BcEnvironments.ps1:29 Zeichen:9
+ throw (GetExtenedErrorMessage $_.Exception)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Der Remoteserve...d-f07439d029eb):String) [], RuntimeException
+ FullyQualifiedErrorId : Der Remoteserver hat einen Fehler zurückgegeben: (403) Unzulässig. (ms-correlation-x = 2a3ee4f0-34ba-441f-a72d-f07439d029eb)
Sorry for german language, had no time to switch language to english.
Any ideas what is wrong there?
Kind regards
Looks like the authcontext is wrong.
You cannot get environments.
New-BcAuthContext -devicelogin will give you ann authcontext - try with that.
Thanks for fast reply.
Unfortunately that was not the problem, also with a fresh AuthContext the error remains:
PS C:\Windows\system32> $authContext = New-BcAuthContext -includeDeviceLogin
$saasEnvironment = "sandbox"
[string[]]$apps = Get-ChildItem 'XXXX' -Recurse -filter "*_SAAS.app" -Exclude "*Test*"
Publish-BcContainerApp -appFile $apps -bcAuthContext $authcontext -environment $saasEnvironment -syncMode ForceSync
Attempting authentication to https://api.businesscentral.dynamics.com/Common using device login...
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code DW7N4NC9K to authenticate.
Waiting for authentication...
Authenticated from xx.xx.xxx.xxx as user xxxxxxxxxxxxxxxx
Authenticated to common, using tenant id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
Der Remoteserver hat einen Fehler zurückgegeben: (403) Unzulässig. (ms-correlation-x = 3d9e6bea-cd75-4f56-ad2d-b37c3ae0d17f)
In C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.5\BcSaaS\Get-BcEnvironments.ps1:29 Zeichen:9
+ throw (GetExtenedErrorMessage $_.Exception)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Der Remoteserve...d-b37c3ae0d17f):String) [], RuntimeException
+ FullyQualifiedErrorId : Der Remoteserver hat einen Fehler zurückgegeben: (403) Unzulässig. (ms-correlation-x = 3d9e6bea-cd75-4f56-ad2d-b37c3ae0d17f)
Could you email me the hidden info here - user etc.
The issue here is that the Publish-BcContainerApp function uses Get-BcEnvironment to test whether the environment specified exists and it is a sandbox.
Get-BcEnvironment needs delegated admin permissions.
Publishing to dev endpoint doesn't
I will remove the test. If the environment doesn't exist or it is a production environment, it will fail on publishing anyway.
Shipped in 2.0.6-preview355
Shipped in BcContainerHelper 2.0.6