Skip to content

[BUG]: Brokered Credential not used under AOT #49398

Open
@afscrome

Description

@afscrome

Library name and version

Azure.Identity 1.14.0-beta.3 / Azure.Identity.Broker 1.3.0-beta.2

Describe the bug

When I run muy app through dotnet run, I can see that DefaultAzureCredential tries to authenticate through the broker

  • InteractiveBrowserCredential authentication failed:

However when I run my app through dotnet publish, I don't see that attempt.

My App has <PublishAot>true</PublishAot>. TryCreateDevelopmentBrokerOptions tries to use reflection to initialize the broker, which is presumably why it doesnt work under AOT -

internal static bool TryCreateDevelopmentBrokerOptions(out InteractiveBrowserCredentialOptions options)

Expected behavior

DefaultAzureCredential should include brokered credentials on both AOT and non AOT apps, or documentation should be provided on how to configure brokered credentials to work manually on AOT apps.

Ideally this could be done before the 1.14 release, but if not the docs & release notes should be updated to highlight that the Broker is ignored under AOT.

Actual behavior

Despite seeing evidence that the brokered credentials are used via dotnet run, no such evidence can be found after running the app after dotnet publish .

Reproduction Steps

  1. Ensure your csproj is configured to PublishAot
<PublishAot>true</PublishAot>
  1. dotnet run your app, verify that an attempt is made to the Broker credentials

  2. dotnet publish your app, and fail to see an attempt being made with brokered credentials.

using var forwarder = new AzureEventSourceLogForwarder(loggerFactory);
//forwarder.Start();
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions()
{
    // Managed Identity Credentials are slow, and not typically used in docker scenarios
    ExcludeManagedIdentityCredential = true,
});
var token = await credential.GetTokenAsync(new(scopes: ["https://management.azure.com/.default"]));

Environment

dotnet:

.NET SDK:
 Version:           9.0.201
 Commit:            071aaccdc2
 Workload version:  9.0.200-manifests.a3a1a094
 MSBuild version:   17.13.13+1c2026462

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.201\

.NET workloads installed:
 [aspire]
   Installation Source: VS 17.13.35919.96
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.3
  Architecture: x64
  Commit:       831d23e561

.NET SDKs installed:
  6.0.428 [C:\Program Files\dotnet\sdk]
  8.0.408 [C:\Program Files\dotnet\sdk]
  9.0.100 [C:\Program Files\dotnet\sdk]
  9.0.200 [C:\Program Files\dotnet\sdk]
  9.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  S:\REDACTED\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Visual Studio:

Microsoft Visual Studio Enterprise 2022
Version 17.13.5
VisualStudio.17.Release/17.13.5+35919.96
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Enterprise

Visual C++ 2022   00476-80000-00000-AA768
Microsoft Visual C++ 2022

ASP.NET and Web Tools   17.13.124.35287
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.13.124.35287
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.13.124.35287
Azure Functions and Web Jobs Tools

C# Tools   4.13.0-3.25167.3+73eff2b5de2ad38ec602c0a9e82f9125fb85992b
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub Copilot   17.13.441.19478
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

Microsoft Azure Tools for Visual Studio   2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Node.js Tools   1.5.61125.7 Commit Hash:d387982a7546304d617ed77b6d390e04b6558274
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager   6.13.2
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Office Developer Tools for Visual Studio   17.10.35513.00
Microsoft Office Developer Tools for Visual Studio

Razor (ASP.NET Core)   17.13.3.2512306+41f62d0b8021cafc33bdefdb7e0198c8d2eb59ac
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.13.3.1
Microsoft SQL Server Data Tools

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools   17.0.31211.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.13.0-3.25167.3+73eff2b5de2ad38ec602c0a9e82f9125fb85992b
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.13.0-beta.25154.2+82a3f54f7140a62e6398403451098c4517747c02
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions