Closed guillermoright closed 2 months ago
Thank you for reporting this issue.
We tried to reproduce the issue by creating test application using the template ASP.NET Core WebAPI (native AOT). We then tried to add connection string with Authentication=Active Directory Interactive. The test run succeeded. We then tried to publish using dotnet publish -r win-x64 -c Release. However, we were not able to reproduce the issue you reported.
Could you provide an example reproduction code, please? This will help us to investigate this issue further.
Thank you for reporting this issue.
We tried to reproduce the issue by creating test application using the template ASP.NET Core WebAPI (native AOT). We then tried to add connection string with Authentication=Active Directory Interactive. The test run succeeded. We then tried to publish using dotnet publish -r win-x64 -c Release. However, we were not able to reproduce the issue you reported.
Could you provide an example reproduction code, please? This will help us to investigate this issue further.
this an example you can use to reproduce the errorr , i just added small code to open a database connection ,
I use Azure Hyperscale at work. You should replace the databaseserver and databasename parameters with the ones you'll use.
you need to publish the api dotnet publish -r win-x64 and then call the get endpoint
The web API works in development mode, but once deployed, it throws an error.
in development mode when trying to connect to the server, a browser session opens to enter your credentials. However, after deployment, this process no longer works an throw an error
Can you send me your example so I can review it?
Thank you for the repro. I tried the provided repro and identified that the issue happens when using MDS version 5.2.1.
A hotfix is scheduled to be release within the first 2 weeks of August. We'll let you know when it becomes available.
any update ??
@guillermoright Can you verify the fix in MDS 5.2.2?
@guillermoright Can you verify the fix in MDS 5.2.2?
@DavoudEshtehari The fix in version 5.2.2 does not resolve the issue; we are still encountering the same error when releasing the application using dotnet publish -r win-x64 -c Release. If you go to the publish folder (bin\Release\net8.0\win-x64\publish) and execute NativeApi.exe, it throws the same error reported earlier, but in development mode works well
In the example application, you need to replace the values of "database name" and "database server" with real ones. in this line " Repository.Test("{ //here use real database server }", "{ //here use real database name }"); " to connect using Microsoft Entra MFA Server authentication
then go to the browser /weatherforecast
Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN678PMD990A", Request id "0HN678PMD990A:00000001": An unhandled exception was thrown by the application.
Microsoft.Data.SqlClient.SqlException (0x80131904): A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
---> System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
---> System.MissingMethodException: No parameterless constructor defined for type 'System.Configuration.ClientConfigurationHost'.
at System.ActivatorImplementation.CreateInstance(Type, Boolean) + 0x119
at System.Configuration.Internal.ConfigSystem.System.Configuration.Internal.IConfigSystem.Init(Type, Object[]) + 0x43
at System.Configuration.ClientConfigurationSystem..ctor() + 0x47
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem() + 0x56
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.PrepareConfigSystem() + 0x35
at System.Configuration.ConfigurationManager.GetSection(String) + 0x18
at System.Runtime.Caching.MemoryCacheStatistics.InitializeConfiguration(NameValueCollection) + 0x2c
at System.Runtime.Caching.MemoryCacheStatistics..ctor(MemoryCache, NameValueCollection) + 0x4a
at System.Runtime.Caching.MemoryCache.InitDisposableMembers(NameValueCollection) + 0xf1
at Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider..cctor() + 0x8c
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0xb9
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0x14a
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnGCStaticBase(StaticClassConstructionContext*, Object) + 0xd
at Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.3) + 0x4c6 at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions, DbConnectionPoolKey, Object, DbConnectionPool, DbConnection, DbConnectionOptions) + 0x30e at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool, DbConnection, DbConnectionOptions, DbConnectionPoolKey, DbConnectionOptions) + 0x40 at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection, DbConnectionOptions, DbConnectionInternal) + 0x270 at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection, DbConnectionOptions, DbConnectionInternal) + 0x5e at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection, UInt32, Boolean, Boolean, DbConnectionOptions, DbConnectionInternal&) + 0x4be at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection, TaskCompletionSource
1, DbConnectionOptions, DbConnectionInternal&) + 0xc0
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection, TaskCompletionSource1, DbConnectionOptions, DbConnectionInternal, DbConnectionInternal&) + 0x11e at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection, DbConnectionFactory, TaskCompletionSource
1, DbConnectionOptions) + 0x118
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1, SqlConnectionOverrides) + 0x24c
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides) + 0x1ed
at NativeApi.Repository.Test(String, String) + 0x211
at Program.<>cDisplayClass0_0.
@guillermoright How are you publishing the application? Have you tried a Deployment Mode of Self Contained? Is there a reason why you would not deploy using Deployment mode Self Contained?
@guillermoright How are you publishing the application? Have you tried a Deployment Mode of Self Contained? Is there a reason why you would not deploy using Deployment mode Self Contained?
@arellegue It is Native Aot , just like self-contained apps, using this instruccion "PublishAot true PublishAot" so when i run dotnet publish -r win-x64 -c Release , the app include all required runtime libraries
@guillermoright I see that the issue was closed. Could you try to reference the MDS 6.0-preview1 to see if it fixes the issue, please?
@guillermoright I see that the issue was closed. Could you try to reference the MDS 6.0-preview1 to see if it fixes the issue, please?
@arellegue The MDS 6.0-preview1 dosent solve the issue , it is imposible to connect to azure SQL Database HyperScale, for an application when it is released
Native Aot
using native AOT with ASP.NET Core, minimal api, with azure sql server with Microsoft Entra authentication with Azure SQL,
this is the connection string for Microsoft Entra MFA Serve authentication: {servername};Authentication=Active Directory Interactive;Database={databaseName}
when we deploy the aplication dotnet publish -r win-x64 -c Release, we are getting this error , seems the microsoft entra authentication is not supported,