Skip to content

az aro create fails in Microsoft tenant: Credential lifetime exceeds the max value allowed as per assigned policy '538f1913-366a-440a-95a0-e195cb55b282' #28522

@jiasli

Description

@jiasli

Describe the bug

az aro create provides an empty dict {} as the body when calling application: addPassword REST API (#22549):

def add_password(self, obj_id):
cred = self.client.application_add_password(obj_id, {})
return cred["secretText"]

According to https://learn.microsoft.com/en-us/graph/api/application-addpassword,

endDateTime
The date and time at which the password expires represented using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z. Optional. The default value is "startDateTime + 2 years".

This triggers policy 538f1913-366a-440a-95a0-e195cb55b282 in Microsoft tenant 72f988bf-86f1-41af-91ab-2d7cd011db47 and causes an error.

Related command

az aro create

Errors

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: Credential lifetime exceeds the max value allowed as per assigned policy '538f1913-366a-440a-95a0-e195cb55b282'.
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/role/_msgrpah/_graph_client.py", line 52, in _send
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 1010, in send_raw_request
azure.cli.core.azclierror.HTTPError: Bad Request({"error":{"code":"CredentialInvalidLifetimeAsPerAppPolicy","message":"Credential lifetime exceeds the max value allowed as per assigned policy '538f1913-366a-440a-95a0-e195cb55b282'.","details":[{"code":"InvalidKeyEndDate","message":"Credential lifetime exceeds the max value allowed as per assigned policy '538f1913-366a-440a-95a0-e195cb55b282'.","target":"EndDate"}],"innerError":{"date":"2024-03-05T04:13:31","request-id":"d07b15e7-19ea-4d7c-b94f-d4926b208f04","client-request-id":"d07b15e7-19ea-4d7c-b94f-d4926b208f04"}}})

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/aro/custom.py", line 79, in aro_create
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/aro/_aad.py", line 27, in create_application
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/aro/_aad.py", line 56, in add_password
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/role/_msgrpah/_graph_client.py", line 131, in application_add_password
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/role/_msgrpah/_graph_client.py", line 55, in _send
azure.cli.command_modules.role._msgrpah._graph_client.GraphError: Credential lifetime exceeds the max value allowed as per assigned policy '538f1913-366a-440a-95a0-e195cb55b282'.

Issue script & Debug output

N/A

Expected behavior

The command should success.

Environment Summary

azure-cli                         2.58.0

core                              2.58.0
telemetry                          1.1.0

Dependencies:
msal                              1.26.0
azure-mgmt-resource             23.1.0b2

Python location 'D:\tool\azure-cli\python.exe'
Extensions directory 'C:\Users\jiasli\.azure\cliextensions'

Python (Windows) 3.11.7 (tags/v3.11.7:fa7a6f2, Dec  4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)]

Additional context

IcM 479021709

Metadata

Metadata

Assignees

No one assigned

    Labels

    AROaz aro (Azure Redhat OpenShift)Auto-AssignAuto assign by botService AttentionThis issue is responsible by Azure service team.act-codegen-extensibility-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions