使用 EF Core 通过 AAD 身份验证连接到 Azure SQL 服务器
Connect to Azure SQL server via AAD Authentication using EF Core
-
azure-active-directory
-
entity-framework-core
-
azure-sql-database
-
azure-web-app-service
-
azure-sql-server
Azure SQL 服务器支持 AAD 身份验证,我希望我的应用程序使用 AAD 身份验证而不是 SQL 服务器管理员凭据连接到 SQL 服务器。我正在使用 EF Core 连接到 SQL,如何启用 EF Core 以使用 AAD 身份验证。
我的应用程序部署在 Azure App Service 中并且启用了 MSI 扩展,所以我期待使用 Microsoft.Azure.Services.AppAuthentication
从 AAD 获取令牌。
Connect to Azure SQL server via AAD Authentication using EF Core
如果你的项目平台是.netcore,目前是not supported
。我还在 github 上找到了 issue。
或者你可以参考这个blog or another 。
so I am looking forward to using Microsoft.Azure.Services.AppAuthentication for getting the token from AAD
您可以从 document 获取演示代码
您可以从 document
获取演示代码
var azureServiceTokenProvider = new AzureServiceTokenProvider();
string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync("https://management.azure.com/").ConfigureAwait(false);
更新:
感谢AlejandroC的分享,.NET Core 2.2 Preview 1已经支持,更多信息请参考.NET Core 2.2 Preview 1 - August 22, 2018
azure-active-directory
entity-framework-core
azure-sql-database
azure-web-app-service
azure-sql-server
Azure SQL 服务器支持 AAD 身份验证,我希望我的应用程序使用 AAD 身份验证而不是 SQL 服务器管理员凭据连接到 SQL 服务器。我正在使用 EF Core 连接到 SQL,如何启用 EF Core 以使用 AAD 身份验证。
我的应用程序部署在 Azure App Service 中并且启用了 MSI 扩展,所以我期待使用 Microsoft.Azure.Services.AppAuthentication
从 AAD 获取令牌。
Connect to Azure SQL server via AAD Authentication using EF Core
如果你的项目平台是.netcore,目前是not supported
。我还在 github 上找到了 issue。
或者你可以参考这个blog or another
so I am looking forward to using Microsoft.Azure.Services.AppAuthentication for getting the token from AAD
您可以从 document 获取演示代码 您可以从 document
获取演示代码 var azureServiceTokenProvider = new AzureServiceTokenProvider();
string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync("https://management.azure.com/").ConfigureAwait(false);
更新:
感谢AlejandroC的分享,.NET Core 2.2 Preview 1已经支持,更多信息请参考.NET Core 2.2 Preview 1 - August 22, 2018