Azure / Azure/azure-cli

`az ad sp create-for-rbac` should support finer grain of credential expiry time

Open
#28,521 3 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
act-identity-squad Auto-Assign Azure CLI Team Graph potential-pruning question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**
`az ad sp create-for-rbac`

**Is your feature request related to a problem? Please describe.**
Currently, only integer `--years` is supported which is too rough:

```
> az ad sp create-for-rbac -h
...
Credential Arguments
--years : Number of years for which the credentials will be valid.
Default: 1 year.
```

The minimum expiry time is 1 year which is against the security best practice of setting expiry time as short as possible.

> [!CAUTION]
> **If there is a policy in the tenant that forbids expiry time >= 1 year, `az ad sp create-for-rbac` will fail.**

**Describe the solution you'd like**

1. Support `--end-date` similar to that from `az ad app credential reset` and `az ad app create`.
2. Support `--days` like Azure Portal: ![image](https://github.com/Azure/azure-cli/assets/4003950/deaf26f1-fdee-41d3-bd5e-f2ba05c11e78)

**Describe alternatives you've considered**
Drop `--year` as it encourages imprecise expiry time and it also causes ambiguity in leap years (https://github.com/Azure/azure-cli/issues/28520).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.