Skip to content

Commit

Permalink
[Role] az ad sp create-for-rbac: Add alias --json-auth for `--sdk…
Browse files Browse the repository at this point in the history
…-auth` (#26572)

* Add alias `--json-auth` for `--sdk-auth` of `az ad sp create-for-rbac`

* update help information

* remove the url
  • Loading branch information
MoChilia authored Jul 10, 2023
1 parent 7d3fdec commit e8efb79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ def refresh_accounts(self):
self._set_subscriptions(result, merge=False)

def get_sp_auth_info(self, subscription_id=None, name=None, password=None, cert_file=None):
"""Generate a JSON for --sdk-auth argument when used in:
- az ad sp create-for-rbac --sdk-auth
"""Generate a JSON for --json-auth argument when used in:
- az ad sp create-for-rbac --json-auth
"""
from collections import OrderedDict
account = self.get_subscription(subscription_id)
Expand Down
6 changes: 4 additions & 2 deletions src/azure-cli/azure/cli/command_modules/role/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ def load_arguments(self, _):
help='Role of the service principal.')
c.argument('skip_assignment', arg_type=get_three_state_flag(),
deprecate_info=c.deprecate(target='--skip-assignment', hide=True), help='No-op.')
c.argument('show_auth_for_sdk', options_list='--sdk-auth', deprecate_info=c.deprecate(target='--sdk-auth'),
help='output result in compatible with Azure SDK auth file', arg_type=get_three_state_flag())
c.argument('show_auth_in_json', options_list=['--sdk-auth', '--json-auth'],
deprecate_info=c.deprecate(target='--sdk-auth'),
help='Output service principal credential along with cloud endpoints in JSON format. ',
arg_type=get_three_state_flag())

with self.argument_context('ad sp owner list') as c:
c.argument('identifier', options_list=['--id'], help='service principal name, or object id or the service principal')
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/role/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ def list_service_principal_owners(client, identifier):
def create_service_principal_for_rbac(
# pylint:disable=too-many-statements,too-many-locals, too-many-branches, unused-argument
cmd, display_name=None, years=None, create_cert=False, cert=None, scopes=None, role=None,
show_auth_for_sdk=None, skip_assignment=False, keyvault=None):
show_auth_in_json=None, skip_assignment=False, keyvault=None):
import time

if role and not scopes or not role and scopes:
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def create_service_principal_for_rbac(

logger.warning(CREDENTIAL_WARNING)

if show_auth_for_sdk:
if show_auth_in_json:
from azure.cli.core._profile import Profile
profile = Profile(cli_ctx=cmd.cli_ctx)
result = profile.get_sp_auth_info(scopes[0].split('/')[2] if scopes else None,
Expand Down

0 comments on commit e8efb79

Please sign in to comment.