Skip to content

Commit

Permalink
[IoTHub] Add missing parameter to create storage endpoint (Azure#11245)
Browse files Browse the repository at this point in the history
* Add missing parameter to create storage endpoint

* PR comments has been resolved
  • Loading branch information
anusapan authored and Juliehzl committed Nov 20, 2019
1 parent 72b2e89 commit b273712
Show file tree
Hide file tree
Showing 6 changed files with 1,495 additions and 968 deletions.
1 change: 1 addition & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Release History
**IOT**

* Fix #2531: Add convenience arguments for hub update.
* Fix #8323: Add missing parameters to create storage custom endpoint.

**Key Vault**

Expand Down
3 changes: 2 additions & 1 deletion src/azure-cli/azure/cli/command_modules/iot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,8 @@
az iot hub routing-endpoint create --resource-group MyResourceGroup --hub-name MyIotHub \\
--endpoint-name S1 --endpoint-type azurestoragecontainer --endpoint-resource-group "[Resource Group]" \\
--endpoint-subscription-id {SubscriptionId} --connection-string {ConnectionString} \\
--container-name {ContainerName}
--container-name {ContainerName} --batch-frequency 100 --chunk-size 100 \\
--ff {iothub}-{partition}-{YYYY}-{MM}-{DD}-{HH}-{mm}
"""

helps['iot hub routing-endpoint delete'] = """
Expand Down
11 changes: 11 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 @@ -203,6 +203,17 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
help='Encoding format for the container. The default is AVRO. '
'Note that this field is applicable only for blob container endpoints.')

with self.argument_context('iot hub routing-endpoint create') as c:
c.argument('batch_frequency', options_list=['--batch-frequency', '-b'], type=int,
help='Request batch frequency in seconds. The maximum amount of time that can elapse before data is'
' written to a blob, between 60 and 720 seconds.')
c.argument('chunk_size_window', options_list=['--chunk-size', '-w'], type=int,
help='Request chunk size in megabytes(MB). The maximum size of blobs, between 10 and 500 MB.')
c.argument('file_name_format', options_list=['--file-name-format', '--ff'],
help='File name format for the blob. The file name format must contain {iothub},'
' {partition}, {YYYY}, {MM}, {DD}, {HH} and {mm} fields. All parameters are'
' mandatory but can be reordered with or without delimiters.')

with self.argument_context('iot hub certificate') as c:
c.argument('certificate_path', options_list=['--path', '-p'], type=file_type,
completer=FilesCompleter([".cer", ".pem"]), help='The path to the file containing the certificate.')
Expand Down
8 changes: 6 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 @@ -666,7 +666,8 @@ def iot_hub_get_stats(client, hub_name, resource_group_name=None):
def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoint_type,
endpoint_resource_group, endpoint_subscription_id,
connection_string, container_name=None, encoding=None,
resource_group_name=None):
resource_group_name=None, batch_frequency=300, chunk_size_window=300,
file_name_format='{iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}'):
resource_group_name = _ensure_resource_group_name(client, resource_group_name, hub_name)
hub = iot_hub_get(cmd, client, hub_name, resource_group_name)
if EndpointType.EventHub.value == endpoint_type.lower():
Expand Down Expand Up @@ -706,7 +707,10 @@ def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoi
subscription_id=endpoint_subscription_id,
resource_group=endpoint_resource_group,
container_name=container_name,
encoding=encoding.lower() if encoding else EncodingFormat.AVRO.value
encoding=encoding.lower() if encoding else EncodingFormat.AVRO.value,
file_name_format=file_name_format,
batch_frequency_in_seconds=batch_frequency,
max_chunk_size_in_bytes=(chunk_size_window * 1048576)
)
)
return client.iot_hub_resource.create_or_update(resource_group_name, hub_name, hub, {'IF-MATCH': hub.etag})
Expand Down
Loading

0 comments on commit b273712

Please sign in to comment.