Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceConnector] az webapp connection create redis: Add --system-identity param #30630

Merged
merged 3 commits into from
Jan 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ class CLIENT_TYPE(Enum):
RESOURCE.Mysql: [AUTH_TYPE.Secret],
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret, AUTH_TYPE.UserAccount],
RESOURCE.Sql: [AUTH_TYPE.Secret, AUTH_TYPE.UserAccount],
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
RESOURCE.Redis: [AUTH_TYPE.SecretAuto, AUTH_TYPE.UserAccount, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],

RESOURCE.CosmosCassandra: [AUTH_TYPE.SecretAuto, AUTH_TYPE.UserAccount, AUTH_TYPE.ServicePrincipalSecret],
Expand Down Expand Up @@ -811,7 +811,7 @@ class CLIENT_TYPE(Enum):
RESOURCE.Mysql: [AUTH_TYPE.Secret],
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.Sql: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
RESOURCE.Redis: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],

RESOURCE.CosmosCassandra: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
Expand Down Expand Up @@ -843,7 +843,7 @@ class CLIENT_TYPE(Enum):
RESOURCE.Mysql: [AUTH_TYPE.Secret],
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.Sql: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
RESOURCE.Redis: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],

RESOURCE.CosmosCassandra: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
Expand Down Expand Up @@ -875,7 +875,7 @@ class CLIENT_TYPE(Enum):
RESOURCE.Mysql: [AUTH_TYPE.Secret],
RESOURCE.MysqlFlexible: [AUTH_TYPE.Secret],
RESOURCE.Sql: [AUTH_TYPE.Secret],
RESOURCE.Redis: [AUTH_TYPE.SecretAuto],
RESOURCE.Redis: [AUTH_TYPE.WorkloadIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.RedisEnterprise: [AUTH_TYPE.SecretAuto],

RESOURCE.CosmosCassandra: [AUTH_TYPE.WorkloadIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,14 +962,26 @@ def validate_service_state(linker_parameters):
segments = parse_resource_id(target_id)
rg = segments.get('resource_group')
name = segments.get('name')
sub = segments.get('subscription')
if not rg or not name:
return

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

if target_type == RESOURCE.Redis:
auth_type = linker_parameters.get('auth_info', {}).get('auth_type')
if auth_type == AUTH_TYPE.Secret.value or auth_type == AUTH_TYPE.SecretAuto.value:
return
redis = run_cli_cmd('az redis show --ids "{}"'.format(target_id))
if redis.get('redisConfiguration', {}).get('aadEnabled', 'False') != "True":
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.')


def get_default_object_id_of_current_user(cmd, namespace): # pylint: disable=unused-argument
user_account_auth_info = getattr(namespace, 'user_account_auth_info', None)
Expand Down
Loading