Reputation: 17
Tech Stack:
.Net 6 web api
Microsoft.Sql.Sqlclient 4.0.1 (Nuget package add Azure App service(API) - System generated Managed Identity).
Azure.Identity
Azure Sql database - setup to accept API APP service managed identity.
I am using EFcore in API to connect to Azure sql database and this setup is working as expected in my workstation from VS2022(using from vs2022 credentail). the API connects with database without any issues. But when the same code is deployed to Azure APP service, API is not able to connect to Azure Sql instance.
Issue: Azure App service "System-managed" identity works fine in local using VS2022 but is not working in App service
Thanks in advance
Upvotes: 0
Views: 599
Reputation: 7392
Thanks @Jason Pan and Thomas for the comments.
Make sure you have enabled the Managed Identity
in the Azure App service
.
As mentioned in the MSDoc, check the identity status by using the below command.
az webapp identity show --name KeyVaultAPIMay24 --resource-group YourRG
As mentioned by Thomas check whether you have configured SQL Database with correct permissions to use Managed Identity by Amine Teffahi.
We can also configure the Managed Identity
from the Visual Studio itself.
After publishing the App again, you need to Connect to the Identity Platform.
Upvotes: 0