Skip to content

Azure Policy TSP Gen, Enrollments - #29909

Open
dunnryan wants to merge 7 commits into
Azure:mainfrom
dunnryan:add-enrollments-cmdlets
Open

Azure Policy TSP Gen, Enrollments #29909
dunnryan wants to merge 7 commits into
Azure:mainfrom
dunnryan:add-enrollments-cmdlets

Conversation

@dunnryan

@dunnryan dunnryan commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Switched to using TypeSpec Generation in Policy cmdlets and added CRUD cmdlets for Policy Enrollment resource.

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 July 27, 2026 22:37
@a0x1ab

a0x1ab commented Jul 27, 2026

Copy link
Copy Markdown
Member

/azp run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings July 27, 2026 23:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 73 out of 224 changed files in this pull request and generated 10 comments.

Comment thread src/Resources/Policy.Autorest/test/PolicyDefinitionWithUri.Recording.json Outdated
Comment on lines 9 to +11
# Az.Policy Module
## Description
Microsoft Azure PowerShell: Policy cmdlets
${$project.metadata.description}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@VeryEarly Is this an issue with the type spec generation? I don't know where this gets populated from, but I know these docs files are auto generated

Comment thread src/Resources/Policy.Autorest/custom/Update-AzPolicyEnrollment.ps1
Comment thread src/Resources/Policy.Autorest/custom/New-AzPolicyEnrollment.ps1
Comment thread src/Resources/Policy.Autorest/custom/Any.cs
Comment thread src/Resources/Policy.Autorest/custom/Any.cs
Comment thread src/Resources/Policy.Autorest/custom/Any.cs
Comment thread src/Resources/Policy.Autorest/docs/Update-AzPolicyEnrollment.md Outdated
Comment thread src/Resources/Policy.Autorest/Properties/AssemblyInfo.cs
Comment thread src/Resources/Policy.Autorest/Properties/AssemblyInfo.cs Outdated
Copilot AI review requested due to automatic review settings July 27, 2026 23:45
@a0x1ab

a0x1ab commented Jul 27, 2026

Copy link
Copy Markdown
Member

/azp run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 73 out of 224 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (3)

src/Resources/Policy.Autorest/Properties/AssemblyInfo.cs:5

  • AssemblyInfo.cs now has conflicting/duplicated header text (MIT + Apache license blocks and duplicated copyright), and the AutoRest note has a missing space in "Generator.Changes". This looks like an accidental merge of two templates and should be normalized to a single correct header.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the ""License"");

src/Resources/Policy.Autorest/test/NewPolicySetDefinition.Recording.json:74

  • Recording includes real user email and AAD object id in the error message. Please scrub these values to stable placeholders.
    src/Resources/Policy.Autorest/test/NewPolicySetDefinitionVersion.Recording.json:74
  • Recording includes real user email and AAD object id in the error payload; please scrub to placeholders to avoid committing personal data.

Comment thread src/Resources/Policy.Autorest/README.md
Comment thread src/Resources/Policy.Autorest/examples/Update-AzPolicyEnrollment.md Outdated
Comment thread src/Resources/Policy.Autorest/docs/Update-AzPolicyEnrollment.md Outdated
Comment thread src/Resources/Policy.Autorest/examples/New-AzPolicyEnrollment.md Outdated
@VeryEarly

Copy link
Copy Markdown
Collaborator

/azp run

Copilot AI review requested due to automatic review settings July 28, 2026 22:25
@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines:
Successfully started running 3 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 73 out of 230 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

src/Resources/Policy.Autorest/Properties/AssemblyInfo.cs:15

  • The file header now contains duplicated copyright lines and two different license headers (MIT and Apache 2.0). This is conflicting/ambiguous and could cause compliance confusion. Please keep a single, correct license header for this project and remove duplicates.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the ""License"");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ""AS IS"" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
// is regenerated.

src/Resources/Policy.Autorest/custom/Update-AzPolicyEnrollment.ps1:257

  • When Metadata is preserved from the existing enrollment, it is assigned as a PSCustomObject. Because New-AzPolicyEnrollment declares -Metadata as [string], PowerShell may stringify that object (often to an empty string), which can unintentionally clear metadata or throw in ResolvePolicyMetadataParameter. Serialize the existing metadata to JSON before passing it to New-AzPolicyEnrollment so it round-trips reliably.
    if (!$calledParameters.Metadata -and $existing.Metadata -and @($existing.Metadata.PSObject.Properties).Count -gt 0) {
        $calledParameters.Metadata = $existing.Metadata
    }

src/Resources/Policy.Autorest/custom/Update-AzPolicyExemption.ps1:273

  • When Metadata is preserved from the existing exemption, it is assigned as a PSCustomObject. Because New-AzPolicyExemption declares -Metadata as [string], PowerShell may stringify that object (often to an empty string), which can unintentionally clear metadata or fail parsing. Serialize the existing metadata to JSON before passing it through to ensure it round-trips reliably.
    if (!$calledParameters.Metadata -and $existing.Metadata -and @($existing.Metadata.PSObject.Properties).Count -gt 0) {
        $calledParameters.Metadata = $existing.Metadata
    }

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.

4 participants