From 91bba44bebfa85e834308428bb2dd630fb040969 Mon Sep 17 00:00:00 2001 From: sebastianstephan Date: Mon, 2 Mar 2026 09:46:13 +0100 Subject: [PATCH 1/2] fix issue 210: deploy-to-aca.ps1: StateStore connection string truncated to first character on macOS/Linux --- ACA/deploy-to-aca.ps1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ACA/deploy-to-aca.ps1 b/ACA/deploy-to-aca.ps1 index a6e62e2..8631ca2 100644 --- a/ACA/deploy-to-aca.ps1 +++ b/ACA/deploy-to-aca.ps1 @@ -160,9 +160,15 @@ if ($imageExists -eq 'true') { Write-Host "`nStep 3: Prompting for StateStore connection string..." -ForegroundColor Yellow $secureConnString = Read-Host -Prompt "The StateStore keeps track of migration job details in a DocumentDB. You may use the same database as the Target DocumentDB or a separate one. Enter the connection string for the StateStore." -AsSecureString -$connString = [Runtime.InteropServices.Marshal]::PtrToStringAuto( - [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureConnString) -) +$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureConnString) +try { + $connString = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) +} catch { + Write-Host "`nError: Failed to read the StateStore connection string: $_" -ForegroundColor Red + exit 1 +} finally { + [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) +} Write-Host "`nStep 4: Deploying Container App with application image..." -ForegroundColor Yellow @@ -179,7 +185,7 @@ $finalBicepParams = @( "vCores=$VCores", "memoryGB=$MemoryGB", "stateStoreAppID=$StateStoreAppID", - "stateStoreConnectionString=`"$connString`"", + "stateStoreConnectionString=$connString", "aspNetCoreEnvironment=Development", "imageTag=$ImageTag", "ownerTag=$OwnerTag", From b03768e72e6e7498f03be573b8d6a42ff57a340c Mon Sep 17 00:00:00 2001 From: sebastianstephan Date: Wed, 11 Mar 2026 09:50:21 +0000 Subject: [PATCH 2/2] fix issue that the script stopped working on Windows Systems; Enhanced the script with separate handling of windows and non-windows platforms --- ACA/deploy-to-aca.ps1 | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ACA/deploy-to-aca.ps1 b/ACA/deploy-to-aca.ps1 index 8631ca2..58d61d7 100644 --- a/ACA/deploy-to-aca.ps1 +++ b/ACA/deploy-to-aca.ps1 @@ -160,14 +160,25 @@ if ($imageExists -eq 'true') { Write-Host "`nStep 3: Prompting for StateStore connection string..." -ForegroundColor Yellow $secureConnString = Read-Host -Prompt "The StateStore keeps track of migration job details in a DocumentDB. You may use the same database as the Target DocumentDB or a separate one. Enter the connection string for the StateStore." -AsSecureString -$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureConnString) -try { - $connString = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) -} catch { - Write-Host "`nError: Failed to read the StateStore connection string: $_" -ForegroundColor Red - exit 1 -} finally { - [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) +$isWindowsPlatform = ($env:OS -eq 'Windows_NT') -or ((Get-Variable IsWindows -ErrorAction SilentlyContinue) -and $IsWindows) + +if ($isWindowsPlatform) { + # Keep the previous Windows behavior to avoid deployment issues observed with PtrToStringBSTR. + $connString = [Runtime.InteropServices.Marshal]::PtrToStringAuto( + [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureConnString) + ) + $stateStoreConnectionStringParam = "stateStoreConnectionString=`"$connString`"" +} else { + $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureConnString) + try { + $connString = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + $stateStoreConnectionStringParam = "stateStoreConnectionString=$connString" + } catch { + Write-Host "`nError: Failed to read the StateStore connection string: $_" -ForegroundColor Red + exit 1 + } finally { + [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) + } } Write-Host "`nStep 4: Deploying Container App with application image..." -ForegroundColor Yellow @@ -185,7 +196,7 @@ $finalBicepParams = @( "vCores=$VCores", "memoryGB=$MemoryGB", "stateStoreAppID=$StateStoreAppID", - "stateStoreConnectionString=$connString", + $stateStoreConnectionStringParam, "aspNetCoreEnvironment=Development", "imageTag=$ImageTag", "ownerTag=$OwnerTag",