Skip to content

Commit

Permalink
Add StorageAccountDetails to AzureStorageOrchestrationServiceSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksha Asrani committed Jan 14, 2019
1 parent 7cd6510 commit 39e6dd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
33 changes: 8 additions & 25 deletions src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public sealed class AzureStorageOrchestrationService :
readonly WorkItemQueue workItemQueue;
readonly ConcurrentDictionary<string, ActivitySession> activeActivitySessions;
readonly MessageManager messageManager;
readonly StorageAccountDetails storageAccountDetails;

readonly ITrackingStore trackingStore;

Expand All @@ -75,22 +76,13 @@ public sealed class AzureStorageOrchestrationService :
bool isStarted;
Task statsLoop;
CancellationTokenSource shutdownSource;

/// <summary>
/// Initializes a new instance of the <see cref="AzureStorageOrchestrationService"/> class.
/// </summary>
/// <param name="settings">The settings used to configure the orchestration service.</param>
public AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSettings settings)
: this(settings, customInstanceStore: null)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="AzureStorageOrchestrationService"/> class with a custom instance store.
/// </summary>
/// <param name="settings">The settings used to configure the orchestration service</param>
/// <param name="storageAccountDetails">The Azure storage account details</param>
public AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSettings settings, StorageAccountDetails storageAccountDetails)
: this(settings, storageAccountDetails, null)
: this(settings, null)
{ }

/// <summary>
Expand All @@ -99,20 +91,6 @@ public AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSettings
/// <param name="settings">The settings used to configure the orchestration service.</param>
/// <param name="customInstanceStore">Custom UserDefined Instance store to be used with the AzureStorageOrchestrationService</param>
public AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSettings settings, IOrchestrationServiceInstanceStore customInstanceStore)
: this(settings, settings != null ? GetCloudStorageAccount(settings.StorageConnectionString) : null, customInstanceStore)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="AzureStorageOrchestrationService"/> class with a custom instance store.
/// </summary>
/// <param name="settings">The settings used to configure the orchestration service</param>
/// <param name="storageAccountDetails">The azure storage account details</param>
/// <param name="customInstanceStore">Custom UserDefined Instance store to be used with the AzureStorageOrchestrationService</param>
public AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSettings settings, StorageAccountDetails storageAccountDetails, IOrchestrationServiceInstanceStore customInstanceStore)
: this(settings, GetCloudStorageAccount(storageAccountDetails), customInstanceStore)
{ }

private AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSettings settings, CloudStorageAccount account, IOrchestrationServiceInstanceStore customInstanceStore)
{
if (settings == null)
{
Expand All @@ -123,6 +101,11 @@ private AzureStorageOrchestrationService(AzureStorageOrchestrationServiceSetting

this.settings = settings;
this.tableEntityConverter = new TableEntityConverter();
this.storageAccountDetails = settings.StorageAccountDetails;

CloudStorageAccount account = this.storageAccountDetails == null
? CloudStorageAccount.Parse(settings.StorageConnectionString)
: new CloudStorageAccount(this.storageAccountDetails.StorageCredentials, this.storageAccountDetails.AccountName, this.storageAccountDetails.EndpointSuffix, true);
this.storageAccountName = account.Credentials.AccountName;
this.stats = new AzureStorageOrchestrationServiceStats();
this.queueClient = account.CreateCloudQueueClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,11 @@ public class AzureStorageOrchestrationServiceSettings
/// interval, it will cause it to expire and ownership of the partition will move to another worker instance.
/// </summary>
public TimeSpan LeaseInterval { get; set; } = TimeSpan.FromSeconds(30);

/// <summary>
/// Gets or sets the Azure Storage Account details
/// If provided, this is used to connect to Azure Storage
/// </summary>
public StorageAccountDetails StorageAccountDetails { get; set; }
}
}

0 comments on commit 39e6dd1

Please sign in to comment.