Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/workflows/validate-managed-cleanroom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ jobs:
Write-Host "PSScriptAnalyzer: clean"
}

- name: Target resource configuration (offline, mocked Azure CLI)
run: |
& "./$env:DEMO/scripts/bicep/tests/test-target-resource-configuration.ps1"

- name: Dry-run smoke (offline, no network)
working-directory: demos/analytics-using-managedcleanroom/scripts/frontend
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,42 @@ $deployParams = @{
This is Bicep (declarative collaboration resource) + the ARM *action* steps
(`enableWorkload`, `addCollaborator`). Runtime ~35 min. See [scripts/bicep/](bicep/).

### Optional target resource configuration

To pass additional creation-time settings such as public IP tags, add a
`targetResourceConfiguration` hashtable to `$deployParams` before invoking the
deployment script:

```powershell
$deployParams.targetResourceConfiguration = @{
iPTagConfiguration = @{
type = "FirstPartyUsage"
value = "/AzureCleanRoomsNonProd"
}
}
.\scripts\bicep\deploy-managed-cleanroom.ps1 @deployParams -DryRun
```

Use only IP-tag values approved for your subscription and scenario. These are
networking IP tags, not ordinary ARM resource tags. Use ARM property names,
including the case-sensitive `iPTagConfiguration` spelling, not CLI shorthand
such as `i-p-tag-configuration`.

The script merges this object with `aksSku` and `nodePoolSize`. If those fields
also appear in the object, the object values take precedence; SKU validation
and the node-count range of 3-10 still apply. With the object omitted, existing
behavior is unchanged (`Standard_D4ds_v5`, 3 nodes by default).

`-DryRun` prints the effective configuration without deploying; it still reads
the current Azure CLI account. Remove `-DryRun` to create the collaboration.
The script passes the object through a temporary JSON file, which is removed
even if deployment fails. Direct Bicep deployments can also supply the optional
`targetResourceConfiguration` object parameter.

These settings apply when creating a new collaboration. An existing
collaboration is skipped, not updated. `-DeleteExistingCollab` deletes and
recreates the collaboration; it is not an in-place configuration change.

---

## Phase 2 — Each participant resolves the collaboration and joins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
.PARAMETER resourceLocation
Region where clean-room infra (AKS/CCF/CACI) is provisioned (default: westus).

.PARAMETER targetResourceConfiguration
Optional target resource settings using ARM property names, including
iPTagConfiguration. aksSku and nodePoolSize in this object override the
corresponding script parameters and retain their validation constraints.

.PARAMETER additionalCollaborators
Optional list of extra collaborator identifiers to invite via addCollaborator.

Expand Down Expand Up @@ -75,12 +80,32 @@ param(

[string]$apiVersion = "2026-09-30-preview",

[switch]$dryRun
[switch]$dryRun,

[ValidateNotNull()]
[hashtable]$targetResourceConfiguration = @{}
)

$ErrorActionPreference = "Stop"
$armEndpoint = "https://management.azure.com"

if ($targetResourceConfiguration.ContainsKey("aksSku")) {
$aksSku = $targetResourceConfiguration.aksSku
}
if ($targetResourceConfiguration.ContainsKey("nodePoolSize")) {
$nodePoolSize = $targetResourceConfiguration.nodePoolSize
}
$effectiveTargetConfiguration = @{
aksSku = $aksSku
nodePoolSize = $nodePoolSize
}
foreach ($entry in $targetResourceConfiguration.GetEnumerator()) {
if ($entry.Key -notin @("aksSku", "nodePoolSize")) {
$effectiveTargetConfiguration[$entry.Key] = $entry.Value
}
}
$targetConfigurationJson = $effectiveTargetConfiguration | ConvertTo-Json -Depth 20 -Compress

# Analytics is currently the only supported workload.
$workloadType = "Analytics"

Expand Down Expand Up @@ -113,6 +138,7 @@ if ($dryRun) {
}
Write-Host "[DRY-RUN] Would deploy Bicep: $PSScriptRoot/managed-cleanroom.bicep (owner from caller token)"
Write-Host "[DRY-RUN] collaborationName=$collaborationName location=$location resourceLocation=$resourceLocation aksSku=$aksSku nodePoolSize=$nodePoolSize"
Write-Host "[DRY-RUN] targetResourceConfiguration=$targetConfigurationJson"
Write-Host "[DRY-RUN] Would POST $collabArmUrl/enableWorkload body {workloadType=$workloadType}"
foreach ($collaborator in $additionalCollaborators) {
Write-Host "[DRY-RUN] Would POST $collabArmUrl/addCollaborator body {collaborator.userIdentifier=$collaborator}"
Expand Down Expand Up @@ -155,19 +181,27 @@ if ($existing -and $existing.id) {
# collaborators are passed here. az deployment group create blocks until the
# deployment reaches a terminal state, so no separate provisioning poll is needed.
Write-Host "Deploying collaboration '$collaborationName' via Bicep (~25 min)..."
az deployment group create `
--resource-group $resourceGroup `
--name "deploy-$collaborationName" `
--template-file "$PSScriptRoot/managed-cleanroom.bicep" `
--parameters `
collaborationName=$collaborationName `
location=$location `
resourceLocation=$resourceLocation `
aksSku=$aksSku `
nodePoolSize=$nodePoolSize `
-o none
if ($LASTEXITCODE -ne 0) {
throw "Bicep deployment failed (az deployment group create exit code $LASTEXITCODE). See the error above."
$targetConfigurationFile = [System.IO.Path]::GetTempFileName()
try {
[System.IO.File]::WriteAllText($targetConfigurationFile, $targetConfigurationJson)
az deployment group create `
--resource-group $resourceGroup `
--name "deploy-$collaborationName" `
--template-file "$PSScriptRoot/managed-cleanroom.bicep" `
--parameters `
collaborationName=$collaborationName `
location=$location `
resourceLocation=$resourceLocation `
aksSku=$aksSku `
nodePoolSize=$nodePoolSize `
"targetResourceConfiguration=@$targetConfigurationFile" `
-o none
if ($LASTEXITCODE -ne 0) {
throw "Bicep deployment failed (az deployment group create exit code $LASTEXITCODE). See the error above."
}
}
finally {
Remove-Item -LiteralPath $targetConfigurationFile -ErrorAction SilentlyContinue
}

$collab = Get-Collab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ param aksSku string = 'Standard_D4ds_v5'
@maxValue(10)
param nodePoolSize int = 3

@description('Optional target resource settings using ARM property names (for example iPTagConfiguration). Values override aksSku and nodePoolSize when supplied in this object.')
param targetResourceConfiguration object = {}

@description('Optional additional collaborators added at creation time. Each entry is { userIdentifier: "<email-or-appId>" }. The owner is derived from the caller token automatically. Add further collaborators later via the addCollaborator action (see deploy script).')
param collaborators array = []

Expand All @@ -86,10 +89,10 @@ resource collaboration 'Microsoft.CleanRoom/collaborations@2026-09-30-preview' =
properties: {
resourceLocation: resourceLocation
collaborators: collaborators
targetResourceConfiguration: {
targetResourceConfiguration: union({
aksSku: aksSku
nodePoolSize: nodePoolSize
}
}, targetResourceConfiguration)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
$ErrorActionPreference = "Stop"
$deploymentScript = Join-Path $PSScriptRoot "../deploy-managed-cleanroom.ps1"
$testDirectory = Join-Path ([System.IO.Path]::GetTempPath()) "cleanroom target config $([guid]::NewGuid())"
$previousExitCode = $global:LASTEXITCODE

function Assert-Equal {
param($Actual, $Expected, [string]$Message)
if ($Actual -cne $Expected) {
throw "${Message}: expected '$Expected', got '$Actual'."
}
}

function Invoke-Scenario {
param([hashtable]$Parameters, [string]$FailureMode = "", [switch]$Existing)
$state = [pscustomobject]@{
Calls = [System.Collections.Generic.List[string]]::new()
Configuration = $null
ParameterFile = $null
Deployed = $false
Error = $null
Output = @()
}

function az {
$command = $args -join " "
$state.Calls.Add($command)
$global:LASTEXITCODE = 0
switch -Wildcard ($command) {
"account show *" { '{"id":"offline-test-subscription"}'; return }
"group create *" { return }
"provider register *" { return }
"deployment group create *" {
$parameter = @($args | Where-Object { $_ -like "targetResourceConfiguration=@*" })
Assert-Equal $parameter.Count 1 "Expected one JSON object parameter"
$state.ParameterFile = $parameter[0].Substring("targetResourceConfiguration=@".Length)
Assert-Equal (Test-Path -LiteralPath $state.ParameterFile) $true "Parameter file exists during deployment"
$state.Configuration = Get-Content -LiteralPath $state.ParameterFile -Raw | ConvertFrom-Json
if ($FailureMode -eq "ExitCode") { $global:LASTEXITCODE = 1; return }
if ($FailureMode -eq "Throw") { throw "Simulated deployment exception" }
$state.Deployed = $true
return
}
"rest --method GET *" {
if ($Existing -or $state.Deployed) {
'{"id":"/offline/collaboration","properties":{"workloads":[{"workloadType":"Analytics","endpoint":"https://example.test"}],"health":{"healthState":"Ok"}}}'
} else {
'{}'
}
return
}
"rest --method POST */enableWorkload?*" { return }
default { throw "Unexpected Azure CLI call: $command" }
}
}

try {
$state.Output = @(& (Join-Path $testDirectory "deploy-managed-cleanroom.ps1") `
-resourceGroup offline-rg -collaborationName offline-collab @Parameters 6>&1)
} catch {
$state.Error = $_
}
return $state
}

try {
New-Item -ItemType Directory -Path $testDirectory | Out-Null
Copy-Item -LiteralPath $deploymentScript -Destination $testDirectory
$cases = @(
@{ Name = "defaults"; Parameters = @{}; Sku = "Standard_D4ds_v5"; Nodes = 3 },
@{ Name = "legacy sizing"; Parameters = @{ aksSku = "Standard_D16ds_v5"; nodePoolSize = 6 }; Sku = "Standard_D16ds_v5"; Nodes = 6 },
@{ Name = "empty object"; Parameters = @{ targetResourceConfiguration = @{} }; Sku = "Standard_D4ds_v5"; Nodes = 3 },
@{ Name = "IP tags with legacy sizing"; Parameters = @{ aksSku = "Standard_D8ds_v5"; nodePoolSize = 4; targetResourceConfiguration = @{ iPTagConfiguration = @{ type = "FirstPartyUsage"; value = "/AzureCleanRoomsNonProd" } } }; Sku = "Standard_D8ds_v5"; Nodes = 4 },
@{ Name = "object overrides legacy sizing"; Parameters = @{ aksSku = "Standard_D4ds_v5"; nodePoolSize = 3; targetResourceConfiguration = @{ aksSku = "Standard_D32ds_v5"; nodePoolSize = 10 } }; Sku = "Standard_D32ds_v5"; Nodes = 10 },
@{ Name = "partial object retains defaults"; Parameters = @{ targetResourceConfiguration = @{ nodePoolSize = 5 } }; Sku = "Standard_D4ds_v5"; Nodes = 5 }
)
foreach ($case in $cases) {
$parameters = $case.Parameters.Clone()
$parameters.dryRun = $true
$state = Invoke-Scenario -Parameters $parameters
if ($state.Error) { throw $state.Error }
Assert-Equal $state.Calls.Count 1 "$($case.Name): only account lookup in dry run"
$prefix = "[DRY-RUN] targetResourceConfiguration="
$line = @($state.Output | Where-Object { "$($_)".StartsWith($prefix) })
Assert-Equal $line.Count 1 "$($case.Name): effective configuration printed"
$configuration = "$($line[0])".Substring($prefix.Length) | ConvertFrom-Json
Assert-Equal $configuration.aksSku $case.Sku "$($case.Name): SKU"
Assert-Equal $configuration.nodePoolSize $case.Nodes "$($case.Name): node count"
if ($case.Parameters.targetResourceConfiguration.iPTagConfiguration) {
Assert-Equal $configuration.iPTagConfiguration.value "/AzureCleanRoomsNonProd" "IP tag in dry-run output"
}
Write-Host "PASS: $($case.Name)"
}

foreach ($invalid in @(
@{ aksSku = "UnsupportedSku" },
@{ aksSku = $null },
@{ nodePoolSize = 2 },
@{ nodePoolSize = 11 },
@{ nodePoolSize = $null }
)) {
$state = Invoke-Scenario -Parameters @{ targetResourceConfiguration = $invalid; dryRun = $true }
if (-not $state.Error) { throw "Invalid configuration was accepted: $($invalid | ConvertTo-Json -Compress)" }
Assert-Equal $state.Calls.Count 0 "Invalid sizing rejected before Azure CLI calls"
Write-Host "PASS: invalid configuration rejected: $($invalid | ConvertTo-Json -Compress)"
}

$tagValue = '/tag with spaces, "quotes" and \slashes'
$configuration = @{ aksSku = "Standard_D8ds_v5"; nodePoolSize = 5; iPTagConfiguration = @{ type = "FirstPartyUsage"; value = $tagValue } }
foreach ($failureMode in @("", "ExitCode", "Throw")) {
$state = Invoke-Scenario -Parameters @{ targetResourceConfiguration = $configuration } -FailureMode $failureMode
if ($failureMode -eq "") {
if ($state.Error) { throw $state.Error }
Assert-Equal $state.Deployed $true "Successful deployment"
} else {
if (-not $state.Error) { throw "Deployment failure was not propagated: $failureMode" }
$expectedMessage = if ($failureMode -eq "ExitCode") { "Bicep deployment failed*" } else { "Simulated deployment exception*" }
if ($state.Error.Exception.Message -notlike $expectedMessage) { throw $state.Error }
}
Assert-Equal $state.Configuration.aksSku "Standard_D8ds_v5" "SKU forwarded in JSON file"
Assert-Equal $state.Configuration.nodePoolSize 5 "Node count forwarded in JSON file"
Assert-Equal $state.Configuration.iPTagConfiguration.type "FirstPartyUsage" "IP tag type forwarded in JSON file"
Assert-Equal $state.Configuration.iPTagConfiguration.value $tagValue "Special characters round-trip in JSON file"
Assert-Equal (Test-Path -LiteralPath $state.ParameterFile) $false "Temporary file removed after deployment"
Assert-Equal $configuration.Count 3 "Caller configuration unchanged"
Write-Host "PASS: JSON forwarding and cleanup (failure mode: '$failureMode')"
}

$state = Invoke-Scenario -Parameters @{ targetResourceConfiguration = $configuration } -Existing
if ($state.Error) { throw $state.Error }
Assert-Equal $state.Deployed $false "Existing collaboration skipped"
Assert-Equal $state.ParameterFile $null "No parameter file for skipped deployment"
Write-Host "PASS: existing collaboration skipped"
Write-Host "All 15 offline target-resource-configuration tests passed."
}
finally {
Remove-Item -LiteralPath $testDirectory -Recurse -Force -ErrorAction SilentlyContinue
$global:LASTEXITCODE = $previousExitCode
}
Loading