Thanks apwestgarth . Very strange that it works in an Azure IaaS VM perfectly but fails when its in the windows container. And if I add username and password to the connection string it works like a charm in windows containers. Just not working with MI. Error below is what I get
One or more errors occurred.
at System.Threading.Tasks.Task`1.GetResultCore(Boolean
waitCompletionNotification)
at System.Data.SqlClient.SqlInternalConnectionTds.<>c__
DisplayClass134_1.<GetFedAuthToken>b__1()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Parameters: Connection String: [No connection string
specified], Resource: https://database.windows.net/,
Authority: https://login.windows.net/8FCFE683-42D5-437D-8E
8D-401F4BA55C88. Exception Message: Tried the following 4
methods to get an access token, but none of them worked.
Parameters: Connection String: [No connection string
specified], Resource: https://database.windows.net/,
Authority: https://login.windows.net/8FCFE683-42D5-437D-8E
8D-401F4BA55C88. Exception Message: Tried to get token
using Managed Service Identity. Unable to connect to the
Managed Service Identity (MSI) endpoint. Please check
that you are running on an Azure resource that has MSI
setup.
Parameters: Connection String: [No connection string
specified], Resource: https://database.windows.net/,
Authority: https://login.windows.net/8FCFE683-42D5-437D-8E
8D-401F4BA55C88. Exception Message: Tried to get token
using Visual Studio. Access token could not be acquired.
Visual Studio Token provider file not found at "C:\Windows
\system32\config\systemprofile\AppData\Local\.IdentityServ
ice\AzureServiceAuth\tokenprovider.json"
Parameters: Connection String: [No connection string
specified], Resource: https://database.windows.net/,
Authority: https://login.windows.net/8FCFE683-42D5-437D-8E
8D-401F4BA55C88. Exception Message: Tried to get token
using Azure CLI. Access token could not be acquired. 'az'
is not recognized as an internal or external command,
operable program or batch file.
Parameters: Connection String: [No connection string
specified], Resource: https://database.windows.net/,
Authority: https://login.windows.net/8FCFE683-42D5-437D-8E
8D-401F4BA55C88. Exception Message: Tried to get token
using Active Directory Integrated Authentication. Access
token could not be acquired. Failed to get user name from
the operating system.Inner Exception : No mapping between
account names and security IDs was done
Request information:
Request URL: http://10.41.0.7/
Request path: /
User host address: 10.41.0.7
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 12
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.HttpApplicationFactory.E
nsureAppStartCalledForIntegratedMode(HttpContext context,
HttpApplication app)
at System.Web.HttpApplication.RegisterEventSubscription
sWithIIS(IntPtr appContext, HttpContext context,
MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicati
onState state, MethodInfo[] handlers, IntPtr appContext,
HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicat
ionInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplica
tion(IntPtr appContext)