Skip to content
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
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/role/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@
text: az ad sp create-for-rbac
- name: Create using a custom display name.
text: az ad sp create-for-rbac -n "MyApp"
- name: Create with a Contributor role assignments on specified scope.
text: az ad sp create-for-rbac -n "MyApp" --role Contributor --scopes /subscriptions/{SubID}/resourceGroups/{ResourceGroup1} /subscriptions/{SubID}/resourceGroups/{ResourceGroup2}
- name: Create with a Contributor role assignments on specified scopes. To retrieve current subscription ID, run `az account show --query id --output tsv`.
text: az ad sp create-for-rbac -n "MyApp" --role Contributor --scopes /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup1} /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup2}
- name: Create using a self-signed certificate.
text: az ad sp create-for-rbac --create-cert
- name: Create using a self-signed certificate, and store it within KeyVault.
Expand Down
9 changes: 8 additions & 1 deletion src/azure-cli/azure/cli/command_modules/role/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@

logger = get_logger(__name__)

SCOPE_WARNING = "In a future release, --scopes argument will become required for creating a role assignment. " \
"Please explicitly specify --scopes."

# pylint: disable=too-many-lines


Expand Down Expand Up @@ -1403,7 +1406,11 @@ def create_service_principal_for_rbac(

graph_client = _graph_client_factory(cmd.cli_ctx)
role_client = _auth_client_factory(cmd.cli_ctx).role_assignments
scopes = scopes or ['/subscriptions/' + role_client.config.subscription_id]

if role and not scopes:
logger.warning(SCOPE_WARNING)
scopes = ['/subscriptions/' + role_client.config.subscription_id]
Comment on lines +1410 to +1412
Copy link
Member Author

@jiasli jiasli Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike #20924, the default value assignment is done in our own custom function, instead of letting knack assign the default value and set is_default.


years = years or 1
_RETRY_TIMES = 36
existing_sps = None
Expand Down