Conversation
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
There was a problem hiding this comment.
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.Sdkfor DeploymentStacks2025-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.
| /// <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 |
There was a problem hiding this comment.
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.
src/Resources/Resources.Management.Sdk/Generated/Models/ErrorResponse.cs
Outdated
Show resolved
Hide resolved
src/Resources/ResourceManager/Implementation/CmdletBase/DeploymentStacksCmdletBase.cs
Show resolved
Hide resolved
| this.Insert(index, color.ToString()); | ||
| } | ||
| this.Insert(index, value + Environment.NewLine); | ||
| if (color != Color.Reset) | ||
| { | ||
| this.Insert(index, Color.Reset.ToString()); |
There was a problem hiding this comment.
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.
| 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()); |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
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.
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
|
|
||
| for (int i = currentText.Length - 1; i >= 0 && currentText[i] == '\n'; i--) | ||
| { | ||
| existingNewlines++; |
There was a problem hiding this comment.
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).
| 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; | |
| } |
| /// <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;} |
There was a problem hiding this comment.
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.
| # 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'); | ||
| ``` |
There was a problem hiding this comment.
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).
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This reverts commit 2eea4e2.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| // 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; |
There was a problem hiding this comment.
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).
| // 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; |
There was a problem hiding this comment.
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).
| 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 { |
There was a problem hiding this comment.
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.
| 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 { |
| /// The ID of the target subscription. The value must be an UUID. | ||
| /// </summary> | ||
| public string SubscriptionId { get; set;} | ||
| public System.Guid SubscriptionId { get; set;} |
There was a problem hiding this comment.
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.
| public System.Guid SubscriptionId { get; set;} | |
| public string SubscriptionId { get; set;} |
| // 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; |
There was a problem hiding this comment.
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).
| // 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; |
There was a problem hiding this comment.
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).
| git clone https://github.com/anamikapan11/azure-powershell | ||
| cd azure-powershell | ||
| git checkout anapandey/pwcmdlet |
There was a problem hiding this comment.
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.
| 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> |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Description
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.