Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

group deployment validate should offer better debug output #3975

Open lucagervasi opened 7 years ago

lucagervasi commented 7 years ago

Description

Issuing az group deployment create results in bogous error references, possibly referencing compiled json (template + parameters) line and column number. Sometimes it is hard to find errors. It would be handy to output some lines surrounding the error instead of just "line 25 column 1 - line 25 column 2 (char 539 - 540)" references. It would be handy having az group deployment validate offer an option to export compiled json.


Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: pip

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: Thu Jul 6 12:01:43 CEST 2017 azure-cli (2.0.2)

acr (2.0.0) acs (2.0.2) appservice (0.1.2) batch (2.0.0) cloud (2.0.0) component (2.0.0) configure (2.0.2) container (0.1.2) core (2.0.2) documentdb (0.1.2) feedback (2.0.0) find (0.0.1b1) iot (0.1.2) keyvault (2.0.0) lab (0.0.1) monitor (0.0.1) network (2.0.2) nspkg (2.0.0) profile (2.0.2) redis (0.1.1b3) resource (2.0.2) role (2.0.1) sql (2.0.0) storage (2.0.2) vm (2.0.2)

Python (Linux) 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

OS Version: What OS and version are you using?
Answer here: Fedora release 25 (Twenty Five)

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: GNU bash, version 4.3.43(1)-release (x86_64-redhat-linux-gnu)

leidegre commented 7 years ago

I second this, for example, from the resource manager API, I get this error

Deployment failed. Deployment template validation failed: 'The template resource 'appsettings' at line '1' and column '1682' is not valid: ...

Note the reference to column 1682. I can assure you that no such column exists in my resource template. It's essential that the line number can be traced back to the source, there's no excuse for this, this just turned a helpful error message into a useless error message.

Using the PowerShell cmdlet New-AzureRmResourceGroupDeployment this is not a problem, it says ...at line '60' and column '14'.... Which is very useful.

yugangw-msft commented 5 years ago

This is a bad error from the ARM service end. Regarding the aspect of PowerShell is doing better, please provide a sample template. Also I checked out doc, CLI does surface good errors from service end. I believe ARM just can't produce all errors with good source information. Again, if there is a sample template demonstrating PowerShell does a better job, do share here.

martinoss commented 5 years ago

It would also be helpful to output a "compiled" template with all the resolved values for better understanding what caused validation errors.

got this error...

"message": "Deployment template validation failed: 'The template resource 'xxx-dev/web' at line '1' and column '20864' is not valid: Unable to evaluate template language function 'resourceId': function requires exactly one multi-segmented argument which must be resource type including resource provider namespace. Current function arguments 'Microsoft.Web/serverfarms,/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Web/serverfarms/xxx'. Please see https://aka.ms/arm-template-expressions/#resourceid for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.",

...and would like to check, how my expression has been resolved and sent to the ARM service end without intercepting https traffic.