Hello, az cli does not support assigning an Azure RBAC role for a limited time. You can however:
- Use a script. Follows a simple sample using PowerShell:
az role assignment create # extra params
sleep -Seconds (60*60*2) # secs * mins * hours
az role assignment delete # extra params
- Use Privileged Identity Management. For licensing requirements take a look to Prerequisites. For how to, take a look to the steps detailed in Prepare PIM for Azure roles.
Let us know if you need additional assistance. If the answer was helpful, please accept it so that others can find a solution.