"az deployment group create" fails with "'str' object has no attribute 'get'" error
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
## Describe the bug
**Command Name**
`az deployment group create --resource-group alex-test-1 --template-file alex-test-1.template`
Template contains some invalid syntax in "parameters" section, e.g.:
```
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"adminPassword": "Admin#123456",
"adminUsername": "sbcadmin",
"clusterSubnetName": {
"defaultValue": "cluster",
"type": "string"
},
```
**Errors:**
```
'str' object has no attribute 'get'
```
## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- `az deployment group create --resource-group {} --template-file {}`
```
PS C:\Projects\StackMgr\template_generator> az deployment group create --resource-group alex-test-1 --template-file alex-test-1.template --debug
cli.knack.cli: Command arguments: ['deployment', 'group', 'create', '--resource-group', 'alex-test-1', '--template-file', 'alex-test-1.template', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
Init colorama.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'deployment': ['azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: resource 0.025 38 180
cli.azure.cli.core: Total (1) 0.025 38 180
cli.azure.cli.core: Loaded 38 groups, 180 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : deployment group create
cli.azure.cli.core: Command table: deployment group create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\alexa\.azure\commands\2021-06-24.11-20-19.deployment_group_create.25348.log'.
az_command_data_logger: command args: deployment group create --resource-group {} --template-file {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x03868070>, .register_query_examples at 0x0387E730>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x0387E778>, .add_cache_arguments at 0x0387E808>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .handle_example_parameter at 0x0387E6E8>, .parse_ids_arguments at 0x0387E7C0>]
cli.azure.cli.core.util: attempting to read file alex-test-1.template as utf-8-sig
cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception:
cli.azure.cli.core.util: Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 524, in deploy_arm_template_at_resource_group
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 553, in _deploy_arm_template_at_resource_group
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 910, in _prepare_deployment_properties_unmodified
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 260, in _get_missing_parameters
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 182, in _prompt_for_parameters
AttributeError: 'str' object has no attribute 'get'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 100, in handle_template_based_exception
AttributeError: 'AttributeError' object has no attribute 'inner_exception'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 712, in _run_job
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 102, in handle_template_based_exception
knack.util.CLIError: 'str' object has no attribute 'get'
cli.azure.cli.core.azclierror: 'str' object has no attribute 'get'
az_command_data_logger: 'str' object has no attribute 'get'
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.521 seconds (init: 0.196, invoke: 0.325)
telemetry.save: Save telemetry record of length 3065 in cache
telemetry.check: Negative: The C:\Users\alexa\.azure\telemetry.txt was modified at 2021-06-24 11:17:23.070802, which in less than 600.000000 s
```
## Expected Behavior
Proper error is displayed - as, for example, PowerShell does:
```
PS C:\Projects\StackMgr\template_generator> New-AzResourceGroupDeployment -Name alex-deployment-1 -ResourceGroupName alex-test-1 -TemplateFile .\alex-test-1.template
New-AzResourceGroupDeployment: 12:02:40 - Error: Code=InvalidRequestContent; Message=The request content was invalid and could not be deserialized: 'Unexpected initial token 'String' when populating object. Expected JSON object or array. Path 'properties.template.parameters.adminPassword', line 8, position 39.'.
New-AzResourceGroupDeployment: The deployment validation failed
```
## Environment Summary
```
Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI
azure-cli 2.25.0
```
## Additional Context
Contributor guide
Assessment
This issue has not been assessed yet.