-
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
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @jiasli, |
️✔️AzureCLI-BreakingChangeTest
|
|
Update examples and warnings |
| - 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 |
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.
These examples are similar to
azure-cli/src/azure-cli/azure/cli/command_modules/role/_help.py
Lines 127 to 135 in 031de0d
| - name: Append a certificate to the application with the certificate string. | |
| text: az ad app credential reset --id 00000000-0000-0000-0000-000000000000 --cert "MIICoT..." --append | |
| - name: Append a certificate to the application with the certificate file. | |
| text: |- | |
| az ad app credential reset --id 00000000-0000-0000-0000-000000000000 --cert "@~/cert.pem" --append | |
| `cert.pem` contains the following content | |
| -----BEGIN CERTIFICATE----- <<< this line is optional | |
| MIICoT... | |
| -----END CERTIFICATE----- <<< this line is optional |
azure-cli/src/azure-cli/azure/cli/command_modules/role/_help.py
Lines 594 to 602 in 031de0d
| - name: Append a certificate to the service principal with the certificate string. | |
| text: az ad sp credential reset --id 00000000-0000-0000-0000-000000000000 --cert "MIICoT..." --append | |
| - name: Append a certificate to the service principal with the certificate file. | |
| text: |- | |
| az ad sp credential reset --id 00000000-0000-0000-0000-000000000000 --cert "@~/cert.pem" --append | |
| `cert.pem` contains the following content | |
| -----BEGIN CERTIFICATE----- <<< this line is optional | |
| MIICoT... | |
| -----END CERTIFICATE----- <<< this line is optional |
| - 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 |
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.
The official name should be "Azure Key Vault", not "KeyVault": https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-cli
| 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 " |
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.
Changed according to #30091.
|
|
||
| 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) |
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.
This hint is removed to avoid users' potential incorrect handling of the log.
az ad sp create-for-rbac: Add examples for using --certaz ad sp create-for-rbac: Update examples and warnings
| 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. |
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.
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
american:
- Boston Red Sox
- Detroit Tigers
- New York Yankees
national:
- New York Mets
- Chicago Cubs
- Atlanta BravesThere 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.
In YAML block styles, structure is determined by indentation. In general, indentation is defined as a zero or more space characters at the start of a line. -- https://yaml.org/spec/1.2-old/spec.html#id2777534
PS: The indentation at https://yaml.org/ is inconsistent.


Related command
az ad sp create-for-rbacDescription
--certto clarify Article for service creation principal has misleading guidance for --cert MicrosoftDocs/azure-docs-cli#4734--create-certaccording to [Profile]az login: Add--certificatefor authenticating with service principal certificate #30091Testing Guide
az ad sp create-for-rbac -h