I have been attempting too. I have been able to connect use PSU with SQL support using SQL authentication in Azure.
When I attempted to use either of the passwordless connection strings below, I encountered the same errors as seen by @mabster:
Active Directory Managed Identity Connection String:
Server=<SQL Server>; Authentication=Active Directory Managed Identity; Encrypt=True; Database=<Database Name>; User Id=<Azure Managed Identity ClientID>;"
Active Directory Default Connection String:
Server=<SQL Server>; Authentication=Active Directory Default; Encrypt=True; Database=<Database Name>;
Error:
[14:32:50 INF] Start installing Hangfire SQL objects...
Unhandled exception. System.ArgumentException: Keyword not supported: 'authentication'.
at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Hangfire.SqlServer.SqlServerStorage.<.ctor>b__6_0()
at Hangfire.SqlServer.SqlServerStorage.CreateAndOpenConnection()
at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](DbConnection dedicatedConnection, Func`2 func)
at Hangfire.SqlServer.SqlServerStorage.Initialize()
at Hangfire.SqlServer.SqlServerStorage..ctor(String nameOrConnectionString, SqlServerStorageOptions options)
at Hangfire.SqlServerStorageExtensions.UseSqlServerStorage(IGlobalConfiguration configuration, String nameOrConnectionString, SqlServerStorageOptions options)
at PowerShellUniversal.SQL.SqlFeature.ConfigureHangfire(IServiceCollection serviceProvider, IConfiguration configuration) in C:\actions-runner\_work\universal\universal\src\PowerShellUniversal.SQL\Plugin.cs:line 40
at Universal.Server.Services.PluginService.ConfigureHangfire(IServiceCollection serviceCollection, IConfiguration configuration) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\PluginService.cs:line 85
at Universal.Server.UniversalAutomationStartup.ConfigureServices(IServiceCollection services, IPluginService pluginService)
at Universal.Server.Startup.ConfigureServices(IServiceCollection services) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Startup.cs:line 80
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Universal.Server.Program.<>c__DisplayClass3_0.<Main>b__0(Options o) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Program.cs:line 76
at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
at Universal.Server.Program.Main(String[] args) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Program.cs:line 58
I reviewed an SQL authentication connection and the output given showed this:
[14:46:30 INF] Start installing Hangfire SQL objects...
[14:46:31 INF] Hangfire SQL objects installed.
Checking my SQL Server, I can see that I am finally getting connections to my SQL Database.
Turning my attention to Hangfire leads me to this forum post - Using Microsoft.Data.SqlClient in Hangfire.SqlServer? - question - Hangfire Discussion
It appears Hangfire 1.7.25 does not have a version of Microsoft.Data.SqlClient greater than version 3. It appears when version 1.8 comes out this may be achievable by default.
It looks like there has been some success to workaround this in the Hangfire community - Using Hangfire with Azure and Managed Identity - question - Hangfire Discussion. As I am using the docker container, I expect I will not be able to implement this change. I would be curious to see if this worked if a 1.8 release candidate was built into PSU, however this would not be suitable for a production release. I am wondering if it is feasible to modify the startup.cs file in the released docker images without breaking PSU for anyone who has it working.
I suspect we will have to wait until Hangfire release v1.8 and this is built into PSU for passwordless Azure Active Directory support.
I would be curious to know if anyone else has been able to find a workaround for this for anyone using Azure and the Docker container release. I hope my notes save other engineers some investigation time pulling AD apart to identify why this does not work.