-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Microsoft Entra ID} az ad sp create-for-rbac: Update examples and warnings
#30277
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -528,18 +528,27 @@ | |||||||||||||||||||||||||||||||||||||
| You may also use `az role assignment create` to create role assignments for this service principal later. | ||||||||||||||||||||||||||||||||||||||
| See [steps to add a role assignment](https://aka.ms/azadsp-more) for more information. | ||||||||||||||||||||||||||||||||||||||
| examples: | ||||||||||||||||||||||||||||||||||||||
| - name: Create without role assignment. | ||||||||||||||||||||||||||||||||||||||
| 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 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/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1 /subscriptions/00000000-0000-0000-0000-000000000000/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. | ||||||||||||||||||||||||||||||||||||||
| text: az ad sp create-for-rbac --keyvault MyVault --cert CertName --create-cert | ||||||||||||||||||||||||||||||||||||||
| - name: Create using existing certificate in KeyVault. | ||||||||||||||||||||||||||||||||||||||
| text: az ad sp create-for-rbac --keyvault MyVault --cert CertName | ||||||||||||||||||||||||||||||||||||||
| - name: Create without role assignment. | ||||||||||||||||||||||||||||||||||||||
| 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 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/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup2 | ||||||||||||||||||||||||||||||||||||||
| - name: Create using a self-signed certificate. | ||||||||||||||||||||||||||||||||||||||
| text: az ad sp create-for-rbac --create-cert | ||||||||||||||||||||||||||||||||||||||
| - name: Create using an existing certificate string. | ||||||||||||||||||||||||||||||||||||||
| text: az ad sp create-for-rbac --cert "MIICoT..." | ||||||||||||||||||||||||||||||||||||||
| - name: Create using an existing certificate file. | ||||||||||||||||||||||||||||||||||||||
| text: |- | ||||||||||||||||||||||||||||||||||||||
| az ad sp create-for-rbac --cert "@~/cert.pem" | ||||||||||||||||||||||||||||||||||||||
| `cert.pem` contains the following content | ||||||||||||||||||||||||||||||||||||||
| -----BEGIN CERTIFICATE----- <<< this line is optional | ||||||||||||||||||||||||||||||||||||||
| MIICoT... | ||||||||||||||||||||||||||||||||||||||
| -----END CERTIFICATE----- <<< this line is optional | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+539
to
+547
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These examples are similar to azure-cli/src/azure-cli/azure/cli/command_modules/role/_help.py Lines 127 to 135 in 031de0d
azure-cli/src/azure-cli/azure/cli/command_modules/role/_help.py Lines 594 to 602 in 031de0d
|
||||||||||||||||||||||||||||||||||||||
| - name: Create using a self-signed certificate, and store it within Azure Key Vault. | ||||||||||||||||||||||||||||||||||||||
| text: az ad sp create-for-rbac --keyvault MyVault --cert CertName --create-cert | ||||||||||||||||||||||||||||||||||||||
| - name: Create using existing certificate in Azure Key Vault. | ||||||||||||||||||||||||||||||||||||||
| text: az ad sp create-for-rbac --keyvault MyVault --cert CertName | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+548
to
+551
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The official name should be "Azure Key Vault", not "KeyVault": https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-cli |
||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| helps['ad sp credential'] = """ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1302,14 +1302,10 @@ def create_service_principal_for_rbac( | |
| } | ||
| if cert_file: | ||
| logger.warning( | ||
| "Please copy %s to a safe place. When you run 'az login', provide the file path in the --password argument", | ||
| "Please copy %s to a safe place. When you run `az login`, provide the file path in the --certificate " | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed according to #30091. |
||
| "argument", | ||
| cert_file) | ||
| result['fileWithCertAndPrivateKey'] = cert_file | ||
|
|
||
| login_hint = ('To log in with this service principal, run:\n' | ||
| f'az login --service-principal --username {app_id} --password {password or cert_file} ' | ||
| f'--tenant {graph_client.tenant}') | ||
| logger.info(login_hint) | ||
|
Comment on lines
-1308
to
-1312
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hint is removed to avoid users' potential incorrect handling of the log. |
||
| return result | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it does not affect the help message, the two-space indent is missing here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the contrary, the two-space indent is unnecessary. See the YAML spec:
https://yaml.org/spec/1.2.2/#21-collections
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YAML does not have a strict indent rule; my formatter uses 2 spaces.
PS: The indentation at https://yaml.org/ is inconsistent.
