Skip to content
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

[QUERY] How to use Azure authentication against a keyvault, and get the token. #38388

Closed
nschuessler opened this issue Aug 28, 2023 · 11 comments
Closed
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@nschuessler
Copy link

nschuessler commented Aug 28, 2023

Library name and version

Azure.Identity 1.10, Azure.Security.KeyVault.Secrets 4.5

Query/Question

I have a Visual Studio extension that uses the current IDE user's credentials to access a key vault to retrieve
a client id and client secret for a managed identity. The managed identity (client) is configured for RBAC (role based access control) to azure services and resources.

Because both Microsoft.Azure.KeyVault and Microsoft.Azure.Service.AppAuthentication are no longer actively supported, they will trigger security alerts and cause an interruption of our feature development.

1 Getting the secret from the vault:

This seems to be the code to access a key vault based on the identity of the user using the Visual Studio IDE.

       if (string.IsNullOrEmpty(this.TelemetryKey))
       {
           // https://msftplayground.com/2018/08/azure-managed-service-identity-and-local-development
           SecretClient secretClient = new SecretClient(new Uri(vaultBaseUrl), new DefaultAzureCredential());
           global::Azure.Response<KeyVaultSecret> secret = null;

          // Query the secret here.

The problem is that in the latest version of Visual Studio17.7.2, I get MissingMethodException for the SecretClient constructor.
It seems Visual Studio is using 4.4 of the secrets library, but downgrading to 4.4 for my extension doesn't seem to help. Debugging extension loading issues in Visual Studio is quite troublesome.

2 Authenticating as a managed identity:

Given I have the client id and client secret, how do I access other resources as that managed identity?

This code used to work:

ClientCredential clientCred = new ClientCredential(this.keyVaultSettings.ClientId, this.keyVaultSettings.ClientSecret);
AuthenticationContext authContext = new AuthenticationContext(this.keyVaultSettings.AADInstance);
AuthenticationResult authResult = await authContext.AcquireTokenAsync(resourceId, clientCred);
string accessToken = authResult?.AccessToken;

It seems I need to use ManagedIdentityCredential like this:

var credential = new ManagedIdentityCredential(clientId: userAssignedClientId);
var client = new SecretClient(new Uri("https://myvault.vault.azure.net/"), credential);

Except, where does the client secret go now? I don't see a property for it.
How do you get the access token (for use in REST apis)?

3 As a bonus question, what will my app benefit from by all this work to get the same functionality by redesigning the auth around the new library? I had design it to keep track of (host uri, token) pairs and hand them out based on REST client request URIs.

Thanks

Environment

IDE is version 17.7.2.
I'm on windows 11.
Roslyn 4.6/4.7 is in the mix.

Runtime version for the VSIX is 4.7.2/4.8.
Libraries written in .Net Standard 2.0.

PS C:\Repos\cpr3\src\DevTools\CodeFlowService> dotnet --info
.NET SDK:
Version: 7.0.400
Commit: 73bf45718d

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621 <== This is actually windows 11 I'm running on ...
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.400\

Host:
Version: 7.0.10
Architecture: x64
Commit: a6dbb800a4

.NET SDKs installed:
6.0.316 [C:\Program Files\dotnet\sdk]
7.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.10 [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:
Not found

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

Download .NET:

@github-actions github-actions bot added Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-triage Workflow: This issue needs the team to triage. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Aug 28, 2023
@jsquire jsquire added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-team-triage Workflow: This issue needs the team to triage. labels Aug 29, 2023
@jsquire
Copy link
Member

jsquire commented Aug 29, 2023

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@christothes
Copy link
Member

Hi @nschuessler

Regarding question 1 - I'm not sure why you'd be getting the exception. Could you provide the actual exception and stack trace?

Regarding question 2 - If you are using a client Id and client secret, it sounds like you need the ClientSecretCredential. Managed identities do not utilize a client Id unless it is to specify which user assigned identity to select. I'm not aware of a scenario in which system assigned nor user assigned managed identities utilize a client secret.

Regarding question 3 - the functionality would be nearly the same if you are planning to just migrate your existing code, although the newer libraries are in active development and adhere to our latest design guidelines. Here is an overview of what is new about these latest version of Azure SDKs

@christothes christothes added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Aug 29, 2023
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Aug 29, 2023
@github-actions
Copy link

Hi @nschuessler. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@nschuessler
Copy link
Author

nschuessler commented Aug 30, 2023

Thanks for the answers.

For issue 2:
The exception/message is:
System.MissingMethodException: 'Method not found: 'Void Azure.Security.KeyVault.Secrets.SecretClient..ctor(System.Uri, Azure.Core.TokenCredential)

which is wrapped in a Visual Studio CompositionFailedException.

So my code to use SecretClient is the following:

               // Code inside InitializeSecretsAsync
                SecretClient secretClient = new SecretClient(new Uri(vaultBaseUrl), new DefaultAzureCredential());
                global::Azure.Response<KeyVaultSecret> secret = null;

I thought at first, since the code that uses SecretClient is used in a library targeting .Net standard, and the extension must target .Net 4.8, that a multi targeted Keyvault.Secrets binary may be the cause (i.e. linking against .Net standard, and shipping the .Net 4.8 binary). But changing build targets doesn't fix the problem, and it seems Keyvault.Secrets only has the .Net standard binary version and is not multi-targeted.

The other possible problem is that visual studio Snapshot Debugger uses KeyVault.Secrets version 4.4 not the latest 4.5, so there may be a conflict with multiple versions loaded, but backing down the version in my extension to 4.4 also does not fix the problem.

Possibly using Fuselog viewer may help but otherwise I'm out of ideas on what to try.

Here is the call stack:

 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<System.__Canon>(ref System.__Canon stateMachine) Line 316	C#	Symbols loaded.
>	Microsoft.CPR.VisualStudio.Settings.dll!Microsoft.CPR.VisualStudio.Extension.Settings.KeyVaultSettings.InitializeSecretsAsync(System.Threading.CancellationToken cancellationToken) Line 74	Unknown	Symbols loaded.
 	Microsoft.CPR.VisualStudio.Settings.dll!Microsoft.CPR.VisualStudio.Extension.Settings.KeyVaultSettings.InitializeAsync(System.Threading.CancellationToken cancellationToken) Line 61	C#	Symbols loaded.
 	Microsoft.CPR.VisualStudio.Extension2022.dll!Microsoft.CPR.VisualStudio.Extension.Remoting.CostCallbackListener.CostCallbackListener(Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace workspace, Microsoft.CPR.VisualStudio.Extension.Settings.IKeyVaultSettings settings, Microsoft.CPR.VisualStudio.Extension.IVsixExtension vsixExtension, Microsoft.CPR.VisualStudio.Extension.Settings.IVisualStudioVersion visualStudioVersion, Microsoft.CPR.VisualStudio.Extension.IUserSettings userSettings, Microsoft.CPR.VisualStudio.Extension.ITrendPeekService peekService) Line 124	C#	Symbols loaded.
 	[Native to Managed Transition]		Annotated Frame
 	[Managed to Native Transition]		Annotated Frame
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.ReflectionHelpers.Instantiate(System.Reflection.MethodBase ctorOrFactoryMethod, object[] arguments) Line 696	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue() Line 561	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create() Line 1361	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleState nextState) Line 1463	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleState requiredState) Line 1545	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose() Line 1212	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.ConstructExportedValue(Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport import, Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeExport export, Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker importingPartTracker, Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker partLifecycle, Microsoft.VisualStudio.Composition.ReportFaultCallback faultCallback) Line 369	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetExportedValue.AnonymousMethod__1() Line 303	C#	Symbols loaded.
 	Microsoft.VisualStudio.Composition.dll!Microsoft.VisualStudio.Composition.DelegateServices.As.AnonymousMethod__0() Line 65	C#	Symbols loaded.
 	mscorlib.dll!System.Lazy<Microsoft.VisualStudio.Language.CodeLens.ICodeLensCallbackListener>.CreateValue() Line 437	C#	Symbols loaded.
 	mscorlib.dll!System.Lazy<Microsoft.VisualStudio.Language.CodeLens.ICodeLensCallbackListener>.LazyInitValue() Line 388	C#	Symbols loaded.
 	Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension<System.__Canon, System.__Canon>(object errorSource, System.Lazy<System.__Canon, System.__Canon> provider)	Unknown	No symbols loaded.
 	Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.CodeLens.Proxy.CodeLensHubClient..ctor.AnonymousMethod__1()	Unknown	No symbols loaded.
 	[Resuming Async Method]		Annotated Frame
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.IO.Stream>.SetResult(System.IO.Stream result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.ServiceHub.Client.dll!Microsoft.ServiceHub.Client.HubClient.RequestServiceAsync(Microsoft.ServiceHub.Client.ServiceDescriptor serviceDescriptor, System.Threading.CancellationToken cancellationToken)	Unknown	Non-user code. Cannot find or open the PDB file.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.IO.Pipelines.IDuplexPipe>.SetResult(System.IO.Pipelines.IDuplexPipe result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.ServiceHub.Client.dll!Microsoft.ServiceHub.Client.HubClient.GetPipeAsync(Microsoft.ServiceHub.Framework.ServiceMoniker serviceMoniker, Microsoft.ServiceHub.Framework.ServiceActivationOptions options, System.Threading.CancellationToken cancellationToken)	Unknown	Non-user code. Cannot find or open the PDB file.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Framework.RemoteServiceBroker>.SetResult(Microsoft.ServiceHub.Framework.RemoteServiceBroker result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.ThreadingTools.WithCancellationSlow<Microsoft.ServiceHub.Framework.RemoteServiceBroker>(System.Threading.Tasks.Task<Microsoft.ServiceHub.Framework.RemoteServiceBroker> task, System.Threading.CancellationToken cancellationToken) Line 283	C#	Non-user code. Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.TaskFactory.CompleteOnInvokePromise.Invoke(System.Threading.Tasks.Task completingTask) Line 2457	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3627	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Framework.RemoteServiceBroker>.SetResult(Microsoft.ServiceHub.Framework.RemoteServiceBroker result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.AsyncLazy<Microsoft.ServiceHub.Framework.RemoteServiceBroker>.GetValueAsync.AnonymousMethod__0() Line 157	C#	Non-user code. Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.Execute() Line 2498	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) Line 2827	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) Line 2767	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued) Line 92	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued) Line 219	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.TaskContinuation.InlineIfPossibleOrElseQueue(System.Threading.Tasks.Task task, bool needsProtection) Line 263	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3642	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Framework.RemoteServiceBroker>.SetResult(Microsoft.ServiceHub.Framework.RemoteServiceBroker result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.ServiceHub.Client.dll!Microsoft.ServiceHub.Client.HubClient.Reset.AnonymousMethod__58_0()	Unknown	Non-user code. Cannot find or open the PDB file.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Framework.IRemoteServiceBroker>.SetResult(Microsoft.ServiceHub.Framework.IRemoteServiceBroker result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.ServiceHub.Client.dll!Microsoft.ServiceHub.Client.HubClient.GetThisAsRemoteServiceBrokerAsync()	Unknown	Non-user code. Cannot find or open the PDB file.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Client.LocationServiceProxy>.SetResult(Microsoft.ServiceHub.Client.LocationServiceProxy result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.ServiceHub.Client.dll!Microsoft.ServiceHub.Utility.Shared.ServiceHubRetry.ExecuteAsync<Microsoft.ServiceHub.Client.LocationServiceProxy>(System.Func<System.Threading.Tasks.Task<Microsoft.ServiceHub.Client.LocationServiceProxy>> actionToExecute, System.Diagnostics.TraceSource logger, Microsoft.ServiceHub.Utility.Shared.ServiceHubRetryConfiguration<Microsoft.ServiceHub.Client.LocationServiceProxy> serviceHubRetryConfiguration, System.Threading.CancellationToken cancellationToken)	Unknown	Non-user code. Cannot find or open the PDB file.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Client.LocationServiceProxy>.SetResult(Microsoft.ServiceHub.Client.LocationServiceProxy result) Line 603	C#	Symbols loaded.
 	[Completed] Microsoft.ServiceHub.Client.dll!Microsoft.ServiceHub.Client.HubClient.GetLocationServiceAsync()	Unknown	Non-user code. Cannot find or open the PDB file.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.ServiceHub.Client.ClientConfiguration>.SetResult(Microsoft.ServiceHub.Client.ClientConfiguration result) Line 603	C#	Symbols loaded.
 	[Completed] StreamJsonRpc.dll!StreamJsonRpc.JsonRpc.InvokeCoreAsync<Microsoft.ServiceHub.Client.ClientConfiguration>(StreamJsonRpc.RequestId id, string targetName, System.Collections.Generic.IReadOnlyList<object> arguments, System.Collections.Generic.IReadOnlyList<System.Type> positionalArgumentDeclaredTypes, System.Collections.Generic.IReadOnlyDictionary<string, System.Type> namedArgumentDeclaredTypes, System.Threading.CancellationToken cancellationToken, bool isParameterObject) Line 1574	C#	Non-user code. Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<StreamJsonRpc.Protocol.JsonRpcMessage>.SetResult(StreamJsonRpc.Protocol.JsonRpcMessage result) Line 603	C#	Symbols loaded.
 	[Completed] StreamJsonRpc.dll!StreamJsonRpc.JsonRpc.InvokeCoreAsync(StreamJsonRpc.Protocol.JsonRpcRequest request, System.Type expectedResultType, System.Threading.CancellationToken cancellationToken) Line 1975	C#	Non-user code. Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Line 288	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Line 810	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Line 3617	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result) Line 490	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.TaskCompletionSource<System.__Canon>.TrySetResult(System.__Canon result) Line 298	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.Tasks.TaskCompletionSource<System.__Canon>.SetResult(System.__Canon result) Line 321	C#	Symbols loaded.
 	StreamJsonRpc.dll!StreamJsonRpc.JsonRpc.InvokeCoreAsync.AnonymousMethod__0(StreamJsonRpc.Protocol.JsonRpcMessage response) Line 1907	C#	Symbols loaded.
 	StreamJsonRpc.dll!StreamJsonRpc.JsonRpc.HandleRpcAsync(StreamJsonRpc.Protocol.JsonRpcMessage rpc) Line 2621	C#	Symbols loaded.
 	[Resuming Async Method]		Annotated Frame
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Line 1070	C#	Symbols loaded.
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0() Line 977	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() Line 1252	C#	Symbols loaded.
 	mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Line 820	C#	Symbols loaded.
 	[Async Call Stack]		Annotated Frame
 	[Async] Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPointAsync<bool>(object errorSource, System.Func<System.Threading.Tasks.Task<bool>> asyncCall, bool valueOnThrow)	Unknown	No symbols loaded.
 	[Async] Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.CodeLens.Proxy.CodeLensHubClient..ctor.__valueFactory|13_0()	Unknown	No symbols loaded.
 	[Async] Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.AwaitExtensions.ExecuteContinuationSynchronouslyAwaiter<bool>.OnCompleted.AnonymousMethod__5_0(System.Threading.Tasks.Task<bool> _, object s) Line 777	C#	Symbols loaded.
 	[Async] Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.AsyncLazy<bool>.GetValueAsync.AnonymousMethod__0() Line 150	C#	Symbols loaded.
 	[Async] [Awaited by multiple tasks/threads]		Annotated Frame

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Aug 30, 2023
@nschuessler
Copy link
Author

Update: So I think I understand the nature of the problem.
Microsoft.Azure.Keyvault is already part of VS IDE installation where as "Azure.Security.KeyVault.Secrets" is not (or at least is installed differently), so as an indirect reference, it has to be explicitly included in the top level project file as a reference. This fixes the above stack (for an out of proc extension)

But the in proc portion is not fixed by this. Even with explicit inclusion in the manifest. I'll keep fiddling with it.

@heaths
Copy link
Member

heaths commented Aug 30, 2023

For issue 2:
The exception/message is:
System.MissingMethodException: 'Method not found: 'Void Azure.Security.KeyVault.Secrets.SecretClient..ctor(System.Uri, Azure.Core.TokenCredential)

@nschuessler you likely need to update to the latest Azure.Identity. We intentionally don't have a hard dependency on Azure.Identity because it brings in MSAL.NET (a large dependency), which is often not needed for many apps. At some point about a year ago, a change was made that has an implicit dependency on Azure.Identity changes (and Azure.Core changes, but that is a hard dependency).

@christothes christothes added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Nov 7, 2023
Copy link

github-actions bot commented Nov 7, 2023

Hi @nschuessler. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Nov 7, 2023
Copy link

Hi @nschuessler, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label Nov 15, 2023
@nschuessler
Copy link
Author

nschuessler commented Nov 15, 2023

So the issues I was having are basically related to how Visual Studio IDE imports / consumes Azure.Identity in it's devenv.exe.config. For most packages, extensions cannot use versions that are newer that those used by the Visual Studio IDE version it is installed in because there is a version mapping in the .config file. There is also some ngen happening in Visual Studio that complicates matters. I was in a situation where I needed a version newer than what IDE had, but couldn't use it because there were changes where the version mapping / ngen caused loading issues.

The only solution is to wait for the IDE to ship with a newer version of Azure.Identity / Azure SDK so extensions can use it. The problem was that it was a few versions old.

If you can do anything to keep the IDE version of Azure SDK as up to date as possible it would be helpful, otherwise if that is not something Azure SDK team does, then there is no investigation here and you can close the issue.

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. labels Nov 15, 2023
@heaths
Copy link
Member

heaths commented Nov 15, 2023

@nschuessler thanks for the update. We'll work with our partners to try to keep those bits updated, but it will also depend on which release channel you're on for Visual Studio. The "Release" channel won't be updated nearly as often. In that case, I'd recommend taking as old of a dependency as you can (and baring any security issues that may have been fixed) to avoid this with your extension.

@christothes @schaabs I recommend we keep this open as a tracking issue at least until we can find the appropriate owners and get an internal issue filed.

@christothes
Copy link
Member

VS is at the latest version of Azure.Identity now

@github-actions github-actions bot locked and limited conversation to collaborators Jul 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Development

No branches or pull requests

4 participants