Skip to content

Commit 6b18efc

Browse files
committed
Replace deprecated package Microsoft.Azure.Services.AppAuthentication with Azure.Identity
1 parent 21591e0 commit 6b18efc

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/dbup-sqlserver/AzureSqlConnectionManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
using DbUp.Support;
1111

1212
#if SUPPORTS_AZURE_AD
13-
using Microsoft.Azure.Services.AppAuthentication;
13+
using Azure.Identity;
14+
using Azure.Core;
1415

1516
namespace DbUp.SqlServer
1617
{
@@ -28,12 +29,11 @@ public AzureSqlConnectionManager(string connectionString, string resource)
2829
public AzureSqlConnectionManager(string connectionString, string resource, string tenantId, string azureAdInstance = "https://login.microsoftonline.com/")
2930
: base(new DelegateConnectionFactory((log, dbManager) =>
3031
{
32+
var tokenProvider = new DefaultAzureCredential();
33+
var tokenContext = new TokenRequestContext(scopes: new string[] { resource + "/.default" }, tenantId: tenantId);
3134
var conn = new SqlConnection(connectionString)
3235
{
33-
AccessToken = new AzureServiceTokenProvider(azureAdInstance: azureAdInstance).GetAccessTokenAsync(resource, tenantId)
34-
.ConfigureAwait(false)
35-
.GetAwaiter()
36-
.GetResult()
36+
AccessToken = tokenProvider.GetToken(tokenContext).Token
3737
};
3838

3939
if (dbManager.IsScriptOutputLogged)

src/dbup-sqlserver/dbup-sqlserver.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
2525
<Reference Include="System.Data" />
2626
<Reference Include="System" />
27-
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
27+
<PackageReference Include="Azure.Identity" Version="1.10.4" />
2828
</ItemGroup>
2929

3030
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
3131
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
3232
</ItemGroup>
33-
33+
3434
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
3535
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
36-
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
36+
<PackageReference Include="Azure.Identity" Version="1.10.4" />
3737
</ItemGroup>
3838

3939
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
40-
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.4" />
41-
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
40+
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.5" />
41+
<PackageReference Include="Azure.Identity" Version="1.10.4" />
4242
</ItemGroup>
4343

4444
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">

0 commit comments

Comments
 (0)