azure-sdk-for-net: [BUG] Cannot connect to KeyVault on Mac OS X

Describe the bug I’m running a .NET Framework project on Mac under mono and trying to use KeyVault but cannot get get access token due to Windows CLI command is used instead of Bash command. According to the output, “cmd.exe” is used, although the source for tag “1.2.0” indicates the Bash command should be used is OS is not Windows.

Exception or Stack Trace

[ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException: Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/05392f7e-58e6-4648-9ee2-95041f83c964. Exception Message: Tried the following 4 methods to get an access token, but none of them worked.
Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/05392f7e-58e6-4648-9ee2-95041f83c964. Exception Message: Tried to get token using Managed Service Identity. Unable to connect to the Managed Service Identity (MSI) endpoint. Please check that you are running on an Azure resource that has MSI setup.
Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/05392f7e-58e6-4648-9ee2-95041f83c964. Exception Message: Tried to get token using Visual Studio. Access token could not be acquired. Environment variable LOCALAPPDATA not set.
Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/05392f7e-58e6-4648-9ee2-95041f83c964. Exception Message: Tried to get token using Azure CLI. Access token could not be acquired. ApplicationName='cmd.exe', CommandLine='/c az account get-access-token -o json --resource https://vault.azure.net', CurrentDirectory='', Native error= Cannot find the specified file
Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/05392f7e-58e6-4648-9ee2-95041f83c964. Exception Message: Tried to get token using Active Directory Integrated Authentication. Access token could not be acquired. secur32.dll

To Reproduce Run a .NET Framework 4.6.1 project and try to connect to KeyVault on Mac OS X

Code Snippet Add the code snippet that causes the issue.

Expected behavior The expected behaviour would be that the AzureCliAccessTokenProvider would use the Bash command.

Setup (please complete the following information):

  • OS: Mac OS X (Output from Runtime OSDescription: Unix 18.6.0.0)
  • IDE : Jetbrains Rider
  • Microsoft.Azure.Services.AppAuthentication 1.2.0
  • Mono 5.18.1.3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 21 (6 by maintainers)

Most upvoted comments

I am having the same issue as @soydachi does (MacOS). Please help us!

The only solution for me now is to restart the laptop and try to wait for 2 minutes, then open Visual Studio 2019 and click run. It only works sometimes. So it cannot be a long time solution.