Skip to content

Only use DefaultAzureCredential for local debug #10519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

japarson
Copy link
Contributor

@japarson japarson commented Jul 16, 2025

DefaultAzureCredential offers a balanced approach to retries, response wait times, and multiple authentication mechanisms. However, production workloads require resilience to latencies, robust retries, and deterministic behavior. Using DefaultAzureCredential() in Azure production services can lead to additional IcMs during managed identity service (IMDS) outages. During such outages, DefaultAzureCredential continues to probe additional credentials after ManagedIdentityCredential times out, including development-time credentials such as AzureCliCredential, AzureDeveloperCliCredential, and AzurePowerShellCredential. This behavior causes your service to be flagged by AzSecPack for suspicious activity.

We should avoid using DefaultAzureCredential in any context except for debug builds which can be used to more easily authenticate when developing locally.

Addresses https://github.com/NuGet/Engineering/issues/5869

joelverhagen
joelverhagen previously approved these changes Jul 16, 2025
@japarson japarson marked this pull request as ready for review July 17, 2025 06:02
@japarson japarson requested a review from a team as a code owner July 17, 2025 06:02
@@ -177,10 +177,14 @@ private static CloudBlobClientWrapper CreateCloudBlobClient(
{
if (string.IsNullOrWhiteSpace(msiConfiguration.ManagedIdentityClientId))
{
#if DEBUG
Copy link
Contributor

Choose a reason for hiding this comment

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

How hard would it be to use IAppConfiguration.Environment == ServicesConstants.DevelopmentEnvironment? The idea is to avoid use #if DEBUG. In all the new places

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.

3 participants