Error: Managed Identity: DefaultAzureCredential authentication failed
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- azure, github-actions, sql
- Domain
- authentication, ci-cd, cloud, databases
Research direction
Read the workflow YAML and the azure/sql-action@v2.3 invocation, then reproduce the shown sqlcmd command with the ActiveDirectoryDefault authentication path. Done means the GitHub Actions job authenticates through the configured federated Managed Identity and executes ./.github/sql/users.sql without the DefaultAzureCredential error.
Written by the indexing model from the issue text.
Description
Hello,
I'm encountering an issue when trying to use a Managed Identity with a Federated Credential in GitHub Actions to run azure/sql-action@v2.3. The Managed Identity has been configured with a Federated Credential for GitHub (environment).
I added my Managed Identity to the database as db_owner, with the following query:
DROP USER IF EXISTS [ManagedIdentity-Dev];
CREATE USER [ManagedIdentity-Dev] FROM EXTERNAL PROVIDER WITH DEFAULT_SCHEMA=[dbo];
ALTER ROLE db_owner ADD MEMBER [ManagedIdentity-Dev];
Here is my GitHub Actions workflow (.yml file):
create-sql-users:
runs-on:
group: github-runner-Dev
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@main
- uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }} # The Managed Identity with Federated Credential
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- uses: azure/sql-action@v2.3
with:
connection-string: ${{ secrets.AZURE_SQL_CONNECTION_STRING }}
path: './.github/sql/users.sql'
skip-firewall-check: true
Issue:
When the workflow runs, I receive the following error message:
sqlcmd -S mydatabase-dev.database.windows.net,1433 -d mydatabase-dev --authentication-method=ActiveDirectoryDefault -i ./.github/sql/users.sql
DefaultAzureCredential authentication failed
GET http://localhost:42356/msi/token
--------------------------------------------------------------------------------
RESPONSE 400 Bad Request
--------------------------------------------------------------------------------
{
"statusCode": 400,
"message": "No User Assigned or Delegated Managed Identity found for specified ClientId/ResourceId/PrincipalId.",
"correlationId": "86d82795-065e-4a71-a11c-12a10e7879d0"
}
Am I missing something?
- Dominant language
- TypeScript
- Stars
- 142
- Forks
- 73
- Avg merge
- 9d 18h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/sql-action
-
need-to-triage
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Azure/sql-action#247 ·
-
need-to-triage
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Azure/sql-action#282 ·
-
bug
Azure/sql-action#267 · 1 assignee ·
-
need-to-triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Azure/sql-action#262 · 1 comment ·
-
need-to-triage
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Azure/sql-action#261 ·
All issues in Azure/sql-action
Similar issues
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100