Skip to content
16 changes: 15 additions & 1 deletion src/azure-cli/azure/cli/command_modules/role/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
helps['ad app credential reset'] = """
type: command
short-summary: Append or overwrite an application's password or certificate credentials
long-summary: >-
The output includes credentials that you must protect. Be sure that you do not include these credentials
in your code or check the credentials into your source control. As an alternative, consider using
[managed identities](https://aka.ms/azadsp-managed-identities) if available to avoid the need to use credentials.
examples:
- 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
Expand Down Expand Up @@ -370,6 +374,10 @@
helps['ad sp create-for-rbac'] = """
type: command
short-summary: Create a service principal and configure its access to Azure resources.
long-summary: >-
The output includes credentials that you must protect. Be sure that you do not include these credentials
in your code or check the credentials into your source control. As an alternative, consider using
[managed identities](https://aka.ms/azadsp-managed-identities) if available to avoid the need to use credentials.
parameters:
- name: --name -n
short-summary: A URI to use as the logic name. It doesn't need to exist. If not present, CLI will generate one.
Expand Down Expand Up @@ -441,7 +449,13 @@
helps['ad sp credential reset'] = """
type: command
short-summary: Reset a service principal credential.
long-summary: Use upon expiration of the service principal's credentials, or in the event that login credentials are lost.
long-summary: >-
Use upon expiration of the service principal's credentials, or in the event that login credentials are lost.


The output includes credentials that you must protect. Be sure that you do not include these credentials
in your code or check the credentials into your source control. As an alternative, consider using
[managed identities](https://aka.ms/azadsp-managed-identities) if available to avoid the need to use credentials.
parameters:
- name: --name -n
short-summary: Name or app ID of the service principal.
Expand Down
8 changes: 8 additions & 0 deletions src/azure-cli/azure/cli/command_modules/role/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
from ._client_factory import _auth_client_factory, _graph_client_factory
from ._multi_api_adaptor import MultiAPIAdaptor

CREDENTIAL_WARNING_MESSAGE = (
"The output includes credentials that you must protect. Be sure that you do not include these credentials in "
"your code or check the credentials into your source control. For more information, see https://aka.ms/azadsp-cli")

logger = get_logger(__name__)

# pylint: disable=too-many-lines
Expand Down Expand Up @@ -1523,6 +1527,8 @@ def create_service_principal_for_rbac(
"Please copy %s to a safe place. When you run 'az login', provide the file path in the --password argument",
cert_file)
result['fileWithCertAndPrivateKey'] = cert_file

logger.warning(CREDENTIAL_WARNING_MESSAGE)
return result


Expand Down Expand Up @@ -1771,6 +1777,8 @@ def reset_service_principal_credential(cmd, name, password=None, create_cert=Fal
}
if cert_file:
result['fileWithCertAndPrivateKey'] = cert_file

logger.warning(CREDENTIAL_WARNING_MESSAGE)
return result


Expand Down