Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
fd6af49
{ARO} add __init__.py for ARO tests and update recording (#13089)
Apr 20, 2020
ad2a70f
{Profile} az login: Polish UnicodeDecodeError (#12972)
jiasli Apr 20, 2020
8937383
{Aladdin} add usage examples for module: monitor network privatedns r…
Apr 20, 2020
66fe624
[Compute] az vmss disk detach: fix data disk NoneType issue (#13069)
arrownj Apr 20, 2020
2989946
[ARO] Fixed az aro table output bug (#13066)
m1kola Apr 20, 2020
758f7e9
fix CI (#13114)
mmyyrroonn Apr 22, 2020
9abb510
[Core] fix logging file fd leaking (#13102)
Apr 22, 2020
0ae790c
[AppService] remove sleep after request.get() (#12609)
bmc-msft Apr 22, 2020
2862ce5
[Network] az network security-partner: support security partner provi…
mmyyrroonn Apr 22, 2020
89cf88c
[KeyVault] Add new parameter `--enable-rbac-authorization` during cre…
bim-msft Apr 22, 2020
21172d9
[AKS] az aks create: Add support for Windows (#13084)
AbelHu Apr 23, 2020
facd2bd
fix ci (#13132)
mmyyrroonn Apr 23, 2020
b3d6fb7
{ACR} Fix small typos (#13142)
pablomh Apr 24, 2020
fdc155c
{Compute} Delete stale test of image builder (#13134)
qwordy Apr 24, 2020
12367f8
rename (#13147)
mmyyrroonn Apr 24, 2020
4a58bcb
[Core] fix core tests failed under certain profiles (#13136)
Apr 24, 2020
b93fab1
[Privatedns] Add feature in private DNS zone to import export zone fi…
rahisshaikh Apr 26, 2020
d10679e
{Resource} Remove resource test test_resource_policyset from profile …
Apr 26, 2020
f4ff610
[Monitor] Support LA cluster CMK features (#13133)
jsntcy Apr 26, 2020
80c7bc7
{Core} support get msal accesstoken with adal refresh token for vm ss…
arrownj Apr 26, 2020
4e1ed61
{REST} az rest: Refine help (#13067)
jiasli Apr 26, 2020
dada5c0
{Compute} Update doc of image-version (#13112)
qwordy Apr 27, 2020
5fff003
[Compute] az vm availability-set list: Support showing VM list (#13090)
qwordy Apr 27, 2020
32e5102
[ACS] BREAKING CHANGE: ARO remove vnet-peer, upgrade to 2019-10-27-pr…
Apr 27, 2020
984817c
[Compute] az vm list-skus: Fix display problem of table format (#13184)
qwordy Apr 27, 2020
79964fb
[Monitor] az monitor log-analytics workspace linked-storage: supports…
mmyyrroonn Apr 27, 2020
d261ede
[CI] Onboard pytest and deprecate nose for Automation Test (#13153)
Apr 27, 2020
a638130
[ARM] az deployment sub/group what-if:Add new commands to support Wha…
shenglol Apr 27, 2020
44c3b4a
[Core] Unpin wheel version via pkginfo to query metadata for Python P…
Apr 27, 2020
06cce5b
revert wheel to 0.30.0 (#13198)
Apr 27, 2020
2349420
update azure-cli version to 2.5.0 (#13206)
Apr 28, 2020
37fcdc6
fix style (#13218)
Juliehzl Apr 28, 2020
69c9933
{CI} Fix running full test timeout on profile when in batch mode (#13…
Apr 28, 2020
21e8a2c
upgrade package (#13183)
Juliehzl Apr 28, 2020
cf7f852
[Storage] Support GZRS for storage account creation and update (#13196)
Juliehzl Apr 28, 2020
015be59
[SQL] `az sql instance-pool`: Add instance pools command group (#11721)
rohands Apr 28, 2020
c8edc08
re-run (#13224)
mmyyrroonn Apr 28, 2020
d60ceda
[Compute] vm list-ip-addresses: Error handling (#13186)
qwordy Apr 28, 2020
35c140c
{Network} fix duplicated quotes for private-endpoint example (#13227)
Apr 28, 2020
91f91cc
[Extension] fix loading wrong metadata for wheel type extension (#13222)
Apr 28, 2020
3315616
[Cosmos DB] az cosmosdb create/update: add --enable-public-network su…
soeom Apr 28, 2020
16de64f
[ACR] `az acr check-health`: Fix "DOCKER_PULL_ERROR" on Windows (#13158)
Wwwsylvia Apr 29, 2020
b302f30
[Compute] Fix a bug of vm create if endpoint_vm_image_alias_doc is no…
qwordy Apr 29, 2020
868decc
[Packaging] Add az script for Git Bash/Cygwin on Windows (#13197)
fengzhou-msft Apr 29, 2020
154ecaa
[Compute] vmss create: Add --os-disk-size-gb (#13180)
qwordy Apr 29, 2020
1d64349
{Packaging} Remove wheel as a runtime dependency (#13230)
fengzhou-msft Apr 29, 2020
bd8a963
[Storage] `az storage account failover`: Add support for grs/gzrs sto…
Juliehzl Apr 30, 2020
4acf761
{Extension} Enhance the ability to filter extension's dist-info in or…
Apr 30, 2020
6fc125b
[Storage] `az storage blob upload`: Add --encryption-scope parameter …
Juliehzl Apr 30, 2020
c8bb769
upgarde version (#13265)
Juliehzl Apr 30, 2020
ba399c7
{Release} Upgrade to Azure CLI 2.5.1 (#13263)
Apr 30, 2020
527267b
{Profile} az login: In WSL use powershell.exe to open the default bro…
jiasli Apr 30, 2020
2aa71a7
pass test for connection string (#13273)
Juliehzl Apr 30, 2020
44c092a
{Config} Add endpoint suffix for mysql and postgre sql (#13115)
handsomesun May 6, 2020
f4f44bd
[AppService] functionapp: AzureWebJobsDashboard will only be set if A…
gzuber May 6, 2020
b7a41a3
fix in enable protection for fileshare cmd (#13268)
May 6, 2020
066ca6e
Fix in restore flow (#13348)
May 6, 2020
2325d7c
{Docs} Quote code in help messages with backticks (#13060)
jiasli May 6, 2020
7674236
[Extension] Support installing extensions in a system directory (#12856)
fengzhou-msft May 6, 2020
2343260
[AppService] fix #10664- VNet Integration - Location Check Issue & fi…
Kotasudhakarreddy May 6, 2020
7a087b1
[IoT] Update the IoT command module first run extension awareness mes…
digimaun May 7, 2020
949aaa0
[Network] fix ttl value changed unintended for dns add-record (#13243)
May 7, 2020
e6a19f2
[Compute] New command az vm auto-shutdown (#13199)
qwordy May 7, 2020
a2ab44e
refine help message (#13372)
mmyyrroonn May 7, 2020
cd405fa
ACS: remove fields cleanup that no longer exist (#13315)
May 7, 2020
da047a1
[AKS] update uptime-sla command help context (#13300)
zqingqing1 May 7, 2020
a6fc7da
[Extension] support .egg-info to store wheel type extension metadata …
May 7, 2020
26e341b
[AppConfig] Bug fix for list key values with fields (#13326)
shenmuxiaosen May 7, 2020
df10af0
{AppService}: Updating websites to use the latest SDK version (#13328)
panchagnula May 7, 2020
cef3cf4
{CI} temporary disable CredScan since ADO bug (#13388)
May 8, 2020
f2fa95a
acr: add timeout of 5 minutes (#13349)
yugangw-msft May 8, 2020
08328cd
{Packaging} Clean some azure-cli dependencies (#13253)
fengzhou-msft May 8, 2020
c3f32ed
[ACR] Support disable public network access (#13347)
yugangw-msft May 8, 2020
aa9c4c1
[ARM] az deployment: Fix the problem that the templateLink will not b…
zhoxing-ms May 8, 2020
2de661c
{Storage} Use get_login_credentials from Core for --auth-mode login i…
Juliehzl May 8, 2020
28cc8f4
Bump ADAL version to 1.2.3 (#13371)
jiasli May 8, 2020
4b495b0
[Network] az network public-ip create: Inform customers of a coming b…
jsntcy May 8, 2020
a15c836
[ARO] Add examples to az aro create, list, list-credentials, show, de…
troy0820 May 9, 2020
f04507a
Update python SDK (#13287)
soeom May 9, 2020
14ecf9e
[Storage] az storage account file-service-properties update/show: Add…
Juliehzl May 9, 2020
05d6f12
[ACR]: bug fixes on token create and image import commands (#13392)
yugangw-msft May 9, 2020
137fcc8
{CI} Allow CI to pass on fork repos (#13398)
jiasli May 9, 2020
193c17c
{Docs} Documentation update for configuring machine in VS Code (#13239)
niswitze May 9, 2020
3c8bf29
Fixes az openshift show command (#13358)
m1kola May 9, 2020
5f3c3da
Fix the problem that deployment does not support specially encoded ch…
zhoxing-ms May 9, 2020
70bedda
{Compute} az vm auto-shutdown: remove a validation (#13409)
qwordy May 11, 2020
938bbaf
[RBAC] `az ad sp credential reset`: fix weak credential generation (#…
qianwens May 11, 2020
0caf144
[Network] support generic commands for private link scenario (#13225)
mmyyrroonn May 11, 2020
bd3dfd5
[Network] az network private-endpoint-connection: Support mysql, post…
mmyyrroonn May 11, 2020
197fcf6
acr: keep show-endpoints command in preview (#13430)
yugangw-msft May 11, 2020
0fc82ed
[AMS] Change az ams transform create and az ams content-key-policy cr…
hivyas May 12, 2020
827774b
[Packaging] Build MSI/Homebrew packages with dependecies resolved fro…
fengzhou-msft May 12, 2020
fce911e
[CI] Support flake8 3.8.0 (#13454)
May 12, 2020
b465b2a
{Docs} Increase visibility of doc/use_cli_effectively.md (#13249)
jiasli May 13, 2020
50a18e8
[Network] az network private-endpoint-connection: Support cosmosdb ty…
mmyyrroonn May 13, 2020
0ce0448
[Core] Update local context on/off status to global user level (#13277)
arrownj May 13, 2020
830672d
remove range check for updating min count for autoscaler (#13215)
marwanad May 13, 2020
c07a398
{CI} Code style check use latest azdev (#13450)
May 13, 2020
fe18bc1
[AppService] az webapp|functionapp config ssl import: Lookup key vaul…
madsd May 14, 2020
df5cfde
{CI} Re-enable CredScan (#13464)
May 14, 2020
39c0d01
[ARM] az deployment sub/group what-if: Fix array alignment and error …
shenglol May 14, 2020
3d1fc80
change sappservice code (#13412)
Juliehzl May 14, 2020
f629608
{ACR} Use azure.multiapi.storage for storage blob service (#13411)
Juliehzl May 14, 2020
bcb9921
{batchai} Change storage dependency (#13414)
Juliehzl May 14, 2020
a6a469f
{TestSDK} Delete local context file when local context scenario test …
arrownj May 14, 2020
8f149eb
[ARO]Add generate_random_id function (#13482)
troy0820 May 14, 2020
863517e
{Resource} Remove unused f-string to fix code style (#13493)
May 14, 2020
8027e06
{Doc} Add quoting-issues-with-powershell.md (#13419)
jiasli May 14, 2020
989924e
{Core} Load vnet/subnet global definition for local context by defaul…
arrownj May 14, 2020
a70d7db
Added "MAB" backupmanagementtype to item list command (#13449)
May 14, 2020
ca63e5d
[Backup] Add support for retrying policy update for failed items. (#1…
May 14, 2020
28b1422
[Backup] Add Resume Protection functionality for Azure Virtual Machin…
May 14, 2020
2c3097b
[Backup] Add support to specify ResourceGroup for storing instantRP d…
May 14, 2020
73ee5ce
[Storage] `az storage container create`: Fix #13373 by adding validat…
Juliehzl May 14, 2020
e6e437a
[Output] Show update instruction in find, feedback and --help (#13345)
fengzhou-msft May 14, 2020
2439cc8
[Storage] Add ADLS Gen2 track2 support (#12729)
Juliehzl May 15, 2020
50cedea
{ACR}: expose --expiration from token commands (#13451)
yugangw-msft May 15, 2020
f7e6bba
Fix that cli doe not fail when user only specifies Windows password (…
AbelHu May 15, 2020
cb927d5
[Compute] az vm list-skus: Update --zone behavior, return all type sk…
qwordy May 15, 2020
58198af
[IoT Hub] Support for 2020-03-01 API and Network Isolation commands (…
c-ryan-k May 15, 2020
2e850ea
{Monitor} az monitor metrics alert: refine severity explanation (#13512)
mmyyrroonn May 15, 2020
80457eb
[AppService] Onboard local context for app service (#12984)
arrownj May 15, 2020
4d73f0f
Modify the deprecate information for deployment operation (#13390)
zhoxing-ms May 15, 2020
08432df
Support --connect-string for az storage blob sync (#13135)
zhoxing-ms May 15, 2020
9b71e8a
[Storage] az storage blob sync: Fix the incorrect error message when …
zhoxing-ms May 15, 2020
bae215b
{Network} az network nic create: Refine help message (#13513)
mmyyrroonn May 15, 2020
ee84afb
[NetAppFiles] Anf 5207 Bugfix - add missing snapshot restore function…
audunn May 15, 2020
fe1e042
{Resource} Add example to tell how to pass array to --parameters (#13…
May 16, 2020
530cd07
fix (#13511)
mmyyrroonn May 18, 2020
029e73b
{Release} Upgrade to Azure CLI 2.6.0 (#13542)
May 18, 2020
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
Prev Previous commit
Next Next commit
[IoT Hub] Support for 2020-03-01 API and Network Isolation commands (#…
…13467)

* Add authenticationType, endpointUri, and entityPath parameters to routing endpoint creation

* Added AuthType and ContainerURI fileupload parameters on hub create

* Support for fileUpload authenticationType change on iot hub update command

* removed debug line

* Testing and formatting updates, added temporary template file for identity-based hub creation

* Moved identity-based hub tests to new test function to avoid hub confusion and speed up testing iteration

* Fix for Identity-Based file upload not utilizing connectionString

* Test recording updates

* WIP: Private-endpoint and private link resource implementation

* parameter fixes

* test recording updates

* whitespace / formatting fixes

* Added help commands for private-endpoint-connection and private-link-resources commands

* Added help example for identity-based routing endpoint

* Removed accidental change

* Linting and style updates, addressing PR feedback

* Rollback of accidental profile version update

* SDK and test updates

* Test template path/name fix and test update

* History update

* Test updates

* Address PR feedback

Moved private-endpoint-connection and private-link-resources into network module, updated tests, and addressed PR feedback

* Help update

* Address PR Feedback - add test recording processor to obscure access keys, updated tests

Co-authored-by: Ryan Kelly <[email protected]>
  • Loading branch information
c-ryan-k and c-ryan-k authored May 15, 2020
commit 58198af0d650df1433f329f2ab42572836bae62e
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 @@ -196,7 +196,7 @@ def default_api_version(self):
'private_endpoint_connections': '2019-10-17-preview'
}),
ResourceType.MGMT_APPSERVICE: '2019-08-01',
ResourceType.MGMT_IOTHUB: '2019-07-01-preview',
ResourceType.MGMT_IOTHUB: '2020-03-01',
ResourceType.MGMT_ARO: '2020-04-30'
},
'2019-03-01-hybrid': {
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/iot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,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"
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}
"""

helps['iot hub routing-endpoint delete'] = """
Expand Down
14 changes: 14 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 @@ -20,6 +20,7 @@
RouteSourceType,
EncodingFormat,
RenewKeyType,
AuthenticationType,
UserRole)
from .custom import KeyType, SimpleAccessRights
from ._validators import (validate_policy_permissions,
Expand Down Expand Up @@ -160,6 +161,13 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
c.argument('fileupload_storage_connectionstring',
options_list=['--fileupload-storage-connectionstring', '--fcs'],
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.'
'Possible values are keyBased and identityBased')
c.argument('fileupload_storage_container_uri',
options_list=['--fileupload-storage-container-uri', '--fcu'],
help='The container URI for the Azure Storage account to which files are uploaded.')
c.argument('fileupload_storage_container_name',
options_list=['--fileupload-storage-container-name', '--fc'],
help='The name of the root container where you upload files. The container need not exist but'
Expand Down Expand Up @@ -207,6 +215,10 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
c.argument('encoding', options_list=['--encoding'], arg_type=get_enum_type(EncodingFormat),
help='Encoding format for the container. The default is AVRO. '
'Note that this field is applicable only for blob container endpoints.')
c.argument('endpoint_uri', options_list=['--endpoint-uri'],
help='The uri of the endpoint resource.')
c.argument('entity_path', options_list=['--entity-path'],
help='The entity path of the endpoint resource.')

with self.argument_context('iot hub routing-endpoint create') as c:
c.argument('batch_frequency', options_list=['--batch-frequency', '-b'], type=int,
Expand All @@ -218,6 +230,8 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
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.')
c.argument('authentication_type', options_list=['--auth-type'], arg_type=get_enum_type(AuthenticationType),
help='Authentication type for the endpoint. The default is keyBased.')

with self.argument_context('iot hub certificate') as c:
c.argument('certificate_path', options_list=['--path', '-p'], type=file_type,
Expand Down
71 changes: 60 additions & 11 deletions src/azure-cli/azure/cli/command_modules/iot/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

from azure.cli.command_modules.iot.mgmt_iot_hub_device.lib.iot_hub_device_client import IotHubDeviceClient
from azure.cli.command_modules.iot.sas_token_auth import SasTokenAuthentication
from azure.cli.command_modules.iot.shared import EndpointType, EncodingFormat, RenewKeyType
from azure.cli.command_modules.iot.shared import EndpointType, EncodingFormat, RenewKeyType, AuthenticationType
from ._constants import PNP_ENDPOINT
from ._client_factory import resource_service_factory, get_pnp_client
from ._utils import open_certificate, get_auth_header, generateKey
Expand Down Expand Up @@ -388,7 +388,9 @@ def iot_hub_create(cmd, client, hub_name, resource_group_name, location=None,
fileupload_notification_ttl=1,
fileupload_storage_connectionstring=None,
fileupload_storage_container_name=None,
fileupload_sas_ttl=1):
fileupload_sas_ttl=1,
fileupload_storage_authentication_type=None,
fileupload_storage_container_uri=None):
from datetime import timedelta
cli_ctx = cmd.cli_ctx
if enable_fileupload_notifications:
Expand All @@ -398,6 +400,11 @@ def iot_hub_create(cmd, client, hub_name, resource_group_name, location=None,
raise CLIError('Please mention storage container name.')
if fileupload_storage_container_name and not fileupload_storage_connectionstring:
raise CLIError('Please mention storage connection string.')
identity_based_file_upload = fileupload_storage_authentication_type and fileupload_storage_authentication_type.lower() == AuthenticationType.IdentityBased.value
if not identity_based_file_upload and not fileupload_storage_connectionstring and fileupload_storage_container_name:
raise CLIError('Key-based authentication requires a connection string.')
if identity_based_file_upload and not fileupload_storage_container_uri:
raise CLIError('Identity-based authentication requires a storage container uri (--fileupload-storage-container-uri, --fcu).')
_check_name_availability(client.iot_hub_resource, hub_name)
location = _ensure_location(cli_ctx, resource_group_name, location)
sku = IotHubSkuInfo(name=sku, capacity=unit)
Expand All @@ -418,7 +425,9 @@ def iot_hub_create(cmd, client, hub_name, resource_group_name, location=None,
storage_endpoint_dic['$default'] = StorageEndpointProperties(
sas_ttl_as_iso8601=timedelta(hours=fileupload_sas_ttl),
connection_string=fileupload_storage_connectionstring if fileupload_storage_connectionstring else '',
container_name=fileupload_storage_container_name if fileupload_storage_container_name else '')
container_name=fileupload_storage_container_name if fileupload_storage_container_name else '',
authentication_type=fileupload_storage_authentication_type if fileupload_storage_authentication_type else None,
container_uri=fileupload_storage_container_uri if fileupload_storage_container_uri else '')

properties = IotHubProperties(event_hub_endpoints=event_hub_dic,
messaging_endpoints=msg_endpoint_dic,
Expand Down Expand Up @@ -472,7 +481,9 @@ def update_iot_hub_custom(instance,
fileupload_notification_ttl=None,
fileupload_storage_connectionstring=None,
fileupload_storage_container_name=None,
fileupload_sas_ttl=None):
fileupload_sas_ttl=None,
fileupload_storage_authentication_type=None,
fileupload_storage_container_uri=None):
from datetime import timedelta
if sku is not None:
instance.sku.name = sku
Expand All @@ -499,6 +510,15 @@ def update_iot_hub_custom(instance,
if fileupload_notification_ttl is not None:
ttl = timedelta(hours=fileupload_notification_ttl)
instance.properties.messaging_endpoints['fileNotifications'].ttl_as_iso8601 = ttl

identity_based_file_upload = fileupload_storage_authentication_type and fileupload_storage_authentication_type.lower() == AuthenticationType.IdentityBased.value
if identity_based_file_upload:
instance.properties.storage_endpoints['$default'].authentication_type = AuthenticationType.IdentityBased
instance.properties.storage_endpoints['$default'].container_uri = fileupload_storage_container_uri
elif fileupload_storage_authentication_type is not None:
instance.properties.storage_endpoints['$default'].authentication_type = None
instance.properties.storage_endpoints['$default'].container_uri = None
# TODO - remove connection string and set containerURI once fileUpload SAS URL is enabled
if fileupload_storage_connectionstring is not None and fileupload_storage_container_name is not None:
instance.properties.storage_endpoints['$default'].connection_string = fileupload_storage_connectionstring
instance.properties.storage_endpoints['$default'].container_name = fileupload_storage_container_name
Expand Down Expand Up @@ -672,11 +692,26 @@ def iot_hub_get_stats(client, hub_name, resource_group_name=None):
return client.iot_hub_resource.get_stats(resource_group_name, hub_name)


def validate_authentication_type_input(endpoint_type, connection_string=None, authentication_type=None, endpoint_uri=None, entity_path=None):
is_keyBased = (AuthenticationType.KeyBased.value == authentication_type.lower()) or (authentication_type is None)
has_connection_string = (connection_string is not None)
if is_keyBased and not has_connection_string:
raise CLIError("Please provide a connection string '--connection-string/-c'")

has_endpoint_uri = (endpoint_uri is not None)
has_endpoint_uri_and_path = (has_endpoint_uri) and (entity_path is not None)
if EndpointType.AzureStorageContainer.value == endpoint_type.lower() and not has_endpoint_uri:
raise CLIError("Please provide an endpoint uri '--endpoint-uri'")
if not has_endpoint_uri_and_path:
raise CLIError("Please provide an endpoint uri '--endpoint-uri' and entity path '--entity-path'")


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,
connection_string=None, container_name=None, encoding=None,
resource_group_name=None, batch_frequency=300, chunk_size_window=300,
file_name_format='{iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}'):
file_name_format='{iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}',
authentication_type=None, endpoint_uri=None, entity_path=None):
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 All @@ -685,7 +720,10 @@ def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoi
connection_string=connection_string,
name=endpoint_name,
subscription_id=endpoint_subscription_id,
resource_group=endpoint_resource_group
resource_group=endpoint_resource_group,
authentication_type=authentication_type,
endpoint_uri=endpoint_uri,
entity_path=entity_path
)
)
elif EndpointType.ServiceBusQueue.value == endpoint_type.lower():
Expand All @@ -694,7 +732,10 @@ def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoi
connection_string=connection_string,
name=endpoint_name,
subscription_id=endpoint_subscription_id,
resource_group=endpoint_resource_group
resource_group=endpoint_resource_group,
authentication_type=authentication_type,
endpoint_uri=endpoint_uri,
entity_path=entity_path
)
)
elif EndpointType.ServiceBusTopic.value == endpoint_type.lower():
Expand All @@ -703,7 +744,10 @@ def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoi
connection_string=connection_string,
name=endpoint_name,
subscription_id=endpoint_subscription_id,
resource_group=endpoint_resource_group
resource_group=endpoint_resource_group,
authentication_type=authentication_type,
endpoint_uri=endpoint_uri,
entity_path=entity_path
)
)
elif EndpointType.AzureStorageContainer.value == endpoint_type.lower():
Expand All @@ -719,7 +763,9 @@ def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoi
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)
max_chunk_size_in_bytes=(chunk_size_window * 1048576),
authentication_type=authentication_type,
endpoint_uri=endpoint_uri
)
)
return client.iot_hub_resource.create_or_update(resource_group_name, hub_name, hub, {'IF-MATCH': hub.etag})
Expand Down Expand Up @@ -891,8 +937,11 @@ def iot_message_enrichment_list(cmd, client, hub_name, resource_group_name=None)


def iot_hub_devicestream_show(cmd, client, hub_name, resource_group_name=None):
from azure.cli.core.commands.client_factory import get_mgmt_service_client, ResourceType
resource_group_name = _ensure_resource_group_name(client, resource_group_name, hub_name)
hub = iot_hub_get(cmd, client, hub_name, resource_group_name)
# DeviceStreams property is still in preview, so until GA we need to use an older API version (2019-07-01-preview)
client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_IOTHUB, api_version='2019-07-01-preview')
hub = client.iot_hub_resource.get(resource_group_name, hub_name)
return hub.properties.device_streams


Expand Down
9 changes: 9 additions & 0 deletions src/azure-cli/azure/cli/command_modules/iot/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ class RenewKeyType(Enum):
Primary = 'primary'
Secondary = 'secondary'
Swap = 'swap'


# pylint: disable=too-few-public-methods
class AuthenticationType(Enum):
"""
Type of the Authentication for the routing endpoint.
"""
KeyBased = 'keybased'
IdentityBased = 'identitybased'
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure_devtools.scenario_tests import RecordingProcessor
from azure_devtools.scenario_tests.utilities import is_text_payload

MOCK_KEY = 'mock_key'


class KeyReplacer(RecordingProcessor):

def process_request(self, request):
if is_text_payload(request) and isinstance(request.body, bytes):
request.body = self._replace_byte_keys(request.body)
elif is_text_payload(request) and isinstance(request.body, str):
request.body = self._replace_string_keys(request.body)
return request

def process_response(self, response):
if is_text_payload(response) and response['body']['string']:
response['body']['string'] = self._replace_string_keys(response['body']['string'])
return response

# pylint: disable=no-self-use
def _replace_string_keys(self, val):
import re
if 'primaryKey' in val:
val = re.sub(r'"primaryKey":( ?)"([^"]+)"', r'"primaryKey":"{}"'
.format(MOCK_KEY), val, flags=re.IGNORECASE)
if 'secondaryKey' in val:
val = re.sub(r'"secondaryKey":( ?)"([^"]+)"', r'"secondaryKey":"{}"'
.format(MOCK_KEY), val, flags=re.IGNORECASE)
return val

# pylint: disable=no-self-use
def _replace_byte_keys(self, val):
import re
if b'primaryKey' in val:
val = re.sub(b'"primaryKey":( ?)"([^"]+)"', '"primaryKey":"{}"'
.format(MOCK_KEY).encode(), val, flags=re.IGNORECASE)
if b'secondaryKey' in val:
val = re.sub(b'"secondaryKey":( ?)"([^"]+)"', '"secondaryKey":"{}"'
.format(MOCK_KEY).encode(), val, flags=re.IGNORECASE)
return val
Loading