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

az iot hub update --fc --fcc is not working

Open mohamedsaif opened this issue 7 years ago • 8 comments

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az iot hub update

Errors:

'$default'
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 206, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 603, in execute
    raise ex
cli/core/commands/__init__.py, ln 661, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
cli/core/commands/__init__.py, ln 654, in _run_job
    six.reraise(*sys.exc_info())
...
cli/core/commands/__init__.py, ln 306, in __call__
    return self.handler(*args, **kwargs)
cli/core/commands/arm.py, ln 526, in handler
    instance = custom_function(instance=instance, **custom_func_args)
cli/command_modules/iot/custom.py, ln 495, in update_iot_hub_custom
    instance.properties.storage_endpoints['$default'].connection_string = fileupload_storage_connectionstring
KeyError: '$default'

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 iot hub update --name {} --fileupload-storage-connectionstring {} --fileupload-storage-container-name {}

Expected Behavior

Environment Summary

Linux-4.15.0-1063-azure-x86_64-with-debian-stretch-sid
Python 3.6.5
Shell: bash

azure-cli 2.0.77

Additional Context

mohamedsaif avatar Nov 29 '19 19:11 mohamedsaif

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @iluican @jlian

ghost avatar Nov 30 '19 03:11 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @iluican @jlian

ghost avatar Nov 30 '19 03:11 ghost

I don't understand what's happening here. Dialing in @iluican

jlian avatar Dec 02 '19 17:12 jlian

@digimaun , can you please take a look?

iluican avatar Dec 04 '19 10:12 iluican

@mohamedsaif , I believe your storageEndpoints is in an indeterminate state...possibly from assigning storageEndpoints to an empty object.

First try raw setting of object (this format should work in bash):

az iot hub update -n MyIoTHub --set properties.storageEndpoints.'$default'="{'connectionString':'DefaultEndpointsProtocol=https;AccountName=blahblahblah;AccountKey=abcdefgh==;EndpointSuffix=core.windows.net', 'containerName':'devices', 'sasTtlAsIso8601':'PT1H'}"

Now the convenience arguments should work:

az iot hub update -n MyIoTHub --fileupload-storage-connectionstring 'DefaultEndpointsProtocol=https;AccountName=blahblahblah;AccountKey=abcdefgh==;EndpointSuffix=core.windows.net' --fileupload-storage-container-name devices

Edit - I want to add one more syntax variation for setting the storageEndpoints object:

az iot hub update -n MyIoTHub --set properties.storageEndpoints="{'\$default':{'connectionString':'DefaultEndpointsProtocol=https;AccountName=blahblahblah;AccountKey=abcdefgh==;EndpointSuffix=core.windows.net', 'containerName':'devices', 'sasTtlAsIso8601':'PT1H'}}"

digimaun avatar Dec 04 '19 22:12 digimaun

@digimaun Thanks for your feedback & support. Executing the last mentioned command it ran successfully and file upload was configured: az iot hub update -n MyIoTHub --set properties.storageEndpoints="{'$default':{'connectionString':'DefaultEndpointsProtocol=https;AccountName=blahblahblah;AccountKey=abcdefgh==;EndpointSuffix=core.windows.net', 'containerName':'devices', 'sasTtlAsIso8601':'PT1H'}}"

I've tried again the second command you mentioned but failed with the same error. It is worth mentioning as well the portal experience for enabling file upload also is not working.

az iot hub update -n HUBNAME --fileupload-storage-connectionstring 'DefaultEndpointsProtocol=https;AccountName=ACCNAME;AccountKey=KEY;EndpointSuffix=core.windows.net' --fileupload-storage-container-name CONTAINER The command failed with an unexpected error. Here is the traceback:

'$default' Traceback (most recent call last): File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 603, in execute raise ex File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 661, 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 654, in _run_job 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 631, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 306, in call return self.handler(*args, **kwargs) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/arm.py", line 526, in handler instance = custom_function(instance=instance, **custom_func_args) File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/iot/custom.py", line 495, in update_iot_hub_custom instance.properties.storage_endpoints['$default'].connection_string = fileupload_storage_connectionstring KeyError: '$default'

mohamedsaif avatar Dec 05 '19 04:12 mohamedsaif

@mohamedsaif , thank you for getting back with your results.

I want to be clear on a couple elements to make sure we are on the same page. And ack on the Portal issue. I repro'd the same thing and the reason is because the '$default' element needs to exist in properties.storageEndpoints - then the Portal experience should work again.

First (assuming in bash environment) make sure in the last mentioned command, that $default is escaped just like in the example. In your reply its not escaped (double checking).

Next the second command with convenience arguments, assumes $default is present. In otherwords you have to have successfully run the first or last command to explicitly set the $default storage endpoint - then the convenience arguments should work.

digimaun avatar Dec 05 '19 19:12 digimaun

@mohamedsaif I assume @digimaun's instructions helped? I'm closing this issue in the meantime. If you need more help just comment and we can follow up. Thanks!

jlian avatar Dec 12 '19 18:12 jlian