不支持关键字:azure 集成连接的“身份验证"错误

编程入门 行业动态 更新时间:2024-10-15 12:37:03
本文介绍了不支持关键字:azure 集成连接的“身份验证"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

不支持获取关键字:尝试通过 .NET core 2.1 项目中的Active Directory Integrated"选项连接 Azure DB 时出现身份验证"错误.

Getting Keyword not supported: 'authentication' error while trying to connect an azure DB through 'Active Directory Integrated' option in .NET core 2.1 project.

注意:我使用 EF core 连接数据源.

Note: I am using EF core to connect the Data source.

推荐答案

UPDATE - 16/08/2019现在已在 Microsoft.Data.SqlClient 1.0.19221.1-Preview

遗憾的是,.NET Core 尚未完全支持 authentication 关键字.这是讨论此问题的 issue.

Unfortunately, the authentication keyword is not yet fully supported in .NET Core. Here is an issue which discusses this.

但是 .NET Core 2.2 已经添加了对此用例的一些支持,如本评论.基本思想是通过 任何方式(ADAL、REST 等)并将 SqlConnection.AccessToken 设置为它.

But .NET Core 2.2 has added some support for this use case as mentioned in this comment. The basic idea is to get the access token by any means (ADAL, REST, etc.) and set SqlConnection.AccessToken to it.

至于将其与 EF Core 一起使用,在此 github 问题中对此进行了很好的讨论 特别是 评论来自 mgolois 为cbriaball 在线程中提到的解决方案.

As for using this with EF Core, there's a good discussion about this in this github issue and in particular the comment by mgolois provides a simple implementation to the solution that cbriaball mentions in the thread.

这里相同以供参考

请注意,此示例使用的是 Microsoft.Azure.Services.AppAuthentication 图书馆

Note that this sample is using the Microsoft.Azure.Services.AppAuthentication library

// DB Context Class public class SampleDbContext : DbContext { public SampleDbContext(DbContextOptions<TeamsDbContext> options) : base(options) { var conn = (System.Data.SqlClient.SqlConnection)this.Database.GetDbConnection(); conn.AccessToken = (new AzureServiceTokenProvider()).GetAccessTokenAsync("database.windows/").Result; } } // Startup.cs services.AddDbContext<SampleDbContext>(options => { options.UseSqlServer(<Connection String>); });

连接字符串将是这样的Server=tcp:.database.windows,1433;Database=;

更多推荐

不支持关键字:azure 集成连接的“身份验证"错误

本文发布于:2023-11-03 18:56:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555819.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   身份验证   关键字   错误   azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!