Closed GABRIELNGBTUC closed 1 month ago
@GABRIELNGBTUC Wanted to check to make sure you were running the latest release? Your stacks cmdlets should be version 7.2.0 if you run Get-Command New-AzResourceGroupDeploymentStack
. There was an issue with surfacing errors in 7.1.0, but it should be fixed with 7.2.0.
Hello.
I was on 7.1.0. After upgrading, the expected error message is indeed showcased.
Describe the bug
When deploying a stack with an invalid deployment, the error returned by the CLI is usually not informative regarding to the actual error. This is particularly problematic to troubleshoot deployment failures in a CI/CD pipeline.
Since the command already seem to receive the failure reason from it's validation check, it should be exposed to the end-user instead of returning generic error messages.
To Reproduce Deploy a stack with the following bicep file and pass a string to the expected parameter instead of an object
The error message will simply say that validation failed without any guidance.
The only way to retrieve the reason for the failure is to run the command with the
-Debug
switch and look at the response body from Azure:Another example is when using keyvault references in a parameter file. If the identity does not have the permissions necessary on the keyvault, the stack creation/update will simply return
Bad request 400
as an error. However, the real error that should be exposed after the validation failure is that the identity does not have the permissionMicrosoft.KeyVault/vaults/deploy/action
on the KeyVault.This is another error message correctly reflected in
New-AzResourceGroupDeployment
but not through the stacks powershell commandsExpected behavior
The command returns the reason why the creation of the stacked failed.
For example, when using
New-AzResourceGroupDeployment
, the reason for the failure is clearly printed in the console:New-AzResourceGroupDeployment: 15:41:40 - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The provided value for the template parameter 'test' is not valid. Expected a value of type 'Object', but received a value of type 'String'. Please see https://aka.ms/arm-create-parameter-file for usage details.'. New-AzResourceGroupDeployment: The deployment validation failed