Adding Hybrid Connection with Azure CLI failed with slot parameter set

Jagoda 26 Reputation points
2021-07-08T07:22:03.693+00:00

Hello,

I'm trying to use Azure CLI command to add Hybrid Connection to the app service slot, but it failed with 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 "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1428, in _deserialize
found_value = key_extractor(attr, attr_desc, data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1193, in rest_key_case_insensitive_extractor
return attribute_key_case_insensitive_extractor(key, None, working_data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1222, 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.6/site-packages/msrest/serialization.py", line 620, in body
data = deserializer._deserialize(data_type, data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1446, in _deserialize
raise_with_traceback(DeserializationError, msg, err)
File "/opt/az/lib/python3.6/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
raise error.with_traceback(exc_traceback)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1428, in _deserialize
found_value = key_extractor(attr, attr_desc, data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1193, in rest_key_case_insensitive_extractor
return attribute_key_case_insensitive_extractor(key, None, working_data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1222, in attribute_key_case_insensitive_extractor
return data.get(found_key)
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 "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 657, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 720, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 691, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 328, in call
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 3413, in add_hc
hybrid_connection, hc, slot)
File "/opt/az/lib/python3.6/site-packages/azure/mgmt/web/v2020_09_01/operations/_web_apps_operations.py", line 18092, in create_or_update_hybrid_connection_slot
body_content = self._serialize.body(connection_envelope, 'HybridConnection')
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 623, in body
SerializationError, "Unable to build a model: "+str(err), err)
File "/opt/az/lib/python3.6/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
raise error.with_traceback(exc_traceback)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 620, in body
data = deserializer._deserialize(data_type, data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1446, in _deserialize
raise_with_traceback(DeserializationError, msg, err)
File "/opt/az/lib/python3.6/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
raise error.with_traceback(exc_traceback)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1428, in _deserialize
found_value = key_extractor(attr, attr_desc, data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1193, in rest_key_case_insensitive_extractor
return attribute_key_case_insensitive_extractor(key, None, working_data)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 1222, in attribute_key_case_insensitive_extractor
return data.get(found_key)
msrest.exceptions.SerializationError: Unable to build a model: Unable to deserializeto object: type, AttributeError: 'str' object has no attribute 'get', DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'

I'm using command copy-pasted from documentation:
az webapp hybrid-connection add -g MyResourceGroup -n MyWebapp --namespace [HybridConnectionNamespace] --hybrid-connection [HybridConnectionName] -s [slot]

https://learn.microsoft.com/en-us/cli/azure/webapp/hybrid-connection?view=azure-cli-latest#az_webapp_hybrid_connection_add-examples

Is there a possibility that I'm using it wrongly?

Azure App Services
Azure App Services
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,600 questions
No comments
{count} votes

Accepted answer
  1. BhargaviAnnadevara-MSFT 5,341 Reputation points
    2021-07-18T11:32:28.367+00:00

    @Jagoda Thanks for reaching out and apologies for not getting back sooner here.

    This bug was reported to the Azure CLI team a couple weeks ago: https://github.com/Azure/azure-cli/issues/18406
    This issue has now been fixed as part of version 2.26.0 and released on July 06, 2021.

    Please upgrade your Azure CLI installation to the current latest version ( 2.26.1 ) and give it another try.

    Hope this helps. Do let us know if you still run into issues.

    ----------

    If an answer is helpful, please "Accept answer" and/or "Up-Vote" which might help other community members reading this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Kannan K 6 Reputation points
    2021-08-27T03:03:05.88+00:00

    I still have this problem in Azure-cli vesion 2.27.2 when trying to create a resource using azure cli.

    2021-08-27T02:51:21.6109050Z azure-cli 2.27.2

    az resource create --resource-group $imageResourceGroup --properties '@win2019base.json' --is-full-object --resource-type Microsoft.VirtualMachineImages/imageTemplates -n $imageTemplateName

    when I pass Json file as parameter it fails to create the resource. can you please help ?