Skip to content

Detect system-assigned managed identities in AzureCredentialHelper#15885

Merged
eerhardt merged 1 commit intomicrosoft:mainfrom
DavidZidar:fix-system-assigned-credential-support
Apr 13, 2026
Merged

Detect system-assigned managed identities in AzureCredentialHelper#15885
eerhardt merged 1 commit intomicrosoft:mainfrom
DavidZidar:fix-system-assigned-credential-support

Conversation

@DavidZidar
Copy link
Copy Markdown
Contributor

Description

This should restore support for system-assigned managed identities.

When system-assigned managed identities are enabled the IDENTITY_ENDPOINT and IDENTITY_HEADER environment variables are defined. It should be enough to detect the endpoint variable for this purpose.

AZURE_CLIENT_ID is still used by user-managed identities.

Reference:
https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Chttp#rest-endpoint-reference

Fixes #15879

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings April 4, 2026 00:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15885

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15885"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores managed-identity support in AzureCredentialHelper for Azure App Service deployments by detecting system-assigned managed identity signals and selecting a managed-identity credential path instead of falling back to development credentials.

Changes:

  • Detects IDENTITY_ENDPOINT (in addition to AZURE_CLIENT_ID) to decide when to use ManagedIdentityCredential.
  • Adds an inline comment clarifying why IDENTITY_ENDPOINT is checked.

Comment thread src/Shared/AzureCredentialHelper.cs Outdated
Comment thread src/Shared/AzureCredentialHelper.cs Outdated
@DavidZidar DavidZidar force-pushed the fix-system-assigned-credential-support branch from 60f26ad to 05cce1c Compare April 4, 2026 11:35
@DavidZidar
Copy link
Copy Markdown
Contributor Author

Copilot pointed out that the code doesn't seem to be working for user-assigned managed identities either so I made the suggested adjustments (with some minor tweaks) to account for this too.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@radical
Copy link
Copy Markdown
Member

radical commented Apr 7, 2026

@eerhardt

Copy link
Copy Markdown
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt Please take a look before merge.

Comment thread src/Shared/AzureCredentialHelper.cs Outdated
Comment thread src/Shared/AzureCredentialHelper.cs Outdated
…Helper

When system-assigned managed identities are enabled the
IDENTITY_ENDPOINT and IDENTITY_HEADER environment variables are defined.
It should be enough to detect the endpoint variable for this purpose.

AZURE_CLIENT_ID is still used by user-managed identities.

Reference:
https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Chttp#rest-endpoint-reference
@DavidZidar DavidZidar force-pushed the fix-system-assigned-credential-support branch from 05cce1c to 7918d6b Compare April 8, 2026 19:24
Copy link
Copy Markdown
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@christothes - let me know if you think we shouldn't do this.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

  • Tests / Build packages / Build packages - Failed step 'Build with packages' will be retried because the job log shows a likely transient infrastructure network failure. Matched pattern: /Unable to load the service index for source https:\/\/(?:pkgs\.dev\.azure\.com\/dnceng|dnceng\.pkgs\.visualstudio\.com)\/public\/_packaging\//i.

@eerhardt eerhardt merged commit 48298a4 into microsoft:main Apr 13, 2026
462 of 466 checks passed
@joperezr joperezr added this to the 13.3 milestone Apr 14, 2026
radical pushed a commit that referenced this pull request Apr 14, 2026
…Helper (#15885)

When system-assigned managed identities are enabled the
IDENTITY_ENDPOINT and IDENTITY_HEADER environment variables are defined.
It should be enough to detect the endpoint variable for this purpose.

AZURE_CLIENT_ID is still used by user-managed identities.

Reference:
https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Chttp#rest-endpoint-reference
@DavidZidar DavidZidar deleted the fix-system-assigned-credential-support branch April 19, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AzureCredentialHelper does not work with system-assigned managed identities in Azure

8 participants