Skip to content

PolicyInsights Autorest migration#29361

Open
dunnryan wants to merge 6 commits intoAzure:mainfrom
dunnryan:pi-autorest-migration
Open

PolicyInsights Autorest migration#29361
dunnryan wants to merge 6 commits intoAzure:mainfrom
dunnryan:pi-autorest-migration

Conversation

@dunnryan
Copy link
Copy Markdown
Contributor

@dunnryan dunnryan commented Apr 2, 2026

Description

Migration to autorest generation for the PolicyInsights cmdlets. Required some customization that has been implemented using the README.md, custom cmdlets, and some c# changes when needed.

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copilot AI review requested due to automatic review settings April 2, 2026 19:12
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates Az.PolicyInsights cmdlets to AutoRest-based generation and scaffolds module assets (custom cmdlets, overrides, docs/examples, and Pester tests) needed to keep back-compat behavior while switching generation approach.

Changes:

  • Introduces AutoRest module structure for PolicyInsights, including custom PowerShell cmdlets and generated override hooks in C#.
  • Adds/updates Pester test harness, test data files, and back-compat tests for core cmdlets.
  • Adds generated documentation and usage examples for the migrated cmdlets.

Reviewed changes

Copilot reviewed 105 out of 359 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
src/PolicyInsights/PolicyInsights.Management.Sdk/Customizations/Attestation.cs Removes legacy SDK customization class in favor of AutoRest-generated model/cmdlets.
src/PolicyInsights/PolicyInsights.Autorest/utils/Unprotect-SecureString.ps1 Adds a utility script used to convert SecureString to plaintext (likely for test/dev workflows).
src/PolicyInsights/PolicyInsights.Autorest/utils/Get-SubscriptionIdTestSafe.ps1 Adds helper to retrieve subscription id in a playback-safe way for tests.
src/PolicyInsights/PolicyInsights.Autorest/test/localEnv.json Adds live-mode local environment values for tests.
src/PolicyInsights/PolicyInsights.Autorest/test/loadEnv.ps1 Adds test environment loader used by Pester runs.
src/PolicyInsights/PolicyInsights.Autorest/test/env.json Adds record/playback environment values for tests.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/NSG_modify_neverCompliant_policyDefinition.json Normalizes JSON file (removes BOM) for test setup content.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/NSG_audit_partiallyCompliant_policyDefinition.json Normalizes JSON file (removes BOM) for test setup content.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/NSG_DINE_neverCompliant_policyDefinition.json Normalizes JSON file (removes BOM) for test setup content.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/ManualPolicySubDefinition.json Adds manual policy definition used by tests.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/ManualPolicyResourceDefinition.json Adds manual policy definition used by tests.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/ManualPolicyRGDefinition.json Adds manual policy definition used by tests.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/CreateRemediationsTemplate.json Normalizes JSON file (removes BOM) for ARM template test asset.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/CreateNSGsTemplate.json Normalizes JSON file (removes BOM) for ARM template test asset.
src/PolicyInsights/PolicyInsights.Autorest/test/TestSetupFiles/AttestationMetadata.json Adds metadata JSON used by attestation tests.
src/PolicyInsights/PolicyInsights.Autorest/test/README.md Adds documentation describing test modes and how stubs are generated.
src/PolicyInsights/PolicyInsights.Autorest/test/Common.ps1 Adds shared Pester test initialization and mocking discovery logic.
src/PolicyInsights/PolicyInsights.Autorest/test/Backcompat/PolicyStateSummary.Tests.ps1 Adds back-compat tests for Get-AzPolicyStateSummary.
src/PolicyInsights/PolicyInsights.Autorest/test/Backcompat/PolicyState.Tests.ps1 Adds back-compat tests for Get-AzPolicyState (including paging and query options).
src/PolicyInsights/PolicyInsights.Autorest/test/Backcompat/PolicyMetadata.Tests.ps1 Adds back-compat tests for Get-AzPolicyMetadata.
src/PolicyInsights/PolicyInsights.Autorest/test/Backcompat/PolicyEvent.Tests.ps1 Adds back-compat tests for Get-AzPolicyEvent.
src/PolicyInsights/PolicyInsights.Autorest/test/Backcompat/PolicyComplianceScan.Tests.ps1 Adds back-compat tests for Start-AzPolicyComplianceScan.
src/PolicyInsights/PolicyInsights.Autorest/test/Backcompat/Common.ps1 Adds back-compat-specific test bootstrap (recording path & test data path overrides).
src/PolicyInsights/PolicyInsights.Autorest/resources/README.md Adds guidance for non-packaged repository resources.
src/PolicyInsights/PolicyInsights.Autorest/how-to.md Adds module development guide (build, docs, tests, packing).
src/PolicyInsights/PolicyInsights.Autorest/examples/Update-AzPolicyAttestation.md Adds example scenarios for updating attestations.
src/PolicyInsights/PolicyInsights.Autorest/examples/Stop-AzPolicyRemediation.md Adds examples for stopping remediations.
src/PolicyInsights/PolicyInsights.Autorest/examples/Start-AzPolicyRemediation.md Adds examples for starting remediations.
src/PolicyInsights/PolicyInsights.Autorest/examples/Start-AzPolicyComplianceScan.md Adds examples for starting compliance scans.
src/PolicyInsights/PolicyInsights.Autorest/examples/Remove-AzPolicyRemediation.md Adds examples for removing remediations.
src/PolicyInsights/PolicyInsights.Autorest/examples/Remove-AzPolicyAttestation.md Adds examples for removing attestations.
src/PolicyInsights/PolicyInsights.Autorest/examples/New-AzPolicyAttestation.md Adds examples for creating attestations at multiple scopes.
src/PolicyInsights/PolicyInsights.Autorest/examples/Get-AzPolicyStateSummary.md Adds examples for querying policy state summaries.
src/PolicyInsights/PolicyInsights.Autorest/examples/Get-AzPolicyRemediation.md Adds examples for querying remediations.
src/PolicyInsights/PolicyInsights.Autorest/examples/Get-AzPolicyMetadata.md Adds examples for querying policy metadata.
src/PolicyInsights/PolicyInsights.Autorest/examples/Get-AzPolicyEvent.md Adds examples for querying policy events.
src/PolicyInsights/PolicyInsights.Autorest/examples/Get-AzPolicyAttestation.md Adds examples for querying attestations.
src/PolicyInsights/PolicyInsights.Autorest/docs/Stop-AzPolicyRemediation.md Adds generated help markdown for Stop-AzPolicyRemediation.
src/PolicyInsights/PolicyInsights.Autorest/docs/Start-AzPolicyComplianceScan.md Adds generated help markdown for Start-AzPolicyComplianceScan.
src/PolicyInsights/PolicyInsights.Autorest/docs/Remove-AzPolicyRemediation.md Adds generated help markdown for Remove-AzPolicyRemediation.
src/PolicyInsights/PolicyInsights.Autorest/docs/Remove-AzPolicyAttestation.md Adds generated help markdown for Remove-AzPolicyAttestation.
src/PolicyInsights/PolicyInsights.Autorest/docs/README.md Adds documentation folder contract (generated, packaged, overwritten).
src/PolicyInsights/PolicyInsights.Autorest/docs/Get-AzPolicyRemediation.md Adds generated help markdown for Get-AzPolicyRemediation.
src/PolicyInsights/PolicyInsights.Autorest/docs/Get-AzPolicyMetadata.md Adds generated help markdown for Get-AzPolicyMetadata.
src/PolicyInsights/PolicyInsights.Autorest/docs/Az.PolicyInsights.md Adds module-level help index page.
src/PolicyInsights/PolicyInsights.Autorest/custom/Start-AzPolicyComplianceScan.ps1 Adds custom wrapper cmdlet routing to the correct internal evaluation call.
src/PolicyInsights/PolicyInsights.Autorest/custom/Remove-AzPolicyAttestation.ps1 Adds custom wrapper to work around identity/resourceId parsing behavior.
src/PolicyInsights/PolicyInsights.Autorest/custom/README.md Adds guidance for custom cmdlets and supported customization mechanisms.
src/PolicyInsights/PolicyInsights.Autorest/custom/Get-AzPolicyStateSummary.ps1 Adds custom wrapper for summarize operation and output shaping.
src/PolicyInsights/PolicyInsights.Autorest/custom/Get-AzPolicyState.ps1 Adds custom wrapper with -All semantics and internal query routing.
src/PolicyInsights/PolicyInsights.Autorest/custom/Get-AzPolicyMetadata.ps1 Adds custom wrapper for list/get metadata with output shaping.
src/PolicyInsights/PolicyInsights.Autorest/custom/Get-AzPolicyEvent.ps1 Adds custom wrapper for listing policy events.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/Summary.cs Adds model extension to surface compliant-resource counts.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/Remediation.cs Adds model extension to carry deployment details when requested.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/PolicyState.cs Adds model alias property for policy evaluation details.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/PolicyAssignmentSummary.cs Adds model extension to surface compliant-resource counts in assignment summaries.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List7.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List6.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List5.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List4.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List3.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List2.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List1.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyState_List.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyRemediationDeployment_List3.cs Overrides paging to use POST for nextLink follow in deployments list variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyRemediationDeployment_List2.cs Overrides paging to use POST for nextLink follow in deployments list variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyRemediationDeployment_List1.cs Overrides paging to use POST for nextLink follow in deployments list variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyRemediationDeployment_List.cs Overrides paging to use POST for nextLink follow in deployments list variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyMetadata_List.cs Overrides list paging behavior to stop once Top is satisfied.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List7.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List6.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List5.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List4.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List3.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List2.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List1.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/GetAzPolicyEvent_List.cs Overrides paging behavior (Top enforcement + POST nextLink follow) for a generated events query variant.
src/PolicyInsights/PolicyInsights.Autorest/custom/GeneratedOverrides/ExpressionEvaluationDetails.cs Overrides JSON deserialization to preserve complex values as stringified JSON.
src/PolicyInsights/PolicyInsights.Autorest/custom/Az.PolicyInsights.custom.psm1 Adds the custom module entrypoint that imports private/internal modules and dot-sources script cmdlets.
src/PolicyInsights/PolicyInsights.Autorest/Properties/AssemblyInfo.cs Adds assembly metadata for the AutoRest project.
src/PolicyInsights/PolicyInsights.Autorest/.gitignore Adds module-local ignore rules for generated/build artifacts.
src/PolicyInsights/PolicyInsights.Autorest/.gitattributes Adds basic text normalization configuration.

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@VeryEarly VeryEarly self-assigned this Apr 3, 2026
@VeryEarly
Copy link
Copy Markdown
Collaborator

before reviewing this PR, please create a new PR to announce breaking changes ASAP, otherwise it cannot be accepted during build event.

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

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.

3 participants