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'
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
az iot hub update --name {} --fileupload-storage-connectionstring {} --fileupload-storage-container-name {}Linux-4.15.0-1063-azure-x86_64-with-debian-stretch-sid
Python 3.6.5
Shell: bash
azure-cli 2.0.77
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @iluican @jlian
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @iluican @jlian
I don't understand what's happening here. Dialing in @iluican
@digimaun , can you please take a look?
@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 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 , 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.
@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!
Most helpful comment
@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 devicesEdit - 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'}}"