-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
DefaultAzureCredentials fails while working with ManagedIdentity in Visual Studio 2019 (.Net Core 3.1) #13228
Comments
@spmanjunath thanks for trying our preview and filing this issue. I'm investigating this now, and I'll update the issue once I have more information. One thing you might try as a work-around is disabling the var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ExcludeSharedTokenCacheCredential = true });
var blobServiceClient = new BlobServiceClient(accountUri, credential); |
Just to give an update on this issue. The underlying issue here is that MSA accounts which are authenticated via Visual Studio fail to authenticate with the For this reason we have decided to disable the |
I have the same issue with the secretclient. The workaround doesn't seem to work. When debugging in Visual Studio 2019.
.NET core 3.1 program.cs
The error message is starting with With the Microsoft.Azure.Services.AppAuthentication lib everything works fine using (while debugging in Visual Studio and when running as an Azure Web app with MI)
|
@jtourlamain Thanks for providing this example. Just to validate that you are failing with the VisualStudioCredential, could you try your scenario by using the VisualStudioCredential directly, rather than the DefaultAzureCredential? |
@christothes the VisualStudioCredential doesn't work. I used:
Maybe it has something to do with the fact that some of us have multiple accounts and those accounts have access to multiple tenants? What does work is:
|
@jtourlamain Thanks for providing these details. Does your scenario require only the one tenantId? If so you can also set the preferred tenant by setting the AZURE_TENANT_ID environment variable. This is equivalent to setting the azure-sdk-for-net/sdk/identity/Azure.Identity/src/DefaultAzureCredentialOptions.cs Line 42 in 72d4c47
In addition, you may want to update to the latest version of the Azure.Identity package. |
Hi, 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! |
Hi, 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! |
I believe I am having the exact same issue when accessing AppConfiguration. Here's the steps I've taken:
Trying the above would throw a 403 FORBIDDEN error both either DefaultAzureCredential and VisualStudioCredential with tenant id provided in code. Suspecting the multiple tenants for my account to be an issue, I tried another account which has access to only this tenant and I was successful. I then tried setting the environment variable AZURE_TENANT_ID with the desired tenant and was also successful. What appears to be broken is:
As I prefer using DefaultAzureCredential as it works both locally and under an App Service, I'm good with the AZURE_TENANT_ID solution, but using VisualStudioCredentialOptions to specify the tenant id should be resolved. |
Hi, 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! |
I'm able to reproduce the issue too. My account has access to multiple tenants. I'm using VS 2019 16.9.2 with an ASP.NET Core 5.0 Blazor Server app. Setting the .csproj file <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.0.2" />
<PackageReference Include="Azure.Identity" Version="1.3.0" />
</ItemGroup>
</Project> Program.cs public class Program
{
public static Task Main(string[] args) =>
CreateHostBuilder(args).Build().RunAsync();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((_, config) =>
{
var secretClient = new SecretClient(
new(Environment.GetEnvironmentVariable("VaultUri")),
new DefaultAzureCredential());
config.AddAzureKeyVault(secretClient, new KeyVaultSecretManager());
})
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
} |
Would you mind providing the logging output after reproducing this with logging enabled? If you use the latest pre-release version of the client, it will produce additional logging from the underlying MSAL library as well. |
@christothes I emailed you the logging output. |
@scottaddie - Thanks for collecting these logs. This is, unfortunately, a know issue. I've linked to a comment from an issue where I looked into this. The short answer is that there is no way to avoid providing the tenant ID hint in these cases. |
Describe the bug
I am using Azure.Identity 1.2.0-Preview.4 to access the StorageAccount from .Net Core 3.1 (from Visual Studio 2019), I have signed-in to VS2019 using the same Microsoft account as my Azure subscription where i am owner.
The code used to access storage account is:
When i run the code below exception is thrown:
I have tried following workarounds without success:
I am unable to determine how else to fix this issue in my development environment, the StorageAccount in the subscription is enabled for Identity access.
The text was updated successfully, but these errors were encountered: