Outline the issue here:
When running az iot device list --hub-name 'ServiceConnect, DeviceConnect, RegistryWrite' is not valid value for enum <enum 'AccessRights'>
Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here:
MSI
CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here:
azure-cli (2.0.19)
acr (2.0.13)
acs (2.0.17)
appservice (0.1.18)
backup (1.0.1)
batch (3.1.5)
batchai (0.1.1)
billing (0.1.5)
cdn (0.0.9)
cloud (2.0.8)
cognitiveservices (0.1.8)
command-modules-nspkg (2.0.1)
component (2.0.7)
configure (2.0.11)
consumption (0.1.5)
container (0.1.11)
core (2.0.18)
cosmosdb (0.1.13)
dla (0.0.12)
dls (0.0.15)
eventgrid (0.1.4)
extension (0.0.4)
feedback (2.0.6)
find (0.2.7)
interactive (0.3.10)
iot (0.1.12)
keyvault (2.0.12)
lab (0.0.11)
monitor (0.0.10)
network (2.0.16)
nspkg (3.0.1)
profile (2.0.14)
rdbms (0.0.7)
redis (0.2.9)
resource (2.0.16)
role (2.0.13)
servicefabric (0.0.4)
sql (2.0.13)
storage (2.0.17)
vm (2.0.16)
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\zlhe\.azure\cliextensions'
Python (Windows) 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
OS Version: What OS and version are you using?
Answer here:
Microsoft Windows [Version 10.0.15063]
Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here:
cmd.exe
Full logs
'ServiceConnect, DeviceConnect, RegistryWrite' is not valid value for enum <enum 'AccessRights'>
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\msrest\serialization.py", line 1280, in deserialize_enum
return enum_obj(str(data))
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\enum.py", line 291, in __call__
return cls.__new__(cls, value)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\enum.py", line 533, in __new__
return cls._missing_(value)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\enum.py", line 546, in _missing_
raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 'ServiceConnect, DeviceConnect, RegistryWrite' is not a valid AccessRights
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\main.py", line 36, in main
cmd_result = APPLICATION.execute(args)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\application.py", line 212, in execute
result = expanded_arg.func(params)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 377, in __call__
return self.handler(*args, **kwargs)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 630, in _execute_command
raise client_exception
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 620, in _execute_command
reraise(*sys.exc_info())
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 602, in _execute_command
result = op(client, **kwargs) if client else op(**kwargs)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\iot\custom.py", line 236, in iot_device_list
device_client = _get_device_client(client, resource_group_name, hub_name, '')
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\iot\custom.py", line 332, in _get_device_client
access_policy = iot_hub_policy_get(client, hub_name, 'iothubowner', resource_group_name)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\iot\custom.py", line 135, in iot_hub_policy_get
return client.get_keys_for_key_name(resource_group_name, hub_name, policy_name)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\mgmt\iothub\operations\iot_hub_resource_operations.py", line 1257, in get_keys_for_key_name
deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', response)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\msrest\serialization.py", line 992, in __call__
value = self.deserialize_data(raw_value, attr_desc['type'])
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\msrest\serialization.py", line 1136, in deserialize_data
return self.deserialize_enum(data, obj_type)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\msrest\serialization.py", line 1286, in deserialize_enum
raise DeserializationError(error.format(data, enum_obj))
msrest.exceptions.DeserializationError: 'ServiceConnect, DeviceConnect, RegistryWrite' is not valid value for enum <enum 'AccessRights'>
I get a similar error when creating new devices with
az iot device create
Both on my local machine with azure-cli (2.0.15) and on the cloud shell with azure-cli (2.0.18).
We got similar error report from another user, any update of this issue?
@chieftn, @xscript, @digimaun mind take a look?
Investigating. Confirmed I can repro on my side.
Can confirm this is impacting CLI version 2.0.12 as well.
@WilliamBerryiii CLI 2.0.12 was packaged with az-cli-iot 0.1.10, which has the same dependency of the latest CLI's az-cli-iot 0.1.12 which is 'azure-mgmt-iothub==0.2.2'...likely a wide spread issue.
Here is the problem, at least with version "2016-02-03" of the API (which is what azure-mgmt-iothub 0.2.2 uses), it is returning the "rights" property value in a different order than specified. It is being returned as "ServiceConnect, DeviceConnect, RegistryWrite" instead of "RegistryWrite, ServiceConnect, DeviceConnect" which ties to the registry_write_service_connect_device_connect enum member hence the exception message:
'ServiceConnect, DeviceConnect, RegistryWrite' is not valid value for enum
Not an Az CLI issue but an azure mgmt API one as far as I can tell.
As a potential workaround, I tried using version 0.4.0 of the azure-mgmt-iothub SDK, which uses newer API "2017-07-01" and is reportedly backwards compatible. Unfortunately same error.
It seems like the (de)serialization should not be this brittle. While many language specifications say that enum.value() calls will return an array in declared order ... it seems overly brittle to push this stance from either the server or client side of an API.
cc: @lmazuel
@WilliamBerryiii the problem here is that the service returns a string ServiceConnect, DeviceConnect, RegistryWrite and not an array... And this one is not defined as a valid string in the RestAPI specification I use to generate the SDK:
https://github.com/Azure/azure-rest-api-specs/blob/9bc154a142ae39c3b900ba91043aabed1ef8e2f3/specification/iothub/resource-manager/Microsoft.Devices/2017-07-01/iothub.json#L1291-L1305
This should have been defined as an array in JSON indeed, in this case order would not have been an issue...
I think I can patch the SDK to bypass the deserialization of this particular attribute, split it using comma, and return an array of enum. I think this will be the best fix, since it's semantically what the service wants (i.e. [ServiceConnect, DeviceConnect, RegistryWrite] and not ServiceConnect, DeviceConnect, RegistryWrite)
Hi All, Thank you for reporting the issue. We identified an issue in our backend service. We are actively working on a fix. ETA: end of the day. Sorry for the inconvenience it caused.
good to know this will be fixed on the service side not the sdk side
This comment is for anyone trying to get started with the MXCHIP AZ3166 IOT DevKit.
Last evening, I found this thread while searching for "'ServiceConnect, DeviceConnect, RegistryWrite' is not valid value for enum
This error also occurred while attempting "Step 3. Provision required Azure services" of the Remote Monitoring tutorial, https://microsoft.github.io/azure-iot-developer-kit/docs/projects/remote-monitoring/.
Thanks for your comment @ScottWolter . You should be unblocked after the back-end service gets fixed. There is an ETA listed above.
Update: We rolled out a fix. This issue is fixed now.
Thank you all.
Most helpful comment
It seems like the (de)serialization should not be this brittle. While many language specifications say that enum.value() calls will return an array in declared order ... it seems overly brittle to push this stance from either the server or client side of an API.