Skip to content

Federated Credentials for GitHub fails with CLi 2.42 #25291

@ezYakaEagle442

Description

@ezYakaEagle442

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Related command

export CREDENTIAL_NAME="gha_aca_run"
export GH_USER_NAME="yourGitHubAccount"
export SUBJECT="repo:$GH_USER_NAME/aca-java-petclinic-mic-srv:ref:refs/heads/main" # "repo:organization/repository:environment:Production"
export DESCRIPTION="GitHub Action Runner for Petclinic ACA demo"

echo $SPN_OBJECT_ID # to check its value

az rest --method POST --uri 'https://graph.microsoft.com/beta/applications/$SPN_OBJECT_ID/federatedIdentityCredentials' --body '{"name":"$CREDENTIAL_NAME","issuer":"https://token.actions.githubusercontent.com","subject":"$SUBJECT","description":"$DESCRIPTION","audiences":["api://AzureADTokenExchange"]}'
Bad Request({"error":{"code":"BadRequest","message":"The request URI is not valid. Since the segment 'applications' refers to a collection, this must be the last segment in the req
uest URI or it must be followed by an function or action that can be bound to it otherwise all intermediate segments must refer to a single resource.","innerError":{"date":"2023-01
-30T17:36:25","request-id":"13ced77d-517c-4416-81ab-d90a59f816ea","client-request-id":"13ced77d-517c-4416-81ab-d90a59f816ea"}}})

Describe the bug

To Reproduce

export CREDENTIAL_NAME="gha_aca_run"
export GH_USER_NAME="yourGitHubAccount"
export SUBJECT="repo:$GH_USER_NAME/aca-java-petclinic-mic-srv:ref:refs/heads/main" # "repo:organization/repository:environment:Production"
export DESCRIPTION="GitHub Action Runner for Petclinic ACA demo"

az rest --method POST --uri 'https://graph.microsoft.com/beta/applications/$SPN_OBJECT_ID/federatedIdentityCredentials' --body '{"name":"$CREDENTIAL_NAME","issuer":"https://token.actions.githubusercontent.com","subject":"$SUBJECT","description":"$DESCRIPTION","audiences":["api://AzureADTokenExchange"]}'

Expected behavior
Based on the docs CLI should work

Environment summary
From VS Code / WSL :

az version
{
  "azure-cli": "2.42.0",
  "azure-cli-core": "2.42.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {}
}

Additional context

I could sucessfully create Federated Credentials from the Portal using the same values.
Note: I use an MS FTE Tenant (named AppInnoLabs) with external subscription

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botGraphaz adService AttentionThis issue is responsible by Azure service team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions