microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
384 stars 247 forks source link

ci/cd workshop PDF - error in releasing a per tenant extension to an online environment, variable $scopes not set #1655

Closed tobiaskluge closed 3 years ago

tobiaskluge commented 3 years ago

Describe the issue BcContainer Helper 2.0.2

Error message:

Publish-PerTenantExtensionApps : The variable '$scopes' cannot be retrieved because it has not been set.

Scripts used to create container and cause the issue

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

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

I added the $scopes line, and than it worked:

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

$scopes       = "https://api.businesscentral.dynamics.com/.default"

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

Full output of scripts

2021-01-28T14:24:24.0372859Z ##[section]Starting: PowerShell Script
2021-01-28T14:24:24.0529896Z ==============================================================================
2021-01-28T14:24:24.0530244Z Task         : PowerShell
2021-01-28T14:24:24.0531198Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2021-01-28T14:24:24.0531914Z Version      : 2.180.1
2021-01-28T14:24:24.0532291Z Author       : Microsoft Corporation
2021-01-28T14:24:24.0532730Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2021-01-28T14:24:24.0533104Z ==============================================================================
2021-01-28T14:24:25.2684423Z Generating script.
2021-01-28T14:24:25.3866017Z ========================== Starting Command Output ===========================
2021-01-28T14:24:25.4161192Z ##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\e9211259-8604-4f1e-a27b-e94802483b6e.ps1'"
2021-01-28T14:24:25.7153791Z Installing BcContainerHelper
2021-01-28T14:24:50.1991932Z Publishing to tenant
2021-01-28T14:24:50.5242511Z BcContainerHelper version 2.0.2
2021-01-28T14:24:51.5449726Z Publish-PerTenantExtensionApps : The variable '$scopes' cannot be retrieved because it has not been set.
2021-01-28T14:24:51.5451046Z At D:\a\_temp\e9211259-8604-4f1e-a27b-e94802483b6e.ps1:9 char:1
2021-01-28T14:24:51.5451863Z + Publish-PerTenantExtensionApps -useNewLine `
2021-01-28T14:24:51.5452349Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-01-28T14:24:51.5453021Z     + CategoryInfo          : InvalidOperation: (scopes:String) [Publish-PerTenantExtensionApps], RuntimeException
2021-01-28T14:24:51.5453789Z     + FullyQualifiedErrorId : VariableIsUndefined,Publish-PerTenantExtensionApps
2021-01-28T14:24:51.5454185Z  
2021-01-28T14:24:51.6758599Z ##[error]PowerShell exited with code '1'.
2021-01-28T14:24:51.7153925Z ##[section]Finishing: PowerShell Script

...

Additional context

tobiaskluge commented 3 years ago

Boah - @freddydk you are crazy fast! Thanks a lot! 👍 💪

freddydk commented 3 years ago

2.0.3-preview328 shipped with a fix for this

freddydk commented 3 years ago

2.0.3 was shipped