Skip to content

Commit e07b6a9

Browse files
committed
add --system-identity for redis
1 parent 024cfb6 commit e07b6a9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/azure-cli/azure/cli/command_modules/serviceconnector/_resource_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ class CLIENT_TYPE(Enum):
782782
RESOURCE.Mysql: [AUTH_TYPE.Secret],
783783
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret, AUTH_TYPE.UserAccount],
784784
RESOURCE.Sql: [AUTH_TYPE.Secret, AUTH_TYPE.UserAccount],
785-
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
785+
RESOURCE.Redis: [AUTH_TYPE.SecretAuto, AUTH_TYPE.UserAccount, AUTH_TYPE.ServicePrincipalSecret],
786786
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],
787787

788788
RESOURCE.CosmosCassandra: [AUTH_TYPE.SecretAuto, AUTH_TYPE.UserAccount, AUTH_TYPE.ServicePrincipalSecret],
@@ -811,7 +811,7 @@ class CLIENT_TYPE(Enum):
811811
RESOURCE.Mysql: [AUTH_TYPE.Secret],
812812
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
813813
RESOURCE.Sql: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
814-
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
814+
RESOURCE.Redis: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
815815
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],
816816

817817
RESOURCE.CosmosCassandra: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
@@ -843,7 +843,7 @@ class CLIENT_TYPE(Enum):
843843
RESOURCE.Mysql: [AUTH_TYPE.Secret],
844844
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
845845
RESOURCE.Sql: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
846-
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
846+
RESOURCE.Redis: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
847847
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],
848848

849849
RESOURCE.CosmosCassandra: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
@@ -875,7 +875,7 @@ class CLIENT_TYPE(Enum):
875875
RESOURCE.Mysql: [AUTH_TYPE.Secret],
876876
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret],
877877
RESOURCE.Sql: [AUTH_TYPE.Secret],
878-
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
878+
RESOURCE.Redis: [AUTH_TYPE.WorkloadIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
879879
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],
880880

881881
RESOURCE.CosmosCassandra: [AUTH_TYPE.WorkloadIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],

src/azure-cli/azure/cli/command_modules/serviceconnector/_validators.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,18 +958,27 @@ def validate_service_state(linker_parameters):
958958
if matched:
959959
target_type = target
960960

961+
auth_type = linker_parameters.get('auth_info', {}).get('auth_type')
961962
if target_type == RESOURCE.AppConfig and linker_parameters.get('auth_info', {}).get('auth_type') == 'secret':
962963
segments = parse_resource_id(target_id)
963964
rg = segments.get('resource_group')
964965
name = segments.get('name')
966+
sub = segments.get('subscription')
965967
if not rg or not name:
966968
return
967969

968-
output = run_cli_cmd('az appconfig show -g "{}" -n "{}"'.format(rg, name))
970+
output = run_cli_cmd('az appconfig show -g "{}" -n "{}" --subscription "{}"'.format(rg, name, sub))
969971
if output and output.get('disableLocalAuth') is True:
970972
raise ValidationError('Secret as auth type is not allowed when local auth is disabled for the '
971973
'specified appconfig, you may use service principal or managed identity.')
972974

975+
if target_type == RESOURCE.Redis:
976+
if auth_type == AUTH_TYPE.Secret or auth_type == AUTH_TYPE.SecretAuto:
977+
return
978+
redis = run_cli_cmd('az redis show --ids "{}"'.format(target_id))
979+
if redis.get('redisConfiguration', {}).get('aadEnabled', 'False') != "True":
980+
raise ValidationError('Please enable Microsoft Entra Authentication on your Redis first. Note that it will cause your cache instances to reboot to load new configuration and result in a failover. Consider performing the operation during low traffic or outside of business hours.')
981+
973982

974983
def get_default_object_id_of_current_user(cmd, namespace): # pylint: disable=unused-argument
975984
user_account_auth_info = getattr(namespace, 'user_account_auth_info', None)

0 commit comments

Comments
 (0)