Setting up routing endpoint for IoT Hub for storage account fails
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior.
Expected behavior A clear and concise description of what you expected to happen.
Environment summary
Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (az --version) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)
Additional context Add any other context about the problem here.
I'm a Sr Content Dev working on expanding the IoT Hub routing tutorial (https://docs.microsoft.com/en-us/azure/iot-hub/tutorial-routing) to add ARM templates, and to add routing setup scripts in PowerShell and CLI (and ARM). Everything works except CLI.
When setting up the routing endpoint using CLI for the storage account, it fails.
az iot hub routing-endpoint create
--connection-string $storageConnectionString
--endpoint-name $endpointName
--endpoint-resource-group $resourceGroup
--endpoint-subscription-id $subscriptionID
--endpoint-type $endpointType
--hub-name $iotHubName
--container $containerName
--resource-group $resourceGroup
Here's the error:
robin@Azure:~$ az iot hub routing-endpoint create --connection-string $storageConnectionString --endpoint-name $endpointName --endpoint-resource-group $resourceGroup --endpoint-subscription-id $subscriptionID --endpoint-type $endpointType --hub-name $iotHubName --container $containerName --resource-group $resourceGroup Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/a4295411-5eff-4f81-b77e-276ab1ccda12/resourceGroups/ContosoResources5/providers/Microsoft.Devices/IotHubs/ContosoTestHub4791?api-version=2018-12-01-preview (Caused by ResponseError('too many 500 error responses',)) Traceback (most recent call last): File "/opt/az/lib/python3.6/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 731, in urlopen body_pos=body_pos, **response_kw) File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 731, in urlopen body_pos=body_pos, **response_kw) File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 731, in urlopen body_pos=body_pos, **response_kw) File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 711, in urlopen retries = retries.increment(method, url, response=response, _pool=self) File "/opt/az/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/a4295411-5eff-4f81-b77e-276ab1ccda12/resourceGroups/ContosoResources5/providers/Microsoft.Devices/IotHubs/ContosoTestHub4791?api-version=2018-12-01-preview (Caused by ResponseError('too many 500 error responses',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/opt/az/lib/python3.6/site-packages/msrest/universal_http/requests.py", line 137, in send **kwargs) File "/opt/az/lib/python3.6/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "/opt/az/lib/python3.6/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/requests/adapters.py", line 507, in send raise RetryError(e, request=request) requests.exceptions.RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/a4295411-5eff-4f81-b77e-276ab1ccda12/resourceGroups/ContosoResources5/providers/Microsoft.Devices/IotHubs/ContosoTestHub4791?api-version=2018-12-01-preview (Caused by ResponseError('too many 500 error responses',))
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 206, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 328, in execute raise ex File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 386, 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 379, 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 356, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 171, in call return self.handler(*args, **kwargs) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/init.py", line 448, in default_command_handler return op(**command_args) File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/iot/custom.py", line 567, in iot_hub_routing_endpoint_create return client.iot_hub_resource.create_or_update(resource_group_name, hub_name, hub, {'IF-MATCH': hub.etag}) File "/opt/az/lib/python3.6/site-packages/azure/mgmt/iothub/operations/iot_hub_resource_operations.py", line 199, in create_or_update **operation_config File "/opt/az/lib/python3.6/site-packages/azure/mgmt/iothub/operations/iot_hub_resource_operations.py", line 140, in _create_or_update_initial response = self._client.send(request, stream=False, **operation_config) File "/opt/az/lib/python3.6/site-packages/msrest/service_client.py", line 336, in send pipeline_response = self.config.pipeline.run(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/pipeline/init.py", line 197, in run return first_node.send(pipeline_request, **kwargs) # type: ignore File "/opt/az/lib/python3.6/site-packages/msrest/pipeline/init.py", line 150, in send response = self.next.send(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/pipeline/requests.py", line 72, in send return self.next.send(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/pipeline/requests.py", line 137, in send return self.next.send(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/pipeline/init.py", line 150, in send response = self.next.send(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/pipeline/requests.py", line 193, in send self.driver.send(request.http_request, **kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/universal_http/requests.py", line 328, in send return super(RequestsHTTPSender, self).send(request, **requests_kwargs) File "/opt/az/lib/python3.6/site-packages/msrest/universal_http/requests.py", line 140, in send raise_with_traceback(ClientRequestError, 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/universal_http/requests.py", line 137, in send **kwargs) File "/opt/az/lib/python3.6/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "/opt/az/lib/python3.6/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "/opt/az/lib/python3.6/site-packages/requests/adapters.py", line 507, in send raise RetryError(e, request=request) msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/a4295411-5eff-4f81-b77e-276ab1ccda12/resourceGroups/ContosoResources5/providers/Microsoft.Devices/IotHubs/ContosoTestHub4791?api-version=2018-12-01-preview (Caused by ResponseError('too many 500 error responses',)) robin@Azure:~$
Sapan Saxena verified on Friday 2/15 that this didn't work for him either. Today (Tuesday 2/19), he says it works for him. It did not work for me this morning, but when I tried it around 2 p.m., it also didn't work, but just never finished running. I left it for 15 minutes in Cloud Shell, and finally have to Ctrl-C to get past it. I checked the portal, it didn't add the endpoint.
If you want the CLI script, ping me internally. I'm going to post the second problem setting up a routing endpoint for a service bus queue separately because it's a whole different problem.
Thx, Robin
One more comment: This is related to GH issue 8579 about setting up an endpoint using CLI for a service bus queue. Completely different error, though.
The awesome @v-Ajnava has mucked around with this and found that the problem is that when you retrieve the connection string, it is returned with double-quotes around it. Then when you turn around and send it into this cmdlet, it fails. If you change the double quotes to single quotes, it works. It would be nice if that cmdlet would accept connection string in double quotes. Is that something that can be changed, or do I have to figure out how to do string manipulation in CLI to change them to single quotes? /cc: @ash2017
Closing as the solution is the same described in #8579.