Skip to content

Fix multi-subscription array interpolation in CreateBody#1

Open
jcoetsie wants to merge 2 commits into
RZomerman:mainfrom
jcoetsie:fix/array-subscription-ids
Open

Fix multi-subscription array interpolation in CreateBody#1
jcoetsie wants to merge 2 commits into
RZomerman:mainfrom
jcoetsie:fix/array-subscription-ids

Conversation

@jcoetsie

@jcoetsie jcoetsie commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Bug fix: multi-subscription array interpolation in CreateBody

  • $Targetsubscription is declared as string[], so when two or more subscription IDs are passed, PowerShell's string interpolation joins them with a space inside a single "subscriptions/..." string — producing an invalid value that triggers an Azure InternalServerError from the checkZonePeers API.
  • Fix: map each element individually with ForEach-Object so the JSON body contains a properly formatted array of "subscriptions/{id}" entries.

Before:

'subscriptionIds'= @(
    "subscriptions/$Targetsubscription"
)

After:

'subscriptionIds'= @($Targetsubscription | ForEach-Object { "subscriptions/$_" })

New feature: -Table switch for compact pivot table output

Adds an optional -Table switch that outputs results as a pivot table, resolving subscription IDs to their display names. Each row is a source AZ; each column is a target subscription:

  AZ mapping for location: westeurope

SourceAZ (My Source Sub) | Target Sub A | Target Sub B
--------------------------|--------------|-------------
1                         | 2            | 3
2                         | 1            | 2
3                         | 3            | 1

Subscription names are resolved via Get-AzSubscription and fall back to the raw ID if inaccessible. Without -Table, the original raw output is unchanged.

Test plan

  • Run with a single -Targetsubscription — still works, raw output unchanged
  • Run with two -Targetsubscription values — no longer returns InternalServerError
  • Run with -Table — pivot table is displayed with resolved subscription names
  • Run with -Table against a subscription the caller cannot read — falls back to subscription ID in column header

🤖 Generated with Claude Code

Jürgen Coetsiers and others added 2 commits July 8, 2026 16:52
When multiple subscriptions are passed, PowerShell interpolates a
string[] into a space-joined string, producing an invalid subscription
ID that causes an Azure InternalServerError.

Map each element individually so the JSON body contains a properly
formatted array of "subscriptions/{id}" entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When -Table is specified, results are formatted as a pivot table where
the source AZ is the row header and each target subscription (resolved
to its display name) is a column, making zone mapping easy to compare
at a glance. Without -Table the original raw output is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant