Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#32 Microsoft.Data.SqlClient v3.0.0 #33

Merged
merged 3 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

## v0.10.0-beta

### Updates

* Updated [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient) to v3.0.0 - contributed by [@usemam](https://github.com/usemam)

### Breaking changes

* Removed manual Azure Managed Identity configuration (it's configured in the MSSQL connection string now) - contributed by [@usemam](https://github.com/usemam)
* Fixed backwards purge history threshold check ([#39](https://github.com/microsoft/durabletask-mssql/pull/39)) - contributed by [Jaah](https://github.com/Jaah)

## v0.9.1-beta
Expand Down
31 changes: 0 additions & 31 deletions src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ class SqlDurabilityOptions
[JsonProperty("taskEventBatchSize")]
public int TaskEventBatchSize { get; set; } = 10;

[JsonProperty("azureManagedIdentityAuthorityHost")]
public string? AzureManagedIdentityAuthorityHost { get; set; }

[JsonProperty("azureManagedIdentityTenantId")]
public string? AzureManagedIdentityTenantId { get; set; }

[JsonProperty("azureManagedIdentityEnabled")]
public bool AzureManagedIdentityEnabled { get; set; }

[JsonProperty("azureManagedIdentityResource")]
public string? AzureManagedIdentityResource { get; set; }

internal ILoggerFactory LoggerFactory { get; set; } = NullLoggerFactory.Instance;

internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings(
Expand Down Expand Up @@ -81,25 +69,6 @@ internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings(
settings.MaxActiveOrchestrations = extensionOptions.MaxConcurrentOrchestratorFunctions.Value;
}

if (this.AzureManagedIdentityEnabled)
{
settings.ManagedIdentitySettings = new ManagedIdentitySettings
{
UseAzureManagedIdentity = this.AzureManagedIdentityEnabled,
TenantId = this.AzureManagedIdentityTenantId,
};

if (!string.IsNullOrEmpty(this.AzureManagedIdentityAuthorityHost))
{
settings.ManagedIdentitySettings.AuthorityHost = new Uri(this.AzureManagedIdentityAuthorityHost);
}

if (!string.IsNullOrEmpty(this.AzureManagedIdentityResource))
{
settings.ManagedIdentitySettings.Resource = new Uri(this.AzureManagedIdentityResource);
}
}

return settings;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DurableTask.SqlServer/DurableTask.SqlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.4.0" />
<PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.5.5" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.*" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="161.46041.41" />
Expand Down
59 changes: 0 additions & 59 deletions src/DurableTask.SqlServer/ManagedIdentitySettings.cs

This file was deleted.

70 changes: 0 additions & 70 deletions src/DurableTask.SqlServer/SqlConnectionFactory.cs

This file was deleted.

10 changes: 5 additions & 5 deletions src/DurableTask.SqlServer/SqlDbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ namespace DurableTask.SqlServer

class SqlDbManager
{
readonly SqlConnectionFactory connectionFactory;
readonly SqlOrchestrationServiceSettings settings;
readonly LogHelper traceHelper;

public SqlDbManager(SqlConnectionFactory connectionFactory, LogHelper traceHelper)
public SqlDbManager(SqlOrchestrationServiceSettings settings, LogHelper traceHelper)
{
this.connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.traceHelper = traceHelper ?? throw new ArgumentNullException(nameof(traceHelper));
}

Expand Down Expand Up @@ -133,7 +133,7 @@ public async Task DeleteSchemaAsync()

async Task<DatabaseLock> AcquireDatabaseLockAsync()
{
SqlConnection connection = await this.connectionFactory.CreateConnection();
SqlConnection connection = this.settings.CreateConnection();
await connection.OpenAsync();

// It's possible that more than one worker may attempt to execute this creation logic at the same
Expand Down Expand Up @@ -187,7 +187,7 @@ async Task ExecuteSqlScriptAsync(string scriptName, DatabaseLock dbLock)
string schemaCommands = await GetScriptTextAsync(scriptName);

// Reference: https://stackoverflow.com/questions/650098/how-to-execute-an-sql-script-file-using-c-sharp
using SqlConnection scriptRunnerConnection = await this.connectionFactory.CreateConnection();
using SqlConnection scriptRunnerConnection = this.settings.CreateConnection();
var serverConnection = new ServerConnection(scriptRunnerConnection);

Stopwatch latencyStopwatch = Stopwatch.StartNew();
Expand Down
8 changes: 2 additions & 6 deletions src/DurableTask.SqlServer/SqlOrchestrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class SqlOrchestrationService : OrchestrationServiceBase
minimumInterval: TimeSpan.FromMilliseconds(50),
maximumInterval: TimeSpan.FromSeconds(3)); // TODO: Configurable

readonly SqlConnectionFactory connectionFactory;
readonly SqlOrchestrationServiceSettings settings;
readonly LogHelper traceHelper;
readonly SqlDbManager dbManager;
Expand All @@ -41,10 +40,7 @@ public SqlOrchestrationService(SqlOrchestrationServiceSettings? settings)
{
this.settings = ValidateSettings(settings) ?? throw new ArgumentNullException(nameof(settings));
this.traceHelper = new LogHelper(this.settings.LoggerFactory.CreateLogger("DurableTask.SqlServer"));
this.connectionFactory = new SqlConnectionFactory(
this.settings.TaskHubConnectionString,
this.settings.ManagedIdentitySettings);
this.dbManager = new SqlDbManager(this.connectionFactory, this.traceHelper);
this.dbManager = new SqlDbManager(this.settings, this.traceHelper);
this.lockedByValue = $"{this.settings.AppName},{Process.GetCurrentProcess().Id}";
this.userId = new SqlConnectionStringBuilder(this.settings.TaskHubConnectionString).UserID ?? string.Empty;
}
Expand Down Expand Up @@ -83,7 +79,7 @@ async Task<SqlConnection> GetAndOpenConnectionAsync(CancellationToken cancelToke
cancelToken = this.ShutdownToken;
}

SqlConnection connection = await this.connectionFactory.CreateConnection();
SqlConnection connection = this.settings.CreateConnection();
await connection.OpenAsync(cancelToken);
return connection;
}
Expand Down
6 changes: 1 addition & 5 deletions src/DurableTask.SqlServer/SqlOrchestrationServiceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public SqlOrchestrationServiceSettings(string connectionString, string? taskHubN
[JsonIgnore]
public ILoggerFactory LoggerFactory { get; set; } = NullLoggerFactory.Instance;

/// <summary>
/// Gets or sets managed identity settings used to connect to a database.
/// </summary>
[JsonProperty("managedIdentitySettings")]
public ManagedIdentitySettings? ManagedIdentitySettings { get; set; }
internal SqlConnection CreateConnection() => new SqlConnection(this.TaskHubConnectionString);
}
}