Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
type=int, validator=validate_fileupload_sas_ttl,
help='The amount of time a SAS URI generated by IoT Hub is valid before it expires,'
' between 1 and 24 hours.')
c.argument('min_tls_version', options_list=['--min-tls-version', '--mintls'],
type=str, help='Specify the minimum TLS version to support for this hub. Can be set to'
' "1.2" to have clients that use a TLS version below 1.2 to be rejected.')

for subgroup in ['consumer-group', 'policy', 'certificate', 'routing-endpoint', 'route']:
with self.argument_context('iot hub {}'.format(subgroup)) as c:
Expand Down
6 changes: 4 additions & 2 deletions src/azure-cli/azure/cli/command_modules/iot/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ def iot_hub_create(cmd, client, hub_name, resource_group_name, location=None,
fileupload_storage_container_name=None,
fileupload_sas_ttl=1,
fileupload_storage_authentication_type=None,
fileupload_storage_container_uri=None):
fileupload_storage_container_uri=None,
min_tls_version=None):
from datetime import timedelta
cli_ctx = cmd.cli_ctx
if enable_fileupload_notifications:
Expand Down Expand Up @@ -428,7 +429,8 @@ def iot_hub_create(cmd, client, hub_name, resource_group_name, location=None,
properties = IotHubProperties(event_hub_endpoints=event_hub_dic,
messaging_endpoints=msg_endpoint_dic,
storage_endpoints=storage_endpoint_dic,
cloud_to_device=cloud_to_device_properties)
cloud_to_device=cloud_to_device_properties,
min_tls_version=min_tls_version)
properties.enable_file_upload_notifications = enable_fileupload_notifications

hub_description = IotHubDescription(location=location,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ def test_iot_hub(self, resource_group, resource_group_location, storage_account)
checks=[self.check('resourcegroup', rg),
self.check('name', hub),
self.check('sku.name', 'F1'),
self.check('properties.minTlsVersion', None),
self.check('properties.eventHubEndpoints.events.partitionCount', '2')])
self.cmd('iot hub delete -n {0}'.format(hub), checks=self.is_empty())

# Test 'az iot hub create'
self.cmd('iot hub create -n {0} -g {1} --sku S1 --fn true'.format(hub, rg), expect_failure=True)
self.cmd('iot hub create -n {0} -g {1} --sku S1 --fn true --fc containerName'
.format(hub, rg), expect_failure=True)
self.cmd('iot hub create -n {0} -g {1} --sku S1 --mintls 2.5'.format(hub, rg), expect_failure=True)
self.cmd('iot hub create -n {0} -g {1} --retention-day 3'
' --c2d-ttl 23 --c2d-max-delivery-count 89 --feedback-ttl 29 --feedback-lock-duration 35'
' --feedback-max-delivery-count 40 --fileupload-notification-max-delivery-count 79'
' --fileupload-notification-ttl 20'.format(hub, rg),
' --fileupload-notification-ttl 20 --min-tls-version 1.2'.format(hub, rg),
checks=[self.check('resourcegroup', rg),
self.check('location', location),
self.check('name', hub),
Expand All @@ -58,7 +60,8 @@ def test_iot_hub(self, resource_group, resource_group_location, storage_account)
self.check('properties.cloudToDevice.maxDeliveryCount', '89'),
self.check('properties.cloudToDevice.defaultTtlAsIso8601', '23:00:00'),
self.check('properties.messagingEndpoints.fileNotifications.ttlAsIso8601', '20:00:00'),
self.check('properties.messagingEndpoints.fileNotifications.maxDeliveryCount', '79')])
self.check('properties.messagingEndpoints.fileNotifications.maxDeliveryCount', '79'),
self.check('properties.minTlsVersion', '1.2')])

# Test 'az iot hub show-connection-string'
conn_str_pattern = r'^HostName={0}.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey='.format(
Expand Down