azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az create container using yaml file throws Python error

Open cirezd opened this issue 2 years ago • 3 comments
trafficstars

This is autogenerated. Please review and update as needed.

Describe the bug

I wanted to mount a volume to a container instance. I exported the yaml-config via az container show of an existing container. I adjusted a few lines and wanted to deploy it, but received the error message. This way of deploying works for Container Apps, so I assume it should also work for Container Instances? I don't understand whether this error is related to the yaml file or to something else.

Command Name az container create

Errors:

The command failed with an unexpected error. Here is the traceback:
('Unable to build a model: ("Unable to deserialize to object: type, AttributeError: \'str\' object has no attribute \'get\'", AttributeError("\'str\' object has no attribute \'get\'")), DeserializationError: ("Unable to deserialize to object: type, AttributeError: \'str\' object has no attribute \'get\'", AttributeError("\'str\' object has no attribute \'get\'"))', DeserializationError("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'")))
Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1201, in rest_key_case_insensitive_extractor
    return attribute_key_case_insensitive_extractor(key, None, working_data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1230, in attribute_key_case_insensitive_extractor
    return data.get(found_key)
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 622, in body
    data = deserializer._deserialize(data_type, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1450, in _deserialize
    value = self.deserialize_data(raw_value, attr_desc['type'])
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1639, in deserialize_data
    return self._deserialize(obj_type, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1454, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/opt/az/lib/python3.10/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1201, in rest_key_case_insensitive_extractor
    return attribute_key_case_insensitive_extractor(key, None, working_data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1230, in attribute_key_case_insensitive_extractor
    return data.get(found_key)
azure.core.exceptions.DeserializationError: ("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/container/custom.py", line 121, in create_container
    return _create_update_from_file(cmd.cli_ctx, resource_group_name, name, location, file, no_wait)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/container/custom.py", line 433, in _create_update_from_file
    return sdk_no_wait(no_wait,
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/util.py", line 717, in sdk_no_wait
    return func(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 73, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py", line 8974, in begin_create_or_update
    raw_result = self._create_or_update_initial(
  File "/opt/az/lib/python3.10/site-packages/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py", line 8879, in _create_or_update_initial
    _json = self._serialize.body(parameters, 'GenericResource')
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 624, in body
    raise_with_traceback(
  File "/opt/az/lib/python3.10/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 622, in body
    data = deserializer._deserialize(data_type, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1450, in _deserialize
    value = self.deserialize_data(raw_value, attr_desc['type'])
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1639, in deserialize_data
    return self._deserialize(obj_type, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1454, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/opt/az/lib/python3.10/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1201, in rest_key_case_insensitive_extractor
    return attribute_key_case_insensitive_extractor(key, None, working_data)
  File "/opt/az/lib/python3.10/site-packages/msrest/serialization.py", line 1230, in attribute_key_case_insensitive_extractor
    return data.get(found_key)
azure.core.exceptions.SerializationError: ('Unable to build a model: ("Unable to deserialize to object: type, AttributeError: \'str\' object has no attribute \'get\'", AttributeError("\'str\' object has no attribute \'get\'")), DeserializationError: ("Unable to deserialize to object: type, AttributeError: \'str\' object has no attribute \'get\'", AttributeError("\'str\' object has no attribute \'get\'"))', DeserializationError("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'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.

  • Put any pre-requisite steps here...
  • az container create --resource-group {} --file {}

Expected Behavior

Environment Summary

Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.31, Ubuntu 20.04.2 LTS
Python 3.10.10
Installer: DEB

azure-cli 2.46.0

Extensions:
containerapp 0.3.13
webapp 0.4.0

Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1

Additional Context

cirezd avatar Mar 10 '23 15:03 cirezd

route to CXP team

yonzhan avatar Mar 11 '23 00:03 yonzhan

Any update? Same error here:

az container create -g {} -f {}.yaml

azure-cli                         2.60.0 *

core                              2.60.0 *
telemetry                          1.1.0

Extensions:
aks-preview                      1.0.0b6

Dependencies:
msal                              1.28.0
azure-mgmt-resource             23.1.0b2

Python location '/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/bin/python'
Extensions directory '/Users/ltmleo/.azure/cliextensions'

Python (Darwin) 3.11.9 (main, Apr  2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)]

Legal docs and information: aka.ms/AzureCliLegal

ltmleo avatar Jun 24 '24 14:06 ltmleo

I just realized that my yaml file (exported using az container show) does not have the same format as the expected form az container created. See this documentation, might help.

ltmleo avatar Jun 27 '24 17:06 ltmleo