Skip to content

Commit b6d4b73

Browse files
committed
Merge branch 'main' of https://github.com/evochriso/dbup-sqlserver into evochriso-main
# Conflicts: # src/dbup-sqlserver/AzureSqlConnectionManager.cs # src/dbup-sqlserver/dbup-sqlserver.csproj
2 parents c6f95f9 + aca47da commit b6d4b73

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/dbup-sqlserver/AzureSqlConnectionManager.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System.Collections.Generic;
2-
32
using Microsoft.Data.SqlClient;
43
using DbUp.Engine.Transactions;
54
using DbUp.Support;
6-
7-
using Microsoft.Azure.Services.AppAuthentication;
5+
using Azure.Identity;
6+
using Azure.Core;
87

98
namespace DbUp.SqlServer;
109

@@ -22,12 +21,11 @@ public AzureSqlConnectionManager(string connectionString, string resource)
2221
public AzureSqlConnectionManager(string connectionString, string resource, string tenantId, string azureAdInstance = "https://login.microsoftonline.com/")
2322
: base(new DelegateConnectionFactory((log, dbManager) =>
2423
{
24+
var tokenProvider = new DefaultAzureCredential();
25+
var tokenContext = new TokenRequestContext(scopes: new string[] { resource + "/.default" }, tenantId: tenantId);
2526
var conn = new SqlConnection(connectionString)
2627
{
27-
AccessToken = new AzureServiceTokenProvider(azureAdInstance: azureAdInstance).GetAccessTokenAsync(resource, tenantId)
28-
.ConfigureAwait(false)
29-
.GetAwaiter()
30-
.GetResult()
28+
AccessToken = tokenProvider.GetToken(tokenContext).Token
3129
};
3230

3331
if (dbManager.IsScriptOutputLogged)

src/dbup-sqlserver/dbup-sqlserver.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
<ItemGroup>
2626
<PackageReference Include="dbup-core" Version="6.0.0-beta.146"/>
2727
<PackageReference Include="System.Net.Security" Version="4.3.2" />
28-
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
2928
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
29+
30+
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
31+
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.4" />
32+
<PackageReference Include="Azure.Identity" Version="1.10.4" />
3033
</ItemGroup>
3134

3235
<ItemGroup>

0 commit comments

Comments
 (0)