What SQL Server connection string works with Entra in Azure?

I have installed a .Net Framework 4.5.2 Web app into Azure, which is set up to use Entra authentication. The app needs to connect to a SQL Server database in the Azure account. The Azure UI shows a variety of connection strings to use with the database. But none of them work. I put the connection strings (modified to include server, db, uid, and pwd as needed) in a Connection String environmental variable. It does not allow specifying a provider, by the way. How do I know what providers are present in Azure? Or do I need to add a new one to my application? It currently references System.Data.

Connection strings suggested by Azure

ADO.NET (Microsoft Entra passwordless authentication)

Server=tcp:MyDBServer.database.windows.net,1433;Initial Catalog=MyDB;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication="Active Directory Default";

Error: Invalid value for key ‘authentication’.


Plain SQL authentication

Server=tcp:MyDBServer.database.windows.net,1433;Initial Catalog=MyDB;Persist Security Info=False;User ID=MyUID;Password=MyPwd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

Error: Cannot open server ‘xxx’ requested by the login. Client with IP address ‘xx.x.xxx.x’ is not allowed to access the server. To enable access, use the Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.


ADO.NET (Microsoft Entra password authentication)

Server=tcp:MyDBServer.database.windows.net,1433;Initial Catalog=MyDB;Persist Security Info=False;User ID=MyUID;Password=MyPwd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";

Error: One or more errors occurred.


ADO.NET (Microsoft Entra integrated authentication)

Server=tcp:MyDBServer.database.windows.net,1433;Initial Catalog=MyDB;Persist Security Info=False;User ID=MyUID;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Integrated";

Error: Cannot use ‘Authentication=Active Directory Integrated’ with ‘User ID’, ‘UID’, ‘Password’ or ‘PWD’ connection string keywords.


ADO.NET (Microsoft Entra integrated authentication)

Server=tcp:MyDBServer.database.windows.net,1433;Initial Catalog=MyDB;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Integrated";

Error: One or more errors occurred.

3

Error: Cannot open server ‘xxx’ requested by the login. Client with IP address ‘xx.x.xxx.x’ is not allowed to access the server. To enable access, use the Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.

This is an error you get when you did not allow the client to access the server using the firewall, see the docs on how to do that.

Now, this

ADO.NET (Microsoft Entra integrated authentication)

Server=tcp:MyDBServer.database.windows.net,1433;Initial Catalog=MyDB;Persist Security Info=False;User ID=MyUID;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication=”Active Directory Integrated”;

Error: Cannot use ‘Authentication=Active Directory Integrated’ with ‘User ID’, ‘UID’, ‘Password’ or ‘PWD’ connection string keywords.

indicates that you should not supply an user id when using “Active Directory Integrated” authentication

If you want “Active Directory Integrated” authentication against your Azure Database you will need to switch to the Microsoft.Data.SqlClient namespace, see this blogpost. There is a guide on how to do that.

That also means you need to update to at least .Net Framework 4.6.2 as seen here

So, if you don’t want to, or can’t do use a connection string with username and password and make sure network access is allowed.

Recognized by Microsoft Azure Collective

The default provider in Azure for connection strings should be System when you are working with them in a.NET Framework 4.5.2 application. SQL Server databases can be used using Data.SqlClient.

You indicated that you are utilizing Azure AD (previously known as Entra authentication), so it is imperative that you verify that the authentication techniques and connection string format are valid.

Measures to Recognise and Fix:

Examine the format of the connection string. Make sure Azure SQL Server has the connection string formatted appropriately. A small format difference exists between SQL authentication and Entra (Azure AD) authentication.

For Authentication

Data Source=<your_server>.database.windows.net;Initial Catalog=<your_database>;User ID=<your_username>;Password=<your_password>;

Example of Entra (Azure AD) Authentication: If your database connections are made with Entra authentication, then:

Data Source=<your_server>.database.windows.net;Initial Catalog=<your_database>;Authentication=Active Directory Integrated;

Alternatively, if you’re authenticating with a particular client ID (Service Principal):

Data Source=<your_server>.database.windows.net;Initial Catalog=<your_database>;Authentication=Active Directory Service Principal;User Id=<client_id>;Password=<client_secret>;

New contributor

Ghani05 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật