Skip to content

fix: remove parameter sets so the script runs as an Azure Automation runbook - #22

Merged
luigilink merged 7 commits into
mainfrom
fix/runbook-no-parametersets
Jul 15, 2026
Merged

fix: remove parameter sets so the script runs as an Azure Automation runbook#22
luigilink merged 7 commits into
mainfrom
fix/runbook-no-parametersets

Conversation

@luigilink

Copy link
Copy Markdown
Owner

Closes #21

Problem

Testing v3.1.0 live in an Azure Automation Runbook fails at start:

BadRequest - The Runbook definition is invalid. Parameter sets in runbooks are not supported in this release.

The -ConfigFile support (from #7) introduced CmdletBinding(DefaultParameterSetName=...) with two ParameterSetName parameters. Azure Automation runbooks do not support parameter sets, so the script — whose primary target is Azure Automation — could not run as a runbook, despite all local tests passing. Found by live runbook testing.

Fix

  • -InputJson and -ConfigFile are now plain optional parameters (no ParameterSetName, no DefaultParameterSetName).
  • Mutual exclusivity is validated in the body: neither -> clear error; both -> 'mutually exclusive'; exactly one -> proceed (unchanged downstream).
  • Version bumped to 3.1.1.

Testing

Invoke-Pester -> 111 passed, 0 failed (parameter tests updated: assert no parameter sets + runtime source validation). Source-selection logic verified for all four cases (InputJson / ConfigFile / both / neither).

Notes

Patch release. Behaviour is otherwise unchanged; both input methods still work.

…runbook

Azure Automation rejects runbooks that use parameter sets ('Parameter sets
in runbooks are not supported in this release'), which broke the script's
primary target even though local tests passed. Declare -InputJson and
-ConfigFile as plain optional parameters and validate their mutual
exclusivity in the body (exactly one required). Bump to 3.1.1.

Fixes #21
Replace the two-parameter-set assertions with checks that no parameter
sets are used and that exactly one config source is validated at runtime.
111 tests pass.

Refs #21
Add a 3.1.1 section to CHANGELOG and trim RELEASE-NOTES to the latest
version, documenting the Azure Automation parameter-set incompatibility fix.

Refs #21
Live runbook testing showed Connect-PnPOnline was 'not recognized': in
Azure Automation the '#Requires -Modules' directive does not import the
module and command auto-loading is unreliable in the sandbox. Add an
explicit Import-Module PnP.PowerShell (with a clear error if missing),
which is harmless locally. Completes the runbook-compatibility fix.

Refs #21
Live runbook testing surfaced that PnP.PowerShell 3.x requires PowerShell
7.4, so it fails to import on a 7.2 runbook. Document the runtime/module
matrix in Getting Started (use a 7.4 Runtime Environment with PnP 3.x, or
PnP 2.12.x on a 7.2 runbook) and note it in CHANGELOG/RELEASE-NOTES.

Refs #21
Document the validated end-to-end runbook setup: system-assigned Managed
Identity, a PowerShell 7.4 Runtime Environment with PnP.PowerShell 3.x,
granting the MI Sites.FullControl.All (app-only) via Microsoft Graph,
linking the runbook to the 7.4 runtime, and a note that only Legacy mode
is reliably app-only. Highlight the breaking change vs 2.0.1 (7.2 runtime).

Refs #21
@luigilink
luigilink merged commit 16ec7d5 into main Jul 15, 2026
1 check passed
@luigilink
luigilink deleted the fix/runbook-no-parametersets branch July 15, 2026 12:45
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.

Runbook fails: 'Parameter sets in runbooks are not supported' (remove parameter sets)

1 participant