Skip to content

Commit

Permalink
Replace deprecated package Microsoft.Azure.Services.AppAuthentication…
Browse files Browse the repository at this point in the history
… with Azure.Identity
  • Loading branch information
evochriso committed Feb 12, 2024
1 parent 21591e0 commit 6b18efc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/dbup-sqlserver/AzureSqlConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
using DbUp.Support;

#if SUPPORTS_AZURE_AD
using Microsoft.Azure.Services.AppAuthentication;
using Azure.Identity;
using Azure.Core;

namespace DbUp.SqlServer
{
Expand All @@ -28,12 +29,11 @@ public AzureSqlConnectionManager(string connectionString, string resource)
public AzureSqlConnectionManager(string connectionString, string resource, string tenantId, string azureAdInstance = "https://login.microsoftonline.com/")
: base(new DelegateConnectionFactory((log, dbManager) =>
{
var tokenProvider = new DefaultAzureCredential();
var tokenContext = new TokenRequestContext(scopes: new string[] { resource + "/.default" }, tenantId: tenantId);
var conn = new SqlConnection(connectionString)
{
AccessToken = new AzureServiceTokenProvider(azureAdInstance: azureAdInstance).GetAccessTokenAsync(resource, tenantId)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult()
AccessToken = tokenProvider.GetToken(tokenContext).Token
};

if (dbManager.IsScriptOutputLogged)
Expand Down
10 changes: 5 additions & 5 deletions src/dbup-sqlserver/dbup-sqlserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Data" />
<Reference Include="System" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
</ItemGroup>

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

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

0 comments on commit 6b18efc

Please sign in to comment.