tags do not work with az lab vm create
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 64
Description
**Describe the bug**
When using --tags with lb vm create, a error message `Parameter 'tags' must be of type '{str}'` is thrown.
I tried different escaping methods, none of them worked.
```
Parameter 'tags' must be of type '{str}'
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 197, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 337, in execute
six.reraise(*sys.exc_info())
File "/opt/az/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 311, in execute
result = cmd(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 170, in __call__
return super(AzCliCommand, self).__call__(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/knack/commands.py", line 109, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 421, in default_command_handler
result = op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/lab/custom.py", line 65, in create_lab_vm
return client.create_environment(resource_group_name, lab_name, lab_virtual_machine)
File "/opt/az/lib/python3.6/site-packages/azure/mgmt/devtestlabs/operations/labs_operations.py", line 634, in create_environment
body_content = self._serialize.body(lab_virtual_machine_creation_parameter, 'LabVirtualMachineCreationParameter')
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 564, in body
errors = _recursive_validate(data_type, data_type, data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 126, in _recursive_validate
return data.validate()
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 220, in validate
validation_result += _recursive_validate(attr_name, attr_type, value)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 122, in _recursive_validate
raise ValidationError("type", attr_name, attr_type)
msrest.exceptions.ValidationError: Parameter 'tags' must be of type '{str}'
```
**To Reproduce**
in the azure CLI, use the command
`az lab vm create --lab-name someLab -g someRG --name insidious-string --image "Ubuntu Server 18.04 LTS" --image-type gallery --tags 'AutoStartOn=true' --size Standard_D2_v3`
**Expected behavior**
The VM should be created with the tag set, no exception is thrown.
**Environment summary**
Azure CLI embedded in the azure portal:
```
az --version
azure-cli (2.0.40)
acr (2.0.28)
acs (2.1.2)
advisor (0.5.1)
ams (0.1.1)
appservice (0.1.36)
backup (1.1.2)
batch (3.2.4)
batchai (0.3.1)
billing (0.1.8)
cdn (0.0.14)
cloud (2.0.15)
cognitiveservices (0.1.13)
command-modules-nspkg (2.0.1)
configure (2.0.17)
consumption (0.3.1)
container (0.2.0)
core (2.0.40)
cosmosdb (0.1.21)
dla (0.1.0)
dls (0.0.22)
dms (0.0.1)
eventgrid (0.1.12)
eventhubs (0.1.3)
extension (0.1.0)
feedback (2.1.3)
find (0.2.11)
interactive (0.3.24)
iot (0.1.21)
keyvault (2.0.23)
lab (0.0.22)
maps (0.2.0)
monitor (0.1.8)
network (2.1.5)
nspkg (3.0.2)
policyinsights (0.1.0)
profile (2.0.27)
rdbms (0.2.5)
redis (0.2.14)
reservations (0.2.1)
resource (2.0.32)
role (2.0.26)
servicebus (0.1.2)
servicefabric (0.0.12)
sql (2.0.27)
storage (2.0.35)
vm (2.0.35)
Python location '/opt/az/bin/python3'
Extensions directory '/home/claas_diederichs/.azure/cliextensions'
Python (Linux) 3.6.1 (default, Jun 28 2018, 16:28:57)
[GCC 5.4.0 20160609]
Legal docs and information: aka.ms/AzureCliLegal
```
**Additional context**
Might be related to #5496
Contributor guide
Research direction
Start with azure/cli/command_modules/lab/custom.py and the create_lab_vm entry point. Reproduce the issue using the documented az lab vm create command with --tags, then trace how the tags argument reaches the DevTest Labs client. Done means the command creates the VM with AutoStartOn=true without the validation exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100