Skip to content

Do not review-powershell cmdlet#29324

Open
anamikapan11 wants to merge 9 commits intoAzure:mainfrom
anamikapan11:anapandey/pwcmdlet
Open

Do not review-powershell cmdlet#29324
anamikapan11 wants to merge 9 commits intoAzure:mainfrom
anamikapan11:anapandey/pwcmdlet

Conversation

@anamikapan11
Copy link
Copy Markdown

Description

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 March 26, 2026 05:57
@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.

@anamikapan11 anamikapan11 changed the title Anapandey/pwcmdlet Do not review-powershell cmdlet Mar 26, 2026
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

This PR updates the Az.Resources module to support Deployment Stacks What-If functionality, including regenerating the underlying Resources.Management SDK against a newer DeploymentStacks API version and adding new cmdlets/models to surface What-If results.

Changes:

  • Export new Deployment Stack What-If cmdlets in Az.Resources.psd1.
  • Regenerate Resources.Management.Sdk for DeploymentStacks 2025-07-01, adding new What-If models/operations and updating several existing models/headers.
  • Add new ResourceManager cmdlets and PowerShell models/formatting helpers to execute and display Deployment Stack What-If results.

Reviewed changes

Copilot reviewed 16 out of 81 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Resources/Resources/Az.Resources.psd1 Exports new Deployment Stack What-If cmdlets.
src/Resources/Resources.Management.Sdk/README.md Updates AutoRest tag/commit and adds tag config for deploymentstacks 2025-07.
src/Resources/Resources.Management.Sdk/Generated/Models/ResourceReferenceExtended.cs Regenerated model: adds extensible resource fields and validation.
src/Resources/Resources.Management.Sdk/Generated/Models/ResourceReference.cs Regenerated model: adds extensible resource fields and validation.
src/Resources/Resources.Management.Sdk/Generated/Models/Resource.cs Regenerated common ARM resource model shape (now includes systemData).
src/Resources/Resources.Management.Sdk/Generated/Models/ProxyResource.cs Regenerated proxy resource base type (now derives from Resource).
src/Resources/Resources.Management.Sdk/Generated/Models/ManagedResourceReference.cs Regenerated model: adds extensible identifiers and updated denyStatus values.
src/Resources/Resources.Management.Sdk/Generated/Models/ErrorResponse.cs Regenerated error response model (now wraps ErrorDetail).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultsAtSubscriptionWhatIfHeaders.cs New generated headers type for subscription-scope What-If.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultsAtSubscriptionCreateOrUpdateHeaders.cs New generated headers type for subscription-scope create/update.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultsAtResourceGroupWhatIfHeaders.cs New generated headers type for RG-scope What-If.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultsAtResourceGroupCreateOrUpdateHeaders.cs New generated headers type for RG-scope create/update.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultsAtManagementGroupWhatIfHeaders.cs New generated headers type for MG-scope What-If.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultsAtManagementGroupCreateOrUpdateHeaders.cs New generated headers type for MG-scope create/update.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResultProperties.cs New generated What-If result properties model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResult.cs New generated What-If result resource model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResourceChangeResourceConfigurationChanges.cs New generated property-level configuration change model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResourceChangeManagementStatusChange.cs New generated management status change model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResourceChangeDenyStatusChange.cs New generated deny status change model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfResourceChange.cs New generated resource change model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfPropertyChangeType.cs New generated constants for What-If property change types.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfPropertyChange.cs New generated model for nested property deltas.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfChangeType.cs New generated constants for What-If change types.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfChangeDeploymentScopeChange.cs New generated model for predicted deployment scope changes.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfChangeDenySettingsChange.cs New generated model for predicted denySettings changes.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfChangeCertainty.cs New generated constants for prediction certainty.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksWhatIfChange.cs New generated model containing predicted changes.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksValidateStackAtSubscriptionHeaders.cs Regenerated validate headers (Retry-After now int?).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksValidateStackAtResourceGroupHeaders.cs Regenerated validate headers (Retry-After now int?).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksValidateStackAtManagementGroupHeaders.cs Regenerated validate headers (Retry-After now int?).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksResourcesWithoutDeleteSupportEnum.cs New generated enum constants for delete-unsupported resources behavior.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksManagementStatus.cs New generated enum constants for management status.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksDiagnosticLevel.cs New generated enum constants for diagnostic level.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksDiagnostic.cs New generated diagnostic model.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksDeleteDetachEnum.cs Regenerated enum constants with improved docs.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksDeleteAtSubscriptionHeaders.cs Regenerated delete headers (adds Retry-After).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksDeleteAtResourceGroupHeaders.cs Regenerated delete headers (adds Retry-After).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksDeleteAtManagementGroupHeaders.cs Regenerated delete headers (adds Retry-After).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksCreateOrUpdateAtSubscriptionHeaders.cs New generated create/update headers for subscription scope.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksCreateOrUpdateAtResourceGroupHeaders.cs New generated create/update headers for RG scope.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStacksCreateOrUpdateAtManagementGroupHeaders.cs New generated create/update headers for MG scope.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStackValidateProperties.cs Regenerated validate properties (adds extensions + validation level).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStackTemplateDefinition.cs Regenerated template type (IDictionary<string, object>).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStackProvisioningState.cs Regenerated provisioning states (adds initializing/running + docs).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentStackProperties.cs Regenerated stack properties (adds extension/external inputs + new fields).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentParameter.cs Regenerated parameter model (adds expression).
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentExternalInputDefinition.cs New generated model for external input definitions.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentExternalInput.cs New generated model for external inputs.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentExtensionConfigItem.cs New generated model for extension config items.
src/Resources/Resources.Management.Sdk/Generated/Models/DeploymentExtension.cs New generated model for extension usage details.
src/Resources/Resources.Management.Sdk/Generated/Models/DenyStatusMode.cs Regenerated deny status mode constants (adds unknown).
src/Resources/Resources.Management.Sdk/Generated/Models/ActionOnUnmanage.cs Regenerated action model (adds resourcesWithoutDeleteSupport).
src/Resources/Resources.Management.Sdk/Generated/IDeploymentStacksWhatIfResultsAtSubscriptionOperations.cs New generated operations interface for subscription-scope What-If results.
src/Resources/Resources.Management.Sdk/Generated/IDeploymentStacksWhatIfResultsAtResourceGroupOperations.cs New generated operations interface for RG-scope What-If results.
src/Resources/Resources.Management.Sdk/Generated/IDeploymentStacksWhatIfResultsAtManagementGroupOperations.cs New generated operations interface for MG-scope What-If results.
src/Resources/Resources.Management.Sdk/Generated/IDeploymentStacksClient.cs Regenerated client interface (SubscriptionId is Guid; adds What-If ops groups).
src/Resources/Resources.Management.Sdk/Generated/DeploymentStacksWhatIfResultsAtSubscriptionOperationsExtensions.cs New generated extension helpers for subscription-scope What-If ops.
src/Resources/Resources.Management.Sdk/Generated/DeploymentStacksWhatIfResultsAtResourceGroupOperationsExtensions.cs New generated extension helpers for RG-scope What-If ops.
src/Resources/Resources.Management.Sdk/Generated/DeploymentStacksWhatIfResultsAtManagementGroupOperationsExtensions.cs New generated extension helpers for MG-scope What-If ops.
src/Resources/Resources.Management.Sdk/Generated/DeploymentStacksClient.cs Regenerated client (ApiVersion 2025-07-01; wires What-If ops).
src/Resources/ResourceManager/SdkModels/Deployments/PSDeploymentStackWhatIfResult.cs New PowerShell-facing What-If result model + nested DTOs.
src/Resources/ResourceManager/SdkModels/Deployments/PSDeploymentStackWhatIfParameters.cs New parameter DTO used to build/route What-If requests.
src/Resources/ResourceManager/SdkModels/DeploymentStacks/PSDenySettingsMode.cs Moves enum into SdkModels.DeploymentStacks namespace.
src/Resources/ResourceManager/ResourceManager.csproj Adds DeploymentStacks track2 package and updates Azure.Core.
src/Resources/ResourceManager/Implementation/DeploymentStacks/GetAzSubscriptionDeploymentStackWhatIf.cs New cmdlet for subscription-scope deployment stack What-If.
src/Resources/ResourceManager/Implementation/DeploymentStacks/GetAzResourceGroupDeploymentStackWhatIf.cs New cmdlet for RG-scope deployment stack What-If.
src/Resources/ResourceManager/Implementation/DeploymentStacks/GetAzManagementGroupDeploymentStackWhatIf.cs New cmdlet for MG-scope deployment stack What-If.
src/Resources/ResourceManager/Implementation/CmdletBase/DeploymentStacksCmdletBase.cs Minor update to imports.
src/Resources/ResourceManager/Implementation/CmdletBase/DeploymentStackWhatIfCmdlet.cs New cmdlet base handling status output + invoking SDK client What-If.
src/Resources/ResourceManager/Formatters/ColoredStringBuilder.cs Adds insertion/indent helpers and new newline utilities.
src/Resources/ResourceManager/Formatters/Color.cs Adds Cyan ANSI color constant.
Comments suppressed due to low confidence (1)

src/Resources/Resources.Management.Sdk/README.md:180

  • The README says the directive is a "Temporary override to make subscription id GUID a string", but the generated client now uses System.Guid SubscriptionId. This makes the comment misleading; either update the comment to reflect the current intent (e.g., keep GUID typing) or adjust/remove the directive if string typing is still required.

Comment on lines +23 to +101
/// <summary>
/// Cmdlet to preview changes for a Subscription Deployment Stack.
/// </summary>
[Cmdlet("Get", AzureRMConstants.AzureRMPrefix + "SubscriptionDeploymentStackWhatIf",
DefaultParameterSetName = ParameterlessTemplateFileParameterSetName)]
[OutputType(typeof(PSDeploymentStackWhatIfResult))]
public class GetAzSubscriptionDeploymentStackWhatIf : DeploymentStackWhatIfCmdlet
{
#region Cmdlet Parameters

[Alias("StackName")]
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The name of the DeploymentStack to preview changes for.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The location to store deployment data.")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Description for the stack.")]
public string Description { get; set; }

[Parameter(Mandatory = false, HelpMessage = "The scope for the deployment stack. Determines where managed resources can be deployed.")]
public string DeploymentScope { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Action to take on resources that become unmanaged. Possible values include: " +
"'detachAll', 'deleteResources', and 'deleteAll'.")]
public PSActionOnUnmanage ActionOnUnmanage { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Mode for DenySettings. Possible values include: 'denyDelete', 'denyWriteAndDelete', and 'none'.")]
public PSDenySettingsMode DenySettingsMode { get; set; }

[Parameter(Mandatory = false, HelpMessage = "List of AAD principal IDs excluded from the lock. Up to 5 principals are permitted.")]
public string[] DenySettingsExcludedPrincipal { get; set; }

[Parameter(Mandatory = false, HelpMessage = "List of role-based management operations excluded from the denySettings. Up to 200 actions are permitted.")]
public string[] DenySettingsExcludedAction { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Apply to child scopes.")]
public SwitchParameter DenySettingsApplyToChildScopes { get; set; }

#endregion

#region Cmdlet Implementation

protected override PSDeploymentStackWhatIfParameters BuildWhatIfParameters()
{
var shouldDeleteResources = (ActionOnUnmanage is PSActionOnUnmanage.DeleteAll || ActionOnUnmanage is PSActionOnUnmanage.DeleteResources);
var shouldDeleteResourceGroups = (ActionOnUnmanage is PSActionOnUnmanage.DeleteAll);
var shouldDeleteManagementGroups = (ActionOnUnmanage is PSActionOnUnmanage.DeleteAll);

return new PSDeploymentStackWhatIfParameters
{
StackName = Name,
Location = Location,
TemplateFile = TemplateFile,
TemplateUri = !string.IsNullOrEmpty(protectedTemplateUri) ? protectedTemplateUri : TemplateUri,
TemplateSpecId = TemplateSpecId,
TemplateObject = TemplateObject,
TemplateParameterUri = TemplateParameterUri,
TemplateParameterObject = GetTemplateParameterObject(),
Description = Description,
DeploymentScope = DeploymentScope,
ResourcesCleanupAction = shouldDeleteResources ? "delete" : "detach",
ResourceGroupsCleanupAction = shouldDeleteResourceGroups ? "delete" : "detach",
ManagementGroupsCleanupAction = shouldDeleteManagementGroups ? "delete" : "detach",
DenySettingsMode = DenySettingsMode != 0 ? DenySettingsMode.ToString() : null,
DenySettingsExcludedPrincipals = DenySettingsExcludedPrincipal,
DenySettingsExcludedActions = DenySettingsExcludedAction,
DenySettingsApplyToChildScopes = DenySettingsApplyToChildScopes.IsPresent
};
}

#endregion
}
} No newline at end of file
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

New Deployment Stack What-If cmdlets are introduced here, but there don’t appear to be corresponding scenario/unit tests covering them. Please add test coverage (e.g., new scenario tests in src/Resources/Resources.Test/ScenarioTests plus test scripts) to validate the What-If request construction and basic success/error flows at subscription/resource group/management group scope.

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +111
this.Insert(index, color.ToString());
}
this.Insert(index, value + Environment.NewLine);
if (color != Color.Reset)
{
this.Insert(index, Color.Reset.ToString());
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

InsertLine inserts multiple values at the same index, but StringBuilder.Insert pushes existing content to the right. With the current order (color -> text -> reset), the final output becomes reset -> text -> color, which breaks the intended ANSI coloring. Insert in reverse order (reset, then text, then color) or adjust indices so the final sequence is color + text + reset.

Suggested change
this.Insert(index, color.ToString());
}
this.Insert(index, value + Environment.NewLine);
if (color != Color.Reset)
{
this.Insert(index, Color.Reset.ToString());
// Insert reset first so it ends up after the text once all inserts are applied.
this.Insert(index, Color.Reset.ToString());
}
// Insert the text next so it ends up between the color and reset codes.
this.Insert(index, value + Environment.NewLine);
if (color != Color.Reset)
{
// Insert the color code last so it appears before the text.
this.Insert(index, color.ToString());

Copilot uses AI. Check for mistakes.
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 26, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 26, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

This commit implements -WhatIf parameter support for all Deployment Stack
cmdlets (New/Set) across all scopes (ResourceGroup, Subscription, ManagementGroup).

Key changes:
- Added WhatIf handling to New-AzResourceGroupDeploymentStack
- Added WhatIf handling to Set-AzResourceGroupDeploymentStack
- Added WhatIf handling to New-AzSubscriptionDeploymentStack
- Added WhatIf handling to Set-AzSubscriptionDeploymentStack
- Added WhatIf handling to New-AzManagementGroupDeploymentStack

Implementation details:
- DeploymentStacksSdkClient: Updated WhatIf methods to use polling approach
  instead of separate WhatIf API call that returns BadRequest
- Resources.format.ps1xml: Added custom view for PSDeploymentStackWhatIfResult
  to display formatted output by default (matching Azure CLI)
- Error handling: Gracefully handles scenarios where WhatIf API is not available

Output format matches Azure CLI with:
- Color-coded change symbols (+ Create, ~ Modify, - Delete, v Detach, = NoChange)
- Legend explaining symbols
- Stack property changes (DeploymentScope, DenySettings)
- Managed resource changes with before/after states
- Management status transitions
- Deletion summaries

The formatter (DeploymentStackWhatIfFormatter) was already present and is now
properly integrated via the custom format view.
Copilot AI review requested due to automatic review settings March 27, 2026 16:09
Includes:
* Quick start test script with automated checks
* Comprehensive test guide with all scenarios
* Test checklist for testers to fill out
* Template files for different test scenarios
* Setup instructions and prerequisites
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

Copilot reviewed 28 out of 93 changed files in this pull request and generated 3 comments.

Comment on lines +146 to +149

for (int i = currentText.Length - 1; i >= 0 && currentText[i] == '\n'; i--)
{
existingNewlines++;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

EnsureNumNewLines counts only consecutive '\n' characters at the end of the buffer. When the buffer contains Windows newlines ("\r\n" from AppendLine/Environment.NewLine), the trailing characters are not consecutive '\n', so this undercounts existing newlines and may append extra blank lines. Consider counting trailing newline sequences in an OS-agnostic way (e.g., trim trailing "\r"/"\n" and compute how many newline sequences are present, or iterate from the end handling "\r\n" as one).

Suggested change
for (int i = currentText.Length - 1; i >= 0 && currentText[i] == '\n'; i--)
{
existingNewlines++;
int index = currentText.Length - 1;
// Count trailing newline sequences in an OS-agnostic way:
// - Treat "\r\n" as a single newline
// - Also handle lone '\n' and lone '\r'
while (index >= 0)
{
if (currentText[index] == '\n')
{
existingNewlines++;
index--;
// Consume preceding '\r' if this is a Windows newline sequence "\r\n"
if (index >= 0 && currentText[index] == '\r')
{
index--;
}
}
else if (currentText[index] == '\r')
{
existingNewlines++;
index--;
}
else
{
break;
}

Copilot uses AI. Check for mistakes.
Comment on lines 45 to +48
/// <summary>
/// The ID of the target subscription.
/// The ID of the target subscription. The value must be an UUID.
/// </summary>
string SubscriptionId { get; set;}
System.Guid SubscriptionId { get; set;}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

DeploymentStacksClient/IDeploymentStacksClient now exposes SubscriptionId as System.Guid, while other generated ARM clients in this repo use string SubscriptionId. This inconsistency can break shared client-factory code that sets SubscriptionId from Azure context (usually a string) and makes this client harder to use consistently. Consider keeping SubscriptionId as string (via swagger/directive) or ensure the factory path explicitly parses/sets the Guid and all call sites are updated accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +165
# Temporary override to make subscription id GUID a string.
directive:
- from: deploymentStacks.json
where: $
transform: $ = $.replace(/common-types\/resource-management\/v5\/types.json#\/parameters\/SubscriptionIdParameter/g, 'common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter');
```
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The README says the directive is a temporary override to make SubscriptionId a string, but the generated DeploymentStacksClient/IDeploymentStacksClient in this PR uses System.Guid for SubscriptionId. Either the directive/comment is no longer accurate, or the override isn’t being applied as intended. Please reconcile this so the generation docs reflect the actual output (or fix the directive so SubscriptionId becomes string if that’s required).

Copilot uses AI. Check for mistakes.
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 27, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 27, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI review requested due to automatic review settings March 27, 2026 18:35
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 27, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

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

Copilot reviewed 32 out of 97 changed files in this pull request and generated 7 comments.

Comment on lines +101 to +126
// Handle WhatIf scenario
if (MyInvocation.BoundParameters.ContainsKey("WhatIf") && ((SwitchParameter)MyInvocation.BoundParameters["WhatIf"]).ToBool())
{
var whatIfResult = DeploymentStacksSdkClient.ExecuteSubscriptionDeploymentStackWhatIf(
deploymentStackName: Name,
location: Location,
templateFile: TemplateFile,
templateUri: !string.IsNullOrEmpty(protectedTemplateUri) ? protectedTemplateUri : TemplateUri,
templateSpec: TemplateSpecId,
templateObject: TemplateObject,
parameterUri: TemplateParameterUri,
parameters: GetTemplateParameterObject(),
description: Description,
resourcesCleanupAction: shouldDeleteResources ? "delete" : "detach",
resourceGroupsCleanupAction: shouldDeleteResourceGroups ? "delete" : "detach",
managementGroupsCleanupAction: shouldDeleteManagementGroups ? "delete" : "detach",
deploymentScope: deploymentScope,
denySettingsMode: DenySettingsMode.ToString(),
denySettingsExcludedPrincipals: DenySettingsExcludedPrincipal,
denySettingsExcludedActions: DenySettingsExcludedAction,
denySettingsApplyToChildScopes: DenySettingsApplyToChildScopes.IsPresent,
bypassStackOutOfSyncError: BypassStackOutOfSyncError.IsPresent
);

WriteObject(whatIfResult);
return;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

In the -WhatIf branch this cmdlet returns whatIfResult (a PSDeploymentStackWhatIfResult), but the cmdlet’s declared OutputType is PSDeploymentStack. This mismatch affects help and downstream tooling. Consider updating the OutputType to include the What-If result type (or separating into a dedicated cmdlet/parameter).

Copilot uses AI. Check for mistakes.
Comment on lines +103 to +128
// Handle WhatIf scenario
if (MyInvocation.BoundParameters.ContainsKey("WhatIf") && ((SwitchParameter)MyInvocation.BoundParameters["WhatIf"]).ToBool())
{
var whatIfResult = DeploymentStacksSdkClient.ExecuteSubscriptionDeploymentStackWhatIf(
deploymentStackName: Name,
location: Location,
templateFile: TemplateFile,
templateUri: !string.IsNullOrEmpty(protectedTemplateUri) ? protectedTemplateUri : TemplateUri,
templateSpec: TemplateSpecId,
templateObject: TemplateObject,
parameterUri: TemplateParameterUri,
parameters: GetTemplateParameterObject(),
description: Description,
resourcesCleanupAction: shouldDeleteResources ? "delete" : "detach",
resourceGroupsCleanupAction: shouldDeleteResourceGroups ? "delete" : "detach",
managementGroupsCleanupAction: shouldDeleteManagementGroups ? "delete" : "detach",
deploymentScope: deploymentScope,
denySettingsMode: DenySettingsMode.ToString(),
denySettingsExcludedPrincipals: DenySettingsExcludedPrincipal,
denySettingsExcludedActions: DenySettingsExcludedAction,
denySettingsApplyToChildScopes: DenySettingsApplyToChildScopes.IsPresent,
bypassStackOutOfSyncError: BypassStackOutOfSyncError.IsPresent
);

WriteObject(whatIfResult);
return;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

In the -WhatIf branch this cmdlet returns whatIfResult (a PSDeploymentStackWhatIfResult), but the cmdlet’s declared OutputType is PSDeploymentStack. This mismatch affects help and downstream tooling. Consider updating the OutputType to include the What-If result type (or separating into a dedicated cmdlet/parameter).

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +23
if ($psVersion.Major -lt 7) {
Write-Host "? PowerShell 7+ required. You have: $psVersion" -ForegroundColor Red
Write-Host " Download from: https://aka.ms/powershell" -ForegroundColor Yellow
exit 1
} else {
Write-Host "? PowerShell version: $psVersion" -ForegroundColor Green
}

# Check .NET SDK
try {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

This script hard-requires PowerShell 7+ (if ($psVersion.Major -lt 7) { ... exit 1 }) but it lives outside the repository tooling locations (/tools/, pipelines). Either move these bug bash scripts under a tooling directory, or make them PowerShell 5.1-compatible; at minimum, add #Requires -Version 7.0 so the requirement is enforced by PowerShell consistently.

Suggested change
if ($psVersion.Major -lt 7) {
Write-Host "? PowerShell 7+ required. You have: $psVersion" -ForegroundColor Red
Write-Host " Download from: https://aka.ms/powershell" -ForegroundColor Yellow
exit 1
} else {
Write-Host "? PowerShell version: $psVersion" -ForegroundColor Green
}
# Check .NET SDK
try {
Write-Host "? PowerShell version: $psVersion" -ForegroundColor Green
# Note: This script is intended to work on PowerShell 5.1+.
# PowerShell 7+ is recommended for best cross-platform support, but not required.
# Check .NET SDK
try {
try {

Copilot uses AI. Check for mistakes.
/// The ID of the target subscription. The value must be an UUID.
/// </summary>
public string SubscriptionId { get; set;}
public System.Guid SubscriptionId { get; set;}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

DeploymentStacksClient.SubscriptionId is now System.Guid. The Az client factory path typically sets SubscriptionId using the context subscription ID string; if this property isn’t set correctly, requests will be sent with an empty/default subscriptionId. Recommend reverting to string for compatibility or ensuring the factory reliably converts/assigns the subscription id value.

Suggested change
public System.Guid SubscriptionId { get; set;}
public string SubscriptionId { get; set;}

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +117
// Handle WhatIf scenario
if (MyInvocation.BoundParameters.ContainsKey("WhatIf") && ((SwitchParameter)MyInvocation.BoundParameters["WhatIf"]).ToBool())
{
var whatIfResult = DeploymentStacksSdkClient.ExecuteResourceGroupDeploymentStackWhatIf(
deploymentStackName: Name,
resourceGroupName: ResourceGroupName,
templateFile: TemplateFile,
templateUri: !string.IsNullOrEmpty(protectedTemplateUri) ? protectedTemplateUri : TemplateUri,
templateSpec: TemplateSpecId,
templateObject: TemplateObject,
parameterUri: TemplateParameterUri,
parameters: GetTemplateParameterObject(),
description: Description,
resourcesCleanupAction: shouldDeleteResources ? "delete" : "detach",
resourceGroupsCleanupAction: shouldDeleteResourceGroups ? "delete" : "detach",
managementGroupsCleanupAction: shouldDeleteManagementGroups ? "delete" : "detach",
denySettingsMode: DenySettingsMode.ToString(),
denySettingsExcludedPrincipals: DenySettingsExcludedPrincipal,
denySettingsExcludedActions: DenySettingsExcludedAction,
denySettingsApplyToChildScopes: DenySettingsApplyToChildScopes.IsPresent,
bypassStackOutOfSyncError: BypassStackOutOfSyncError.IsPresent
);

WriteObject(whatIfResult);
return;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

In the -WhatIf branch this cmdlet returns whatIfResult (a PSDeploymentStackWhatIfResult), but the cmdlet’s declared OutputType is PSDeploymentStack. This mismatch affects help and downstream tooling. Consider updating the OutputType to include the What-If result type (or separating into a dedicated cmdlet/parameter).

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +118
// Handle WhatIf scenario
if (MyInvocation.BoundParameters.ContainsKey("WhatIf") && ((SwitchParameter)MyInvocation.BoundParameters["WhatIf"]).ToBool())
{
var whatIfResult = DeploymentStacksSdkClient.ExecuteResourceGroupDeploymentStackWhatIf(
deploymentStackName: Name,
resourceGroupName: ResourceGroupName,
templateFile: TemplateFile,
templateUri: !string.IsNullOrEmpty(protectedTemplateUri) ? protectedTemplateUri : TemplateUri,
templateSpec: TemplateSpecId,
templateObject: TemplateObject,
parameterUri: TemplateParameterUri,
parameters: GetTemplateParameterObject(),
description: Description,
resourcesCleanupAction: shouldDeleteResources ? "delete" : "detach",
resourceGroupsCleanupAction: shouldDeleteResourceGroups ? "delete" : "detach",
managementGroupsCleanupAction: shouldDeleteManagementGroups ? "delete" : "detach",
denySettingsMode: DenySettingsMode.ToString(),
denySettingsExcludedPrincipals: DenySettingsExcludedPrincipal,
denySettingsExcludedActions: DenySettingsExcludedAction,
denySettingsApplyToChildScopes: DenySettingsApplyToChildScopes.IsPresent,
bypassStackOutOfSyncError: BypassStackOutOfSyncError.IsPresent
);

WriteObject(whatIfResult);
return;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

In the -WhatIf branch this cmdlet returns whatIfResult (a PSDeploymentStackWhatIfResult), but the cmdlet’s declared OutputType is PSDeploymentStack. This mismatch affects help and downstream tooling. Consider updating the OutputType to include the What-If result type (or separating into a dedicated cmdlet/parameter).

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +9
git clone https://github.com/anamikapan11/azure-powershell
cd azure-powershell
git checkout anapandey/pwcmdlet
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The bug bash docs hardcode a personal fork URL and branch name (e.g., github.com/anamikapan11/azure-powershell, anapandey/pwcmdlet). After this PR merges, those instructions will be incorrect for readers/testers. Please update to reference the canonical repo/branch (or describe how to check out the PR branch) and remove fixed commit IDs where possible.

Suggested change
git clone https://github.com/anamikapan11/azure-powershell
cd azure-powershell
git checkout anapandey/pwcmdlet
git clone https://github.com/Azure/azure-powershell
cd azure-powershell
git checkout <branch-name>

Copilot uses AI. Check for mistakes.
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 27, 2026

/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