Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a2f6b6c
Initial updates to use track 2 Hub GA SDK
c-ryan-k Mar 3, 2021
45cadfb
WIP initial user-assigned identity functionality
c-ryan-k Mar 16, 2021
2acf8e6
Added routing endpoint identity and added some preliminary test code
c-ryan-k Mar 17, 2021
b613397
Updated identity code with enums and minor logic updates
c-ryan-k Mar 18, 2021
b3208a4
More identity updates, role and scope assignment
c-ryan-k Mar 18, 2021
ee48812
Minor fixes to identity functions and return values
c-ryan-k Mar 19, 2021
ee807a0
Linting fixes
c-ryan-k Mar 19, 2021
ea84c66
WIP testing updates
c-ryan-k Mar 19, 2021
44117af
Merge branch 'azure-dev' into hub_track2
c-ryan-k Mar 26, 2021
fa2dbb8
Help/Param updates and minor tweaks/fixes
c-ryan-k Mar 30, 2021
691950d
Test updates, help updates, polling updates
c-ryan-k Mar 30, 2021
8fc4f2e
Test recording updates
c-ryan-k Mar 31, 2021
1282c05
test updates
c-ryan-k Apr 6, 2021
0a76443
minor fix in consumer_group_create, test updates
c-ryan-k Apr 6, 2021
5060def
Initial updates to use track 2 Hub GA SDK
c-ryan-k Mar 3, 2021
14fa27d
WIP initial user-assigned identity functionality
c-ryan-k Mar 16, 2021
bc5e641
Added routing endpoint identity and added some preliminary test code
c-ryan-k Mar 17, 2021
8779d9a
Updated identity code with enums and minor logic updates
c-ryan-k Mar 18, 2021
889f42c
More identity updates, role and scope assignment
c-ryan-k Mar 18, 2021
90342f9
Minor fixes to identity functions and return values
c-ryan-k Mar 19, 2021
9b25700
Linting fixes
c-ryan-k Mar 19, 2021
850ab5e
WIP testing updates
c-ryan-k Mar 19, 2021
a65084e
Help/Param updates and minor tweaks/fixes
c-ryan-k Mar 30, 2021
c92c45f
Test updates, help updates, polling updates
c-ryan-k Mar 30, 2021
5f5e1e2
Test recording updates
c-ryan-k Mar 31, 2021
df59fbf
test updates
c-ryan-k Apr 6, 2021
e6308da
minor fix in consumer_group_create, test updates
c-ryan-k Apr 6, 2021
47e700a
Merge branch 'hub_track2' of https://github.com/c-ryan-k/azure-cli in…
c-ryan-k Apr 12, 2021
0214f61
Test updates and new recordings
c-ryan-k Apr 12, 2021
3ea6fc4
Merge branch 'azure-dev' into hub_track2
c-ryan-k Apr 20, 2021
a29fe37
Fix for ARM issue - user identity object must be empty upon removal o…
c-ryan-k Apr 27, 2021
1a0ceeb
Updates to use stable multiapi SDK (2021-03-03) with backfill for dev…
c-ryan-k Apr 28, 2021
d1b5f0d
Merge branch 'dev' into hub_track2
c-ryan-k Apr 28, 2021
ef103b3
Help/Param string updates
c-ryan-k Apr 28, 2021
fb759e6
Version fix for new SDK (2021-03-31)
c-ryan-k Apr 29, 2021
bdc3f5a
Parameter updates
c-ryan-k May 11, 2021
a599f8b
Test and recording updates
c-ryan-k May 11, 2021
cd59e5a
Certificate create/update fixes and test updates
c-ryan-k May 11, 2021
4e8d6a3
Add DeviceConnectionStateEvents as a routing source type
c-ryan-k May 13, 2021
0ab2ae5
RoutingSource test updates
c-ryan-k May 14, 2021
20992a8
SDK version update to 2.0.0
c-ryan-k May 14, 2021
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
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def default_api_version(self):
'subscription_diagnostic_settings': '2017-05-01-preview'
}),
ResourceType.MGMT_APPSERVICE: '2020-09-01',
ResourceType.MGMT_IOTHUB: '2020-03-01',
ResourceType.MGMT_IOTHUB: '2021-03-31',
ResourceType.MGMT_ARO: '2020-04-30',
ResourceType.MGMT_DATABOXEDGE: '2019-08-01'
},
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/iot/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

certificate_help = """For a detailed explanation of CA certificates in Azure IoT Hub,
see https://docs.microsoft.com/azure/iot-hub/iot-hub-x509ca-overview """
SYSTEM_IDENTITY = '[system]'
49 changes: 45 additions & 4 deletions src/azure-cli/azure/cli/command_modules/iot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@
- name: Create an IoT Hub with the standard pricing tier S1 and 4 partitions, in the 'westus' region, with tags.
text: >
az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus --tags a=b c=d
- name: Create an IoT Hub with a system-assigned managed identity, and assign a role and scope to a storage account for the created identity.
text: >
az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus --assign-identity [system] --role "Storage Blob Data Contributor" --scopes {resourceId}
"""

helps['iot hub delete'] = """
Expand All @@ -428,6 +431,44 @@
az iot hub devicestream show -n MyIotHub
"""

helps['iot hub identity'] = """
type: group
short-summary: Manage identities of an Azure IoT hub.
"""

helps['iot hub identity assign'] = """
type: command
short-summary: Assign managed identities to an IoT Hub
examples:
- name: Assign a user-assigned managed identity to an IoT Hub
text: >
az iot hub identity assign --name MyIoTHub --resource-group MyResourceGroup --identities {resourceId}
- name: Assign a system-assigned managed identity to an IoT Hub and assign a role to that identity.
text: >
az iot hub identity assign --name MyIoTHub --resource-group MyResourceGroup --identities [system] --role "Storage Blob Data Contributor" --scopes {resourceId}
"""

helps['iot hub identity show'] = """
type: command
short-summary: Show the identity properties of an IoT Hub
examples:
- name: Show identity properties of an IoT Hub
text: >
az iot hub identity show --name MyIoTHub --resource-group MyResourceGroup
"""

helps['iot hub identity remove'] = """
type: command
short-summary: Remove managed identities from an IoT Hub
examples:
- name: Remove a user-assigned managed identity from an IoT Hub
text: >
az iot hub identity remove --name MyIoTHub --resource-group MyResourceGroup --identities {resourceId}
- name: Remove a system-assigned managed identity from an IoT Hub.
text: >
az iot hub identity remove --name MyIoTHub --resource-group MyResourceGroup --identities [system]
"""

helps['iot hub list'] = """
type: command
short-summary: List IoT hubs.
Expand Down Expand Up @@ -653,9 +694,9 @@
--endpoint-subscription-id {SubscriptionId} --connection-string {ConnectionString} \\
--container-name {ContainerName} --batch-frequency 100 --chunk-size 100 \\
--ff {iothub}-{partition}-{YYYY}-{MM}-{DD}-{HH}-{mm}
- name: Add a new identity-based EventHub endpoint named "EventHubIdentity"
- name: Add a new identity-based EventHub endpoint named "EventHubIdentity" and authenticate using a user-assigned managed identity
text: >
az iot hub routing-endpoint create --resource-group MyResourceGroup --hub-name MyIotHub --endpoint-name EventHubIdentity --endpoint-type eventhub --endpoint-resource-group {ResourceGroup} --endpoint-subscription-id {SubscriptionId} --auth-type identityBased --endpoint-uri {EventHubEndpointUri} --entity-path {EntityPath}
az iot hub routing-endpoint create --resource-group MyResourceGroup --hub-name MyIotHub --endpoint-name EventHubIdentity --endpoint-type eventhub --endpoint-resource-group {ResourceGroup} --endpoint-subscription-id {SubscriptionId} --auth-type identityBased --identity {userIdentityResourceId} --endpoint-uri {EventHubEndpointUri} --entity-path {EntityPath}
"""

helps['iot hub routing-endpoint delete'] = """
Expand Down Expand Up @@ -779,9 +820,9 @@
- name: Update the IoT Hub feedback queue settings
text: >
az iot hub update --name MyIoTHub --feedback-max-delivery-count 20 --feedback-lock-duration 100 --feedback-ttl 4
- name: Update the IoT Hub file upload settings
- name: Update the IoT Hub file upload settings, and assign a managed identity to user for file upload)
text: >
az iot hub update -n MyIoTHub --fileupload-sas-ttl 5 --fileupload-storage-auth-type identityBased
az iot hub update -n MyIoTHub --fileupload-sas-ttl 5 --fileupload-storage-auth-type identityBased --fileupload-storage-identity [system]
- name: Update the IoT Hub file upload notification settings
text: >
az iot hub update -n MyIoTHub --fileupload-notification-max-delivery-count 50
Expand Down
26 changes: 25 additions & 1 deletion src/azure-cli/azure/cli/command_modules/iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
help='The connection string for the Azure Storage account to which files are uploaded.')
c.argument('fileupload_storage_authentication_type',
options_list=['--fileupload-storage-auth-type', '--fsa'],
help='The authentication type for the Azure Storage account to which files are uploaded.'
help='The authentication type for the Azure Storage account to which files are uploaded. '
'Possible values are keyBased and identityBased')
c.argument('fileupload_storage_container_uri',
options_list=['--fileupload-storage-container-uri', '--fcu'],
Expand All @@ -178,10 +178,30 @@ 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('fileupload_storage_identity',
options_list=['--fileupload-storage-identity', '--fsi'],
help="The managed identity to use for file upload authentication. Use '[system]' to "
"refer to the system-assigned managed identity or a resource ID to refer to a "
"user-assigned managed identity.")
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.')
c.argument('tags', tags_type)
c.argument('identities', options_list=['--assign-identity'],
nargs='*', help="Accepts system or user-assigned managed identities separated by spaces. "
"Use '[system]' to refer to the system-assigned identity or a resource ID to refer to "
"a user-assigned identity.")
c.argument('identity_role', options_list=['--role'],
help="Role to assign to the hub's system-assigned managed identity")
c.argument('identity_scopes', options_list=['--scopes'], nargs='*',
help="Space separated list of scopes to assign the role (--role) "
"for the system-assigned managed identity.")

with self.argument_context('iot hub identity') as c:
c.argument('identities', options_list=['--identities'],
nargs='*', help="Accepts system or user-assigned managed identities separated by spaces. "
"Use '[system]' to refer to the system-assigned identity or a resource ID to refer to a "
"user-assigned identity.")

for subgroup in ['consumer-group', 'policy', 'certificate', 'routing-endpoint', 'route']:
with self.argument_context('iot hub {}'.format(subgroup)) as c:
Expand Down Expand Up @@ -238,6 +258,10 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
' mandatory but can be reordered with or without delimiters.')
c.argument('authentication_type', options_list=['--auth-type'], arg_type=get_enum_type(AuthenticationType),
help='Authentication type for the endpoint. The default is keyBased.')
c.argument('identity', help='Use a system-assigned or user-assigned managed identity for endpoint '
'authentication. Use "[system]" to refer to the system-assigned identity or a resource ID '
'to refer to a user-assigned identity. If you use --auth-type without this parameter, '
'system-assigned managed identity is assumed.')

with self.argument_context('iot hub certificate') as c:
c.argument('certificate_path', options_list=['--path', '-p'], type=file_type,
Expand Down
6 changes: 6 additions & 0 deletions src/azure-cli/azure/cli/command_modules/iot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def load_command_table(self, _): # pylint: disable=too-many-statements
g.custom_show_command('show', 'iot_hub_consumer_group_get')
g.custom_command('delete', 'iot_hub_consumer_group_delete')

# iot hub identity commands
with self.command_group('iot hub identity', client_factory=iot_hub_service_factory) as g:
g.custom_command('assign', 'iot_hub_identity_assign')
g.custom_show_command('show', 'iot_hub_identity_show')
g.custom_command('remove', 'iot_hub_identity_remove')

# iot hub policy commands
with self.command_group('iot hub policy', client_factory=iot_hub_service_factory) as g:
g.custom_command('list', 'iot_hub_policy_list')
Expand Down
Loading