Problem signing in to Azure from Visual Studio 2022

Erik Dahl 15 Reputation points
2023-02-26T15:10:17.1033333+00:00

I have an account in Azure AD and have successfully set up and deployed an Azure App Service by logging in to portal.azure.com and manually deploying from a GitHub repo.

I'm trying to debug the app from Visual Studio 2022 (v 17.5) and when I get prompted to sign in to my Azure account, I use my Microsoft account (same one I signed in to portal.azure.com with) and it successfully authenticates but the dialog does not load any subscription information and continues to prompt me to sign in (doesn't matter how many times I successfully do this).

I change an authentication setting within VS to use the "System Web Browser" for authenticating, and signed out of Visual Studio. Then when I logged back in I got this error:

"The following tenants were not added to the account ******@outlook.com 'f8cdef31-a31e-4b4a-93e4-5f571e91255a' - for more information check the logs..."

I checked the logs and saw things like the entries below. Is there any way I can get properly authenticated into my Azure account from VS 2022?

02/26/2023 08:49:23 Central Standard Time : Error : Attempt 1 to call 'v1.0/me', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/26/2023 08:49:23 Central Standard Time : Error : Retry count met, for 'v1.0/me' calls, giving up.
02/26/2023 08:49:24 Central Standard Time : Error : Attempt 1 to call '/f8cdef31-a31e-4b4a-93e4-5f571e91255a/me?api-version=1.6', failed with an error: 'System.UnauthorizedAccessException: Unauthorized to access 'https://graph.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/me?api-version=1.6'. Forbidden
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/26/2023 08:49:26 Central Standard Time : Error : Attempt 1 to call 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/26/2023 08:49:27 Central Standard Time : Error : Attempt 2 to call 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/26/2023 08:49:29 Central Standard Time : Error : Attempt 3 to call 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/26/2023 08:49:29 Central Standard Time : Error : Retry count met, for 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a' calls, giving up.
02/26/2023 08:49:29 Central Standard Time : Error : Failed getting tenant details preferred client exception 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
   at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient+AbstractGraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)
   at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)'
02/26/2023 08:49:30 Central Standard Time : Error : Attempt 1 to call '/f8cdef31-a31e-4b4a-93e4-5f571e91255a/tenantDetails?api-version=1.6', failed with an error: 'System.UnauthorizedAccessException: Unauthorized to access 'https://graph.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/tenantDetails?api-version=1.6'. Forbidden
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/26/2023 08:49:30 Central Standard Time : Error : Failed getting tenant details fallback exception 'System.UnauthorizedAccessException: Unauthorized to access 'https://graph.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/tenantDetails?api-version=1.6'. Forbidden
   at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
   at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
   at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient+AbstractGraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)
   at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)'
02/26/2023 08:49:30 Central Standard Time : Error : Skipping tenant 'f8cdef31-a31e-4b4a-93e4-5f571e91255a' error getting friendly name: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)
   at async Task Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderNetworkServicesBase.GetTenantDetailsAsync(TenantInformation partialTenantInfo, AuthenticationInfo authInfo, bool promptIfNeeded, string queryParameters, AuthenticationFlowType authenticationFlowType, Dictionary<string, string> additionalAuthProperties, CancellationToken cancellationToken)
   at async Task Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderService.TryGetTenantDetailsAsync(AuthenticationInfo authInfo, bool promptIfNeeded, string queryParameters, AuthenticationFlowType authenticationFlowType, Dictionary<string, string> additionalAuthProperties, List<TenantInformation> tenants, HashSet<MissingTenantInfo> missingTenants, CancellationToken cancellationToken)'

Developer technologies | Visual Studio | Debugging
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,979 questions
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Developer technologies | Visual Studio | Other
{count} votes

2 answers

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2023-03-03T20:14:09.11+00:00

    Jan, thanks for reporting this issue. Could you please confirm, if redownloading the .publishsettings file was helpful.

    ·       Does this issue occur only when deploying to Azure App Service WebApp or happens for local deployments?
    Just to isolate the issue further:

    ·       You may directly login to your Azure subscription via Azure Portal, and find (status) the deployment/resources. https://portal.azure.com/

    ·    In the VS Tools Menu, Options -> Azure Service Authentication. Under the Choose an account drop down,

    ·       Open new profile window, and re enter my credentials, and cancel creating new profile.

    -Reference

      -You may try these, if you haven't done it already:
    • Install the latest updates in Visual Studio by selecting Help > Check for Updates.

    2 people found this answer helpful.

  2. Nainil Patel 5 Reputation points
    2023-05-22T04:04:39.6066667+00:00

    Upgrading to latest version 17.6.0 resolved this problem for me.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.