Share via

AddDistributedSqlServerCache connection not working

Patel, Saurabh K 0 Reputation points
2024-01-31T21:14:49.49+00:00

Below code is not working with this connection string. Connection string "Server=AZURESQLSERVER.database.windows.net,1433;Database=AZURE_DB;Authentication=Active Directory MSI;"

services.AddDistributedSqlServerCache(options =>
    {                
                options.ConnectionString = CRAFDBConnection;                
                options.SchemaName = "dbo";
                options.TableName = "SQLSessions";
   });


Any suggestions ??

Azure SQL Database
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

Developer technologies | ASP.NET Core | Other

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-01-31T21:33:52.1933333+00:00

    It's hard to know without the exact error you're getting, but Managed Identity Auth (MSI) is only available with Microsoft.Data.SqlClient 2.1.0 or newer. If you're using a user-assigned managed identity, you'll need to specify either the client id (v3+) or object id (v2.1), like so: // With Microsoft.Data.SqlClient v3.0+ string ConnectionString1 = @"Server=demo.database.windows.net; Authentication=Active Directory Managed Identity; Encrypt=True; User Id=ClientIdOfManagedIdentity; Database=testdb";

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.