Skip to content

The default value for --end-date in az ad app create is misleading when using AsymmetricX509Cert #34233

Open

Description

Describe the bug

When creting an app registration with an AsymmetricX509Cert as a credential, the default value for --end-date is Now+1 year even if the certificate has a greater expiration (e.g. 5 years). Even if the documentation states this clearly and correctly, the behavior is definetely different from the Azure Portal UI where there is no chance at all to choose a different keyCredential endDateTime when uploading a certificate.

Shouldn't the default behaviour when using certificates as credentials be to pick the certificate NotAfter as the keyCredential endDate?

Related command

az ad app create

Errors

The command doesn't fail, but the keyCredential created has a different endDate than the certificate used as a credential which sounds counterintuitive and misaligned with default Azure Portal UX.

Issue script & Debug output

N/A

Expected behavior

The keyCredential created, by default, should have an endDate equal to the certificate's NotAfter

Environment Summary

azure-cli 2.91.0

Additional context

No response

Activity

  1. added
    bugThis issue requires a change to an existing behavior in the product in order to be resolved.
    on Oct 16, 2026
  2. yonzhan commented on Oct 16, 2026

    @yonzhan
    Collaborator

    Thank you for opening this issue, we will look into it.

  3. added
    Azure CLI TeamThe command of the issue is owned by Azure CLI team
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    on Oct 16, 2026
  4. removed
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    on Oct 16, 2026
  5. added this to the Backlog milestone on Oct 16, 2026
  6. microsoft-github-policy-service commented on Oct 19, 2026

    @microsoft-github-policy-service
    Contributor

    🔔 Routing this issue to @Azure/act-identity-squad.

  7. x-engineering-agent commented on Oct 19, 2026

    @x-engineering-agent
    Contributor

    The current az ad app create implementation passes --end-date into _build_key_credentials. When it is omitted, that builder uses the start date plus one year minus 24 hours for every key type, including AsymmetricX509Cert; it does not inspect the certificate's NotAfter value (create path, date default and credential body). The argument help documents the approximately one-year default. This explains the mismatch with the Portal rather than indicating an error in certificate parsing.

    For now, pass --end-date explicitly with your certificate's NotAfter timestamp (for example, in 2029-01-01T00:00:00+00:00 format) when supplying --key-value; the CLI will use that date for the key credential. Changing the default for certificate credentials would change existing CLI behavior, so the identity maintainers should decide whether and how to introduce that behavior rather than treating it as a safe automatic bug fix.

    Posted by x-engineering-agent (Fixer)

  8. x-engineering-agent commented on Oct 19, 2026

    @x-engineering-agent
    Contributor

    The current az ad app create behavior follows its documented default: --end-date defaults to one year after the current time. In the key-credential builder, an omitted end date is computed from the start date (roughly one year, minus 24 hours); the certificate's NotAfter is not read from --key-value.

    To make the key credential expire with your certificate today, pass its NotAfter explicitly using --end-date (for example, a UTC datetime with +00:00). Automatically deriving that date for certificates would change the documented default, so this is a request for the identity command maintainers to assess as an enhancement, rather than a regression fix.

    Posted by x-engineering-agent (Fixer)

  9. microsoft-github-policy-service commented on Oct 20, 2026

    @microsoft-github-policy-service
    Contributor

    🔔 Routing this issue to @Azure/act-identity-squad.

  10. x-engineering-agent commented on Oct 20, 2026

    @x-engineering-agent
    Contributor

    The current behavior matches the documented default, but I agree the difference from a certificate's validity period is worth considering. For az ad app create, the --end-date help says the default is one year after the current time. The credential builder sets the key credential's endDateTime from --end-date, or to approximately one year from its start if omitted; it does not derive the date from the certificate. This is a request to change the default, not evidence of a failing command.

    To align a credential with a certificate today, pass its NotAfter date explicitly using --end-date (in UTC). I'll leave the proposed certificate-aware default with the identity maintainers to evaluate, including compatibility with existing scripts and the behavior for other key types. No automated fix is queued for a default change without that design decision.

    Posted by x-engineering-agent (Fixer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamGraph(doesn't work with label-triggered comments; use Graph.Microsoft instead) az adact-identity-squadfeature-requestneeds-author-feedbackMore information is needed from author to address the issue.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions