Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5bd8aca
checkout
Sep 25, 2022
98777fd
checkout
Sep 25, 2022
95de05c
Update RELEASENOTES.copy.md
Sep 27, 2022
cac0193
Update CreateOnlineDevelopmentEnvironment.yaml
Oct 16, 2022
f71d2c7
checkout
Nov 2, 2022
80eec3f
Update CreateRelease.yaml
Nov 3, 2022
df491af
Update CreateRelease.yaml
Nov 3, 2022
9eb9611
Update CICD.yaml
Nov 5, 2022
0210101
Update Current.yaml
Nov 5, 2022
7f61a34
Update NextMajor.yaml
Nov 5, 2022
39adbb8
Update NextMinor.yaml
Nov 5, 2022
84d7fbf
checkout
Dec 2, 2022
df0b50f
Update RELEASENOTES.copy.md
Dec 2, 2022
526c791
checkout
Jan 13, 2023
b456135
Update RELEASENOTES.copy.md
Jan 14, 2023
887ea46
Hotfix issue 358
Jan 16, 2023
485e754
Hotfix issue 358
Jan 16, 2023
c612f78
checkout
Feb 3, 2023
1f3c588
Update RELEASENOTES.copy.md
Feb 3, 2023
062f83e
checkout
Mar 30, 2023
0555cf3
Update RELEASENOTES.copy.md
Mar 30, 2023
7dcacae
Update RELEASENOTES.copy.md
Mar 30, 2023
d69bf85
checkout
May 15, 2023
c461aa0
Update RELEASENOTES.copy.md
May 15, 2023
1eb545d
Create CODEOWNERS
mazhelez Jun 14, 2023
e26a2dd
Merge pull request #7 from microsoft/mazhelez/add-codeowners
mazhelez Jun 14, 2023
ff45933
checkout
Aug 15, 2023
1826b6e
Update PublishToEnvironment.yaml (#10)
Aug 21, 2023
6778c84
hotfix https://github.com/microsoft/AL-Go/issues/643 (#16)
Aug 31, 2023
9584936
Uptake new GitHub teams in CODEOWNERS (#17)
mazhelez Sep 5, 2023
01fbe1e
Deploying AL-Go from main (37e4e3fac9276ad13dc998d03f7bf0fdad577d19) …
Sep 27, 2023
f33f8f6
Deploying AL-Go from main (91a563be484eeff8ccde7f39b3622991cc8931f0) …
Oct 17, 2023
ea636b2
Update PullRequestHandler.yaml (#40)
Nov 3, 2023
4e9dea0
Deploying AL-Go from main (ad7ba196b05948c0f3522a1dea60916df5169f00) …
Jan 22, 2024
35a5931
Deploying AL-Go from main (e6f32930d61ce5fbf63e9567ee61492bb0ce0690) …
Apr 3, 2024
bf05ca8
Deploying AL-Go from main (92365fbce2f60a8b26758608f36f9e24265646d4) …
May 2, 2024
d3fa23a
Deploying AL-Go from main (383330241ad5197bb44396441a2a5ace0c879d1f) …
Jun 6, 2024
955c79c
Update README.md
Jun 28, 2024
38f08dd
Update README.md
Jun 28, 2024
173f75a
Update README.md
Jun 28, 2024
ffb3a6e
Deploying AL-Go from main (a2c4efcc730e9b264f74cb321e7c2193c8c96b8d) …
Aug 21, 2024
2855a6a
Deploying AL-Go from main (6d6292c0fc1295bccd0ec2e91a916bce02210d0f) …
Oct 4, 2024
8d285b6
Deploying AL-Go from main (a1290fdde01396f3dad78d0c593af9b4d36af1ec) …
Nov 13, 2024
8924ef5
Deploying AL-Go from main (86403d92a5e431a1146dafd38d4df17ea153ebaf) …
Dec 17, 2024
0518c00
Deploying AL-Go from main (120540b15626528818b0aca52dc4822eb527e5c4) …
Jan 22, 2025
7f5ede0
Deploying AL-Go from main (4000fc21109200985749fbbb6b62d22d20a8adcb) …
Mar 17, 2025
0a34674
Deploying AL-Go from main (9a3c24d17cd9a7bc961fd294af974576b1e66685) …
business-central-bot[bot] Apr 1, 2025
10e4662
Deploying AL-Go from main (83e18bd25f318b4a4b024fec764a4dab73ff8500) …
business-central-bot[bot] Apr 30, 2025
b3a3eae
Deploying AL-Go from main (aef11137716ce7d2b0761255331b0faedc890875) …
business-central-bot[bot] Jun 4, 2025
1c3e324
Deploying AL-Go from main (246ca5430b5f0b8dd040d628fb3f14b4fc64b9e2) …
business-central-bot[bot] Aug 29, 2025
0fa7e97
Deploying AL-Go from main (8fe0a6e6c2b2b747805f9821966b203d1ea52a48) …
business-central-bot[bot] Oct 15, 2025
1113b4e
Deploying AL-Go from main (4dd459a25067ede3335ff60d74c3bf049c3f6e7d) …
business-central-bot[bot] Dec 3, 2025
b131887
Deploying AL-Go from main (d5c257be27a832e7a826b58f5e7f9efdb8d67a39) …
business-central-bot[bot] Feb 5, 2026
c8588b4
Deploying AL-Go from main (ff80c207175354f4ee42f74dcdc9885292ab8610) …
business-central-bot[bot] Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 151 additions & 42 deletions .AL-Go/cloudDevEnv.ps1
Original file line number Diff line number Diff line change
@@ -1,59 +1,163 @@
#
# Script for creating cloud development environment
# Please do not modify this script as it will be auto-updated from the AL-Go Template
# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters
#
<#
.SYNOPSIS
Creates a cloud-based development environment for Business Central AL development using SaaS Sandbox.

.DESCRIPTION
This script sets up a cloud-based development environment by:
- Creating a Business Central SaaS Sandbox environment
- Compiling and publishing all apps and test apps to the development scope
- Configuring launch.json for Visual Studio Code with Cloud Sandbox configuration
- Optionally applying custom settings to override repository settings

The script will prompt you interactively for authentication using device code flow.
For automated/unattended execution, you can configure AdminCenterApiCredentials as a GitHub secret
or in Azure KeyVault. See https://aka.ms/algosettings for more information about AdminCenterApiCredentials.

This is an alternative to localDevEnv.ps1 for users who cannot run Docker containers locally.

RECOMMENDED USAGE:
Instead of modifying this script directly (which will be overwritten during AL-Go updates),
create a custom script that calls this one with your preferred parameters. For example,
create a file named after yourself (e.g., 'john-devenv.ps1') that contains:

# My personal cloud development environment script
$mySettings = '{"country":"us"}'
. .\.AL-Go\cloudDevEnv.ps1 -environmentName "john-sandbox" -reuseExistingEnvironment $true -customSettings $mySettings

This approach allows you to:
- Maintain your personal preferences without losing them during updates
- Share your setup with team members
- Version control your custom development configurations
- Easily switch between different development scenarios

.PARAMETER environmentName
The name of the cloud sandbox environment to create or reuse.
If not specified, the script will prompt for input with a default of "{username}-sandbox".

.PARAMETER reuseExistingEnvironment
Boolean parameter indicating whether to reuse an existing environment with the same name.
If $true, the script will use the existing environment if it exists.
If $false, the script will recreate the environment (deleting the old one if it exists).
If not specified, the script will prompt the user to select the behavior.

.PARAMETER fromVSCode
Switch parameter indicating the script is being run from Visual Studio Code.
When specified, the script will pause at the end waiting for user input before closing.

.PARAMETER clean
Switch parameter to create a clean development environment without compiling and publishing apps.
Useful for setting up a fresh environment without deploying any applications.

.PARAMETER customSettings
JSON string containing custom settings that override repository settings.
These settings have the highest precedence and can be used to override country,
or other configuration without modifying repository files.

.EXAMPLE
.\cloudDevEnv.ps1
Runs the script interactively, prompting for all required parameters.

.EXAMPLE
.\cloudDevEnv.ps1 -environmentName "my-sandbox" -reuseExistingEnvironment $true
Creates or reuses a cloud sandbox named "my-sandbox".

.EXAMPLE
.\cloudDevEnv.ps1 -clean
Creates a clean cloud development environment without compiling and publishing apps.

.EXAMPLE
.\cloudDevEnv.ps1 -customSettings '{"country":"dk"}'
Creates a cloud development environment with custom settings for Denmark country.

.EXAMPLE
# Programmatic setup with custom settings
$envName = "test-sandbox"
$settings = '{"country": "us"}'

. ./cloudDevEnv.ps1 -environmentName $envName -reuseExistingEnvironment $true -customSettings $settings

Creates or reuses a cloud development environment with custom country setting.

.NOTES
- Authentication is handled interactively via device code flow (https://aka.ms/devicelogin)
- For unattended execution, configure AdminCenterApiCredentials secret (see link below)
- Does not require Docker to be installed
- Script automatically downloads required AL-Go helper modules and actions
- Modifies launch.json in VS Code workspace for Cloud Sandbox configuration
- Custom settings parameter allows runtime override of repository settings
- If NewBcContainer.ps1 override exists, cloud development may not be supported

.LINK
https://aka.ms/algosettings - AL-Go Settings Documentation
https://github.com/microsoft/AL-Go/blob/main/Scenarios/CreateOnlineDevEnv2.md - Online Dev Environment Setup
#>

Param(
[string] $environmentName = "",
[bool] $reuseExistingEnvironment,
[switch] $fromVSCode
[switch] $fromVSCode,
[switch] $clean,
[string] $customSettings = ""
)

$ErrorActionPreference = "stop"
Set-StrictMode -Version 2.0
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0

$pshost = Get-Host
if ($pshost.Name -eq "Visual Studio Code Host") {
if ($MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '') {
$scriptName = Join-Path $PSScriptRoot $MyInvocation.MyCommand
}
else {
$scriptName = $MyInvocation.InvocationName
function DownloadHelperFile {
param(
[string] $url,
[string] $folder,
[switch] $notifyAuthenticatedAttempt
)

$prevProgressPreference = $ProgressPreference; $ProgressPreference = 'SilentlyContinue'
$name = [System.IO.Path]::GetFileName($url)
Write-Host "Downloading $name from $url"
$path = Join-Path $folder $name
try {
Invoke-WebRequest -UseBasicParsing -uri $url -OutFile $path
}
if (Test-Path -Path $scriptName -PathType Leaf) {
$scriptName = (Get-Item -path $scriptName).FullName
$pslink = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk"
if (!(Test-Path $pslink)) {
$pslink = "powershell.exe"
catch {
if ($notifyAuthenticatedAttempt) {
Write-Host -ForegroundColor Red "Failed to download $name, trying authenticated download"
}
Start-Process -Verb runas $pslink @("-Command ""$scriptName"" -fromVSCode -environmentName '$environmentName' -reuseExistingEnvironment `$$reuseExistingEnvironment")
return
Invoke-WebRequest -UseBasicParsing -uri $url -OutFile $path -Headers @{ "Authorization" = "token $(gh auth token)" }
}
$ProgressPreference = $prevProgressPreference
return $path
}

try {
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
$webClient = New-Object System.Net.WebClient
$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore)
$webClient.Encoding = [System.Text.Encoding]::UTF8
Write-Host "Downloading AL-Go Helper script"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v1.5/AL-Go-Helper.ps1', $ALGoHelperPath)
. $ALGoHelperPath -local

$baseFolder = Join-Path $PSScriptRoot ".." -Resolve

Clear-Host
Write-Host
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ ______
/ ____| | | | | __ \ | ____|
_____ _ _ _____ ______
/ ____| | | | | __ \ | ____|
| | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __
| | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / /
| |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V /
\_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/
| |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V /
\_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/

'@

$tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) "$([Guid]::NewGuid().ToString())"
New-Item -Path $tmpFolder -ItemType Directory -Force | Out-Null
$GitHubHelperPath = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.3/Github-Helper.psm1' -folder $tmpFolder -notifyAuthenticatedAttempt
$ReadSettingsModule = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.3/.Modules/ReadSettings.psm1' -folder $tmpFolder
$debugLoggingModule = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.3/.Modules/DebugLogHelper.psm1' -folder $tmpFolder
$ALGoHelperPath = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.3/AL-Go-Helper.ps1' -folder $tmpFolder
DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.3/.Modules/settings.schema.json' -folder $tmpFolder | Out-Null
DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.3/Environment.Packages.proj' -folder $tmpFolder | Out-Null

Import-Module $GitHubHelperPath
Import-Module $ReadSettingsModule
Import-Module $debugLoggingModule
. $ALGoHelperPath -local

$baseFolder = GetBaseFolder -folder $PSScriptRoot
$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot

Write-Host @'

This script will create a cloud based development environment (Business Central SaaS Sandbox) for your project.
All apps and test apps will be compiled and published to the environment in the development scope.
The script will also modify launch.json to have a "Cloud Sandbox (<name>)" configuration point to your environment.
Expand All @@ -64,18 +168,17 @@ if (Test-Path (Join-Path $PSScriptRoot "NewBcContainer.ps1")) {
Write-Host -ForegroundColor Red "WARNING: The project has a NewBcContainer override defined. Typically, this means that you cannot run a cloud development environment"
}

$settings = ReadSettings -baseFolder $baseFolder -userName $env:USERNAME

Write-Host

if (-not $environmentName) {
$environmentName = Enter-Value `
-title "Environment name" `
-question "Please enter the name of the environment to create" `
-default "$($env:USERNAME)-sandbox"
-default "$($env:USERNAME)-sandbox" `
-trimCharacters @('"',"'",' ')
}

if (-not $PSBoundParameters.ContainsKey('reuseExistingEnvironment')) {
if ($PSBoundParameters.Keys -notcontains 'reuseExistingEnvironment') {
$reuseExistingEnvironment = (Select-Value `
-title "What if the environment already exists?" `
-options @{ "Yes" = "Reuse existing environment"; "No" = "Recreate environment" } `
Expand All @@ -88,7 +191,13 @@ CreateDevEnv `
-caller local `
-environmentName $environmentName `
-reuseExistingEnvironment:$reuseExistingEnvironment `
-baseFolder $baseFolder
-baseFolder $baseFolder `
-project $project `
-clean:$clean `
-customSettings $customSettings
}
catch {
Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)"
}
finally {
if ($fromVSCode) {
Expand Down
Loading