Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Managed Identity Auth doesn't work in linux consumption plan #863

Closed
older opened this issue Dec 29, 2020 · 4 comments
Closed

Azure Managed Identity Auth doesn't work in linux consumption plan #863

older opened this issue Dec 29, 2020 · 4 comments

Comments

@older
Copy link

older commented Dec 29, 2020

Describe the bug

Using the "2017-09-01" Azure Managed Identity API version is required on Azure Functions Linux Consumption hosting plans. Current implementation uses version 2019-08-01 which produces the following exception:

Exception message:
Received a non-retryable error. Identity Response Code: BadRequest, Response: {"error":{"code":"UnsupportedApiVersion","message":"The HTTP resource that matches the request URI 'http://localhost:8081/msi/token?resource=https://database.windows.net/&api-version=2019-08-01' does not support the API version '2019-08-01'.","innerError":null}} 
Stack trace:
System.AggregateException:
   at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
...

To reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

string ConnectionString = @"Server=demo.database.windows.net; Authentication=Active Directory Managed Identity; Database=testdb;";
using (SqlConnection conn = new SqlConnection(ConnectionString)) {
    conn.Open();
}

Expected behavior

Database connection is open.

Further technical details

Microsoft.Data.SqlClient version: 2.1.1
.NET target: Core 3.1.10
SQL Server version: Azure SQL
Operating system: Azure Functions Linux Consumption hosting plan

@cheenamalhotra
Copy link
Member

Acknowledged.
We'll consider addressing this in next iterations.

@older
Copy link
Author

older commented Dec 30, 2020

@cheenamalhotra Maybe documentation should be updated to mention this?

May I ask why Azure.Identity was not used to implement this? Was it too heavy a dependency for SqlClient?

@cheenamalhotra
Copy link
Member

Hi @older,

There's an open issue for Azure Identity dependency work we'll be doing soon (#771)

To summarize, it wasn't possible in the last release as Azure Identity doesn't support net46 and dropping net46 support wasn't possible in release v2.1.x for SqlClient.

@cheenamalhotra
Copy link
Member

This has been fixed with the latest release v3.0.0-preview2. The driver now depends on Azure.Identity to acquire access token for Managed Identity based authentication. Release notes

Closing issue as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants