Skip to content

Commit a218a43

Browse files
author
Sophia Tevosyan
committed
Merge branch 'dev' into stevosyan/extended-sessions-for-orchestrations-isolated
2 parents d4c3b75 + 27083a2 commit a218a43

File tree

12 files changed

+93
-22
lines changed

12 files changed

+93
-22
lines changed

src/WebJobs.Extensions.DurableTask/AzureStorageDurabilityProviderFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ internal AzureStorageOrchestrationServiceSettings GetAzureStorageOrchestrationSe
220220
MaxEntityOperationBatchSize = this.options.MaxEntityOperationBatchSize,
221221
AllowReplayingTerminalInstances = this.azureStorageOptions.AllowReplayingTerminalInstances,
222222
PartitionTableOperationTimeout = this.azureStorageOptions.PartitionTableOperationTimeout,
223+
QueueClientMessageEncoding = this.azureStorageOptions.QueueClientMessageEncoding,
223224
};
224225

225226
if (this.inConsumption)

src/WebJobs.Extensions.DurableTask/IDurabilityProviderFactory.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
using System;
4+
using Microsoft.Azure.WebJobs.Host.Scale;
35

46
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
57
{
@@ -25,5 +27,18 @@ public interface IDurabilityProviderFactory
2527
/// <param name="attribute">A durable client attribute with parameters for the durability provider.</param>
2628
/// <returns>A durability provider to be used by a client function.</returns>
2729
DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute);
30+
31+
/// <summary>
32+
/// Creates or retrieves a cached durability provider to be used in a given function execution.
33+
/// </summary>
34+
/// <param name="attribute">A durable client attribute with parameters for the durability provider.</param>
35+
/// <param name="triggerMetadata">Trigger metadata used to create IOrchestrationService for functions scale scenarios.</param>
36+
/// <returns>A durability provider to be used by a client function.</returns>
37+
DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute, TriggerMetadata triggerMetadata)
38+
{
39+
// This method is not supported by this provider.
40+
// Only providers that require TriggerMetadata for scale should implement it.
41+
throw new NotImplementedException("This provider does not support GetDurabilityProvider with TriggerMetadata.");
42+
}
2843
}
2944
}

src/WebJobs.Extensions.DurableTask/Options/AzureStorageOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7+
using DurableTask.AzureStorage;
78
using Microsoft.Azure.WebJobs.Extensions.DurableTask.Storage;
89
using Microsoft.Extensions.Logging;
910

@@ -232,6 +233,12 @@ public TimeSpan MaxQueuePollingInterval
232233
/// </remarks>
233234
public TimeSpan PartitionTableOperationTimeout { get; set; } = TimeSpan.FromSeconds(2);
234235

236+
/// <summary>
237+
/// Gets or sets the encoding strategy used for Azure Storage Queue messages.
238+
/// The default is <see cref="QueueClientMessageEncoding.UTF8"/>.
239+
/// </summary>
240+
public QueueClientMessageEncoding QueueClientMessageEncoding { get; set; } = QueueClientMessageEncoding.UTF8;
241+
235242
/// <summary>
236243
/// Throws an exception if the provided hub name violates any naming conventions for the storage provider.
237244
/// </summary>

src/WebJobs.Extensions.DurableTask/Scale/DurableTaskTriggersScaleProvider.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Collections.Generic;
77
using System.ComponentModel;
88
using Microsoft.Azure.WebJobs.Host.Scale;
9-
using Microsoft.Extensions.DependencyInjection;
109
using Microsoft.Extensions.Logging;
1110
using Microsoft.Extensions.Options;
1211
using Newtonsoft.Json;
@@ -15,6 +14,8 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Scale
1514
{
1615
internal class DurableTaskTriggersScaleProvider : IScaleMonitorProvider, ITargetScalerProvider
1716
{
17+
private const string AzureManagedProviderName = "azureManaged";
18+
1819
private readonly IScaleMonitor monitor;
1920
private readonly ITargetScaler targetScaler;
2021
private readonly DurableTaskOptions options;
@@ -40,7 +41,16 @@ public DurableTaskTriggersScaleProvider(
4041
this.GetOptions(triggerMetadata);
4142

4243
IDurabilityProviderFactory durabilityProviderFactory = this.GetDurabilityProviderFactory();
43-
DurabilityProvider defaultDurabilityProvider = durabilityProviderFactory.GetDurabilityProvider();
44+
45+
DurabilityProvider defaultDurabilityProvider;
46+
if (string.Equals(durabilityProviderFactory.Name, AzureManagedProviderName, StringComparison.OrdinalIgnoreCase))
47+
{
48+
defaultDurabilityProvider = durabilityProviderFactory.GetDurabilityProvider(attribute: null, triggerMetadata);
49+
}
50+
else
51+
{
52+
defaultDurabilityProvider = durabilityProviderFactory.GetDurabilityProvider();
53+
}
4454

4555
// Note: `this.options` is populated from the trigger metadata above
4656
string? connectionName = GetConnectionName(durabilityProviderFactory, this.options);

src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<AssemblyName>Microsoft.Azure.WebJobs.Extensions.DurableTask</AssemblyName>
66
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.DurableTask</RootNamespace>
7-
<MajorVersion>3</MajorVersion>
8-
<MinorVersion>5</MinorVersion>
9-
<PatchVersion>0</PatchVersion>
7+
<MajorVersion>3</MajorVersion>
8+
<MinorVersion>5</MinorVersion>
9+
<PatchVersion>0</PatchVersion>
1010
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
1111
<VersionSuffix>private1</VersionSuffix>
1212
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>

src/Worker.Extensions.DurableTask/Worker.Extensions.DurableTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile>
3030

3131
<!-- Version information -->
32-
<VersionPrefix>1.8.1</VersionPrefix>
32+
<VersionPrefix>1.8.1</VersionPrefix>
3333
<VersionSuffix>private1</VersionSuffix>
3434
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
3535
<!-- FileVersionRevision is expected to be set by the CI. -->

test/Common/DurableTaskEndToEndTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5107,6 +5107,46 @@ public async Task DurableEntity_CleanEntityStorage(string storageProvider)
51075107
}
51085108
}
51095109

5110+
/// <summary>
5111+
/// End-to-end test which validates that QueueClientMessageEncoding.Base64 works correctly with a Hello World orchestration.
5112+
/// And with base64-queueclient we can support orchestration with escaped characters.
5113+
/// </summary>
5114+
[Fact]
5115+
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
5116+
public async Task HelloWorld_QueueClientMessageEncoding_Base64()
5117+
{
5118+
string[] orchestratorFunctionNames =
5119+
{
5120+
nameof(TestOrchestrations.SayHelloInline),
5121+
};
5122+
5123+
var options = new DurableTaskOptions();
5124+
5125+
// Configure Azure Storage provider with Base64 message encoding
5126+
options.StorageProvider["ConnectionName"] = "AzureWebJobsStorage";
5127+
options.StorageProvider["QueueClientMessageEncoding"] = "Base64";
5128+
5129+
// Create input with escaped characters including 0xFFFE
5130+
string inputWithEscapedChars = "World\uFFFE\u0001\u0002\u0003";
5131+
5132+
using (var host = TestHelpers.GetJobHostWithOptions(
5133+
this.loggerProvider,
5134+
durableTaskOptions: options,
5135+
storageProviderType: TestHelpers.AzureStorageProviderType))
5136+
{
5137+
await host.StartAsync();
5138+
5139+
var client = await host.StartOrchestratorAsync(orchestratorFunctionNames[0], inputWithEscapedChars, this.output);
5140+
var status = await client.WaitForCompletionAsync(this.output);
5141+
5142+
Assert.Equal(OrchestrationRuntimeStatus.Completed, status?.RuntimeStatus);
5143+
Assert.Equal(inputWithEscapedChars, status?.Input);
5144+
Assert.Equal($"Hello, {inputWithEscapedChars}!", status?.Output);
5145+
5146+
await host.StopAsync();
5147+
}
5148+
}
5149+
51105150
[Theory]
51115151
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
51125152
[MemberData(nameof(TestDataGenerator.GetFullFeaturedStorageProviderOptions), MemberType = typeof(TestDataGenerator))]

test/FunctionsV2/EmulatorDurabilityProviderFactory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using DurableTask.Core;
54
using DurableTask.Emulator;
65

76
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<packageSources>
4-
<clear/>
5-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
6-
<add key="local" value="." />
3+
<packageSources>
4+
<clear/>
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
6+
<add key="local" value="." />
77
<add key="durabletask-testing" value="https://azfunc.pkgs.visualstudio.com/public/_packaging/durabletask-testing/nuget/v3/index.json" />
8-
</packageSources>
8+
</packageSources>
99
</configuration>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<packageSources>
4-
<clear/>
5-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
6-
<add key="local" value="." />
3+
<packageSources>
4+
<clear/>
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
6+
<add key="local" value="." />
77
<add key="durabletask-testing" value="https://azfunc.pkgs.visualstudio.com/public/_packaging/durabletask-testing/nuget/v3/index.json" />
8-
</packageSources>
8+
</packageSources>
99
</configuration>

0 commit comments

Comments
 (0)