Issues with EF Update Command and Azure Credentials in ASP.NET Core Application

Yamen Edel 0 Reputation points
2024-05-09T18:29:21.49+00:00

I am encountering errors while attempting to run an Entity Framework (EF) update command (dotnet ef database update) from my ASP.NET Core application. The application is connected to a database hosted on Azure. After executing the EF update command, I am receiving two different errors:

An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.

A DefaultAzureCredential error indicating failure to retrieve a token from the included credentials, despite attempting troubleshooting steps re-authenticating my Azure account in Visual Studio Code. see the error (This account '***' needs re-authentication. Please go to Tools->Options->Azure Services Authentication, and re-authenticate the account you want to use..

- Stored credentials not found. Need to authenticate user in VSCode Azure Account. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/vscodecredential/troubleshoot

- Azure CLI not installed

- PowerShell is not installed.)

I re-configured my SQL call to use the EnableRetryOnFailure method to enable transient error resiliency expecting this to be resolved but it didn't fix it. Then followed the troubleshooting guide provided for the DefaultAzureCredential error,re-authenticating my Azure account in Visual Studio Code and unfortunately this didn't sort it too.

Additionally, the Azure CLI is already installed so not too sure why it's saying it's not !

Any guidance or assistance in resolving this issue would be greatly appreciated. Thank you.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
700 questions
Azure SQL Database
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,228 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yamen Edel 0 Reputation points
    2024-05-10T16:22:42.6+00:00

    An update - as my current IDE is vs code, in order to re-authenticate I was singing out - then signing in using Azure Account extension but apparently this wasn't storing the credentials correctly in vs code to validate them in Azure SQL. I had to try this via VS by going to Tools -> options -> Azure Services Authentication - I signed in from there, then the EF core command worked subsequently !

    0 comments No comments