Skip to content

New-AzResourceGroupDeployment confirmation with -Force and -Confirm:$false #28034

@hallipr

Description

@hallipr

Description

When calling New-AzResourceGroupDeployment with -Debug, I'm prompted to confirm after template validation even when using -Confirm:$False -Force

Issue script & Debug output

~/> $DebugPreference = 'Continue'>
~/> New-AzResourceGroupDeployment -Name 'mcpf0ae6c1d' -ResourceGroupName '<redacted>' -TemplateFile '.\.work\template.json' -TemplateParameterObject $parameters -Debug -Force -Confirm:$False
DEBUG: [Common.Authentication]: Authenticating using Account: 'redacted', environment: 'AzureCloud', tenant: '<redacted>'

<< Auth details redacted >>

=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) - 
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - True
HomeAccountId - False
CorrelationId - <redacted>
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured: 

<redacted MSAL logs>

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://management.azure.com/subscriptions/<redacted>

Headers:
Accept-Language               : en-US
x-ms-client-request-id        : <redacted>

Body:
{
<redacted>  
}


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
<redacted>

Body:
{
  "id": "/subscriptions/<redacted>/providers/Microsoft.Resources/deployments/mcpf0ae6c1d",
  "name": "mcpf0ae6c1d",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "templateHash": "3966093699421575259",
    "parameters": {
     	<redacted>
    },
    "mode": "Incremental",
    "provisioningState": "Succeeded",
    "timestamp": "2025-06-26T18:06:36.2908086Z",
    "duration": "PT0S",
    "correlationId": "6b6394a1-dfe9-490e-9f9f-67b3a60af848",
    "providers": [
      {
        "namespace": "Microsoft.Resources",
        "resourceTypes": [
          {
            "resourceType": "deployments",
            "locations": [
              null
            ]
          }
        ]
      }
    ],
    "dependencies": [],
    "validatedResources": [
      <redacted>
    ]
  }
}


VERBOSE: 11:06:38 AM - Template is valid.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):

Environment data

~/> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

~/> Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     4.1.0                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     6.3.1                 Az.KeyVault                         {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateContact, Add-AzKeyVaultKey, Add-AzKeyVaultManagedStorageAccount…}
Script     7.10.0                Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}

Error output

~/> Resolve-AzError
DEBUG: 11:21:14 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:21:14 AM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 11:21:14 AM - using account id '<redacted>'...
DEBUG: 11:21:14 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet = [Resolve-AzError]. Returning default value [True].
DEBUG: 11:21:14 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].

   HistoryId: 18

Message        : The deployment validation failed
StackTrace     :    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.InvalidOperationException
InvocationInfo : {New-AzResourceGroupDeployment}
Line           : New-AzResourceGroupDeployment -Name '<redacted>f0ae6c1d' -ResourceGroupName 'SSS3PT_<redacted>ff2f5a09' -TemplateFile '.\.work\template.json' -TemplateParameterObject (Get-Content '.\.work\template.parameters.json' | ConvertFrom-Json     
                 -AsHashtable) -Debug -Force -Confirm:$False
Position       : At line:1 char:1
                 + New-AzResourceGroupDeployment -Name '<redacted>f0ae6c1d' -ResourceGroupName  …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 18

DEBUG: 11:21:14 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
Message        : 11:05:51 AM - Error: Code=InvalidResourceProperties; Message=The scale settings of account deployment is deprecated since API version '2023-05-01', please use 'sku' instead.

StackTrace     : 
Exception      : System.Exception
InvocationInfo : {New-AzResourceGroupDeployment}
Line           : New-AzResourceGroupDeployment -Name '<redacted>f0ae6c1d' -ResourceGroupName 'SSS3PT_<redacted>ff2f5a09' -TemplateFile '.\.work\template.json' -TemplateParameterObject (Get-Content '.\.work\template.parameters.json' | ConvertFrom-Json     
                 -AsHashtable) -Debug -Force -Confirm:$False
Position       : At line:1 char:1
                 + New-AzResourceGroupDeployment -Name '<redacted>f0ae6c1d' -ResourceGroupName  …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 18

DEBUG: 11:21:14 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
Message        : 11:05:51 AM - Error: Code=InvalidTemplateDeployment; Message=The template deployment '<redacted>f0ae6c1d' is not valid according to the validation procedure. The tracking id is '206ee6c2-8aab-4ff8-9d19-a339f23c9d22'. See inner errors for   
                 details.

StackTrace     : 
Exception      : System.Exception
InvocationInfo : {New-AzResourceGroupDeployment}
Line           : New-AzResourceGroupDeployment -Name '<redacted>f0ae6c1d' -ResourceGroupName 'SSS3PT_<redacted>ff2f5a09' -TemplateFile '.\.work\template.json' -TemplateParameterObject (Get-Content '.\.work\template.parameters.json' | ConvertFrom-Json     
                 -AsHashtable) -Debug -Force -Confirm:$False
Position       : At line:1 char:1
                 + New-AzResourceGroupDeployment -Name '<redacted>f0ae6c1d' -ResourceGroupName  …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 18


more of the same from 17 to 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARM - TemplatesPossible-SolutionSimilar-Issueneeds-author-feedbackMore information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions