Azure-cli: az ad app update --id <appId> --add appRoles gives serialization error

Created on 12 Jul 2019  路  6Comments  路  Source: Azure/azure-cli

az ad app update --id $app.AppId --add appRoles @"

    {
        "allowedMemberTypes": [
            "User"
        ],
        "description": " Administrators can configure their organisation-wide settings.",
        "displayName": "Administrator",
        "isEnabled": true,
        "origin": "Application",
        "value": "Admin"
    }

"@

az --version
azure-cli 2.0.67

acr 2.2.9
acs 2.4.4
advisor 2.0.1
ams 0.4.7
appservice 0.2.21
backup 1.2.5
batch 4.0.3
batchai 0.4.10
billing 0.2.2
botservice 0.2.2
cdn 0.2.4
cloud 2.1.1
cognitiveservices 0.2.6
command-modules-nspkg 2.0.2
configure 2.0.24
consumption 0.4.4
container 0.3.18
core 2.0.67
cosmosdb 0.2.11
deploymentmanager 0.1.1
dla 0.2.6
dls 0.1.10
dms 0.1.4
eventgrid 0.2.4
eventhubs 0.3.7
extension 0.2.5
feedback 2.2.1
find 0.3.4
hdinsight 0.3.5
interactive 0.4.5
iot 0.3.11
iotcentral 0.1.7
keyvault 2.2.16
kusto 0.2.3
lab 0.1.8
maps 0.3.5
monitor 0.2.15
natgateway 0.1.1
network 2.5.2
nspkg 3.0.3
policyinsights 0.1.4
privatedns 1.0.2
profile 2.1.5
rdbms 0.3.12
redis 0.4.4
relay 0.1.5
reservations 0.4.3
resource 2.1.16
role 2.6.4
search 0.1.2
security 0.1.2
servicebus 0.3.6
servicefabric 0.1.20
signalr 1.0.1
sql 2.2.5
sqlvm 0.2.0
storage 2.4.3
telemetry 1.0.2
vm 2.2.23

Python location 'C:Program Files (x86)Microsoft SDKsAzureCLI2python.exe'
Extensions directory 'C:UsersHiten.azurecliextensions'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

Error:

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', DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1288, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1078, in rest_key_case_insensitive_extractor
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1101, in attribute_key_case_insensitive_extractor
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 571, in body
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1258, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1267, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1447, in deserialize_data
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1478, in deserialize_iter
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1478, in
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1460, in deserialize_data
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1298, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestexceptions.py", line 51, in raise_with_traceback
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1288, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1078, in rest_key_case_insensitive_extractor
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1101, in attribute_key_case_insensitive_extractor
msrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17knackknackcli.py", line 206, in invoke
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 566, in execute
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 624, in _run_jobs_serially
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 615, in _run_job
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-roleazureclicommand_modulesrolecommands.py", line 69, in graph_err_handler
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 594, in _run_job
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 303, in __call__
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommandsarm.py", line 554, in handler
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 409, in cached_put
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-coreazureclicorecommands__init__.py", line 404, in _put_operation
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-cli-roleazureclicommand_modulesrolecustom.py", line 960, in patch_application
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17azure-graphrbacazuregraphrbacoperationsapplications_operations.py", line 321, in patch
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 574, in body
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestexceptions.py", line 51, in raise_with_traceback
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 571, in body
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1258, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1267, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1447, in deserialize_data
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1478, in deserialize_iter
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1478, in
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1460, in deserialize_data
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1298, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestexceptions.py", line 51, in raise_with_traceback
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1288, in _deserialize
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1078, in rest_key_case_insensitive_extractor
File "C:UsersVSSADM~1AppDataLocalTemppip-install-wl9gly17msrestmsrestserialization.py", line 1101, in attribute_key_case_insensitive_extractor
msrest.exceptions.SerializationError: Unable to build a model: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get', DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'

Graph-cli OKR3.4 Candidate

Most helpful comment

Yes, we can consider this for the end to end scenario that you can download the manifest from portal, tweak a bit and then patch back to graph.
Reactivating. We will plan for it once we get enough votes.

All 6 comments

Updating from arbitrary json fragments is unsupported. Please check out the tip for recommended ways to use the update command.

Meanwhile, I am closing this issue even though there is an uncaught exception, but that is part of the nature of being generic. Feel free to post follow-up questions though.

Yes, we can consider this for the end to end scenario that you can download the manifest from portal, tweak a bit and then patch back to graph.
Reactivating. We will plan for it once we get enough votes.

for context, I had asked if it can be a feature request. Thanks, Yugang.

The execution of a generic update is at
https://github.com/Azure/azure-cli/blob/ac427269ab4fc55fbe04d8e1445a1b78d191076f/src/azure-cli-core/azure/cli/core/commands/arm.py#L522

So a generic deserialization is supported here. The error is actually caused by malformed command, possibly line-breaks or quotes.

I tested --set and --add with the example from AAD doc. Both worked fine.

On Windows:

az ad app update --id "xxx" --set "appRoles=[{\"allowedMemberTypes\":[\"User\"],\"displayName\":\"Writer\",\"id\":\"d1c2ade8-98f8-45fd-aa4a-6d06b947c66f\",\"isEnabled\":true,\"description\":\"Writers Have the ability to create tasks.\",\"value\":\"Writer\"}]"
az ad app update --id "xxx" --add appRoles "{\"allowedMemberTypes\":[\"User\"],\"displayName\":\"Writer\",\"id\":\"d1c2ade8-98f8-45fd-aa4a-6d06b947c66f\",\"isEnabled\":true,\"description\":\"Writers Have the ability to create tasks.\",\"value\":\"Writer\"}"

On Linux:

az ad app update --id "xxx" --set 'appRoles=[{"allowedMemberTypes":["User"],"displayName":"Writer","id":"d1c2ade8-98f8-45fd-aa4a-6d06b947c66f","isEnabled":true,"description":"Writers Have the ability to create tasks.","value":"Writer"}]'
az ad app update --id "xxx" --add appRoles '{"allowedMemberTypes":["User"],"displayName":"Writer","id":"d1c2ade8-98f8-45fd-aa4a-6d06b947c66f","isEnabled":true,"description":"Writers Have the ability to create tasks.","value":"Writer"}'

add to S173

Was this page helpful?
0 / 5 - 0 ratings