diff --git a/samples/correlation-csharp/FunctionAppCorrelation.sln b/samples/correlation-csharp/FunctionAppCorrelation.sln new file mode 100644 index 000000000..c1e5f9a30 --- /dev/null +++ b/samples/correlation-csharp/FunctionAppCorrelation.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29509.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionAppCorrelation", "FunctionAppCorrelation\FunctionAppCorrelation.csproj", "{F9428663-9742-4746-A434-D073CCD5395C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F9428663-9742-4746-A434-D073CCD5395C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9428663-9742-4746-A434-D073CCD5395C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9428663-9742-4746-A434-D073CCD5395C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9428663-9742-4746-A434-D073CCD5395C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6D2AE1B1-FA1A-4E46-B75D-B9B01E570B50} + EndGlobalSection +EndGlobal diff --git a/samples/correlation-csharp/FunctionAppCorrelation/.gitignore b/samples/correlation-csharp/FunctionAppCorrelation/.gitignore new file mode 100644 index 000000000..46cc43091 --- /dev/null +++ b/samples/correlation-csharp/FunctionAppCorrelation/.gitignore @@ -0,0 +1 @@ +local.settings.json diff --git a/samples/correlation-csharp/FunctionAppCorrelation/local.settings.json b/samples/correlation-csharp/FunctionAppCorrelation/local.settings.json new file mode 100644 index 000000000..5c404a9bd --- /dev/null +++ b/samples/correlation-csharp/FunctionAppCorrelation/local.settings.json @@ -0,0 +1,8 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "dotnet", + "APPINSIGHTS_INSTRUMENTATIONKEY": " string IDurableOrchestrationContext.StartNewOrchestration(string functionName, object input, string instanceId) { + // correlation +#if NETSTANDARD2_0 + var context = CorrelationTraceContext.Current; +#endif this.ThrowIfInvalidAccess(); var actualInstanceId = string.IsNullOrEmpty(instanceId) ? this.NewGuid().ToString() : instanceId; var alreadyCompletedTask = this.CallDurableTaskFunctionAsync(functionName, FunctionType.Orchestrator, true, actualInstanceId, null, null, input, null); diff --git a/src/WebJobs.Extensions.DurableTask/Correlation/DurableTaskCorrelationTelemetryInitializer.cs b/src/WebJobs.Extensions.DurableTask/Correlation/DurableTaskCorrelationTelemetryInitializer.cs new file mode 100644 index 000000000..c84404484 --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Correlation/DurableTaskCorrelationTelemetryInitializer.cs @@ -0,0 +1,319 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using DurableTask.Core; +using DurableTask.Core.Settings; +using Microsoft.ApplicationInsights.Channel; +using Microsoft.ApplicationInsights.DataContracts; +using Microsoft.ApplicationInsights.Extensibility; +using Microsoft.ApplicationInsights.Extensibility.Implementation; + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation +{ + /// + /// Telemetry Initializer that sets correlation ids for W3C. + /// This source is based on W3COperationCorrelationTelemetryInitializer.cs + /// 1. Modified with CorrelationTraceContext.Current + /// 2. Avoid to be overriden when it is RequestTelemetry + /// Original Source is here https://github.com/microsoft/ApplicationInsights-dotnet-server/blob/2.8.0/Src/Common/W3C/W3COperationCorrelationTelemetryInitializer.cs. + /// + internal + class DurableTaskCorrelationTelemetryInitializer : ITelemetryInitializer + { + private const string RddDiagnosticSourcePrefix = "rdddsc"; + private const string SqlRemoteDependencyType = "SQL"; + + /// These internal property is copied from W3CConstants + /// Trace-Id tag name. + internal const string TraceIdTag = "w3c_traceId"; + + /// Span-Id tag name. + internal const string SpanIdTag = "w3c_spanId"; + + /// Parent span-Id tag name. + internal const string ParentSpanIdTag = "w3c_parentSpanId"; + + /// Version tag name. + internal const string VersionTag = "w3c_version"; + + /// Sampled tag name. + internal const string SampledTag = "w3c_sampled"; + + /// Tracestate tag name. + internal const string TracestateTag = "w3c_tracestate"; + + /// Default version value. + internal const string DefaultVersion = "00"; + + /// + /// Default sampled flag value: may be recorded, not requested. + /// + internal const string TraceFlagRecordedAndNotRequested = "02"; + + /// Recorded and requested sampled flag value. + internal const string TraceFlagRecordedAndRequested = "03"; + + /// Requested trace flag. + internal const byte RequestedTraceFlag = 1; + + /// Legacy root Id tag name. + internal const string LegacyRootIdProperty = "ai_legacyRootId"; + + /// Legacy root Id tag name. + internal const string LegacyRequestIdProperty = "ai_legacyRequestId"; + + /// + /// Constructor. + /// + public DurableTaskCorrelationTelemetryInitializer() + { + this.ExcludeComponentCorrelationHttpHeadersOnDomains = new HashSet(); + } + + /// + /// Set of suppress telemetry tracking if you add Host name on this. + /// + public HashSet ExcludeComponentCorrelationHttpHeadersOnDomains { get; set; } + + /// + /// Initializes telemetry item. + /// + /// Telemetry item. + public void Initialize(ITelemetry telemetry) + { + if (this.IsSuppressedTelemetry(telemetry)) + { + this.SuppressTelemetry(telemetry); + return; + } + + if (!(telemetry is RequestTelemetry)) + { + Activity currentActivity = Activity.Current; + if (telemetry is ExceptionTelemetry) + { + Console.WriteLine("exception!"); + } + + if (currentActivity == null) + { + if (CorrelationTraceContext.Current != null) + { + UpdateTelemetry(telemetry, CorrelationTraceContext.Current); + } + } + else + { + if (CorrelationTraceContext.Current != null) + { + UpdateTelemetry(telemetry, CorrelationTraceContext.Current); + } + else if (CorrelationSettings.Current.Protocol == Protocol.W3CTraceContext) + { + UpdateTelemetry(telemetry, currentActivity, false); + } + else if (CorrelationSettings.Current.Protocol == Protocol.HttpCorrelationProtocol + && telemetry is ExceptionTelemetry) + { + UpdateTelemetryExceptionForHTTPCorrelationProtocol((ExceptionTelemetry)telemetry, currentActivity); + } + } + } + } + + internal static void UpdateTelemetry(ITelemetry telemetry, TraceContextBase contextBase) + { + switch (contextBase) + { + case NullObjectTraceContext nullObjectContext: + return; + case W3CTraceContext w3cContext: + UpdateTelemetryW3C(telemetry, w3cContext); + break; + case HttpCorrelationProtocolTraceContext httpCorrelationProtocolTraceContext: + UpdateTelemetryHttpCorrelationProtocol(telemetry, httpCorrelationProtocolTraceContext); + break; + default: + return; + } + } + + internal static void UpdateTelemetryHttpCorrelationProtocol(ITelemetry telemetry, HttpCorrelationProtocolTraceContext context) + { + OperationTelemetry opTelemetry = telemetry as OperationTelemetry; + + bool initializeFromCurrent = opTelemetry != null; + + if (initializeFromCurrent) + { + initializeFromCurrent &= !(opTelemetry is DependencyTelemetry dependency && + dependency.Type == SqlRemoteDependencyType && + dependency.Context.GetInternalContext().SdkVersion + .StartsWith(RddDiagnosticSourcePrefix, StringComparison.Ordinal)); + } + + if (initializeFromCurrent) + { + opTelemetry.Id = !string.IsNullOrEmpty(opTelemetry.Id) ? opTelemetry.Id : context.TelemetryId; + telemetry.Context.Operation.ParentId = !string.IsNullOrEmpty(telemetry.Context.Operation.ParentId) ? telemetry.Context.Operation.ParentId : context.TelemetryContextOperationParentId; + } + else + { + telemetry.Context.Operation.Id = !string.IsNullOrEmpty(telemetry.Context.Operation.Id) ? telemetry.Context.Operation.Id : context.TelemetryContextOperationId; + if (telemetry is ExceptionTelemetry) + { + telemetry.Context.Operation.ParentId = context.TelemetryId; + } + else + { + telemetry.Context.Operation.ParentId = !string.IsNullOrEmpty(telemetry.Context.Operation.ParentId) ? telemetry.Context.Operation.ParentId : context.TelemetryContextOperationParentId; + } + } + } + + internal static void UpdateTelemetryW3C(ITelemetry telemetry, W3CTraceContext context) + { + OperationTelemetry opTelemetry = telemetry as OperationTelemetry; + + bool initializeFromCurrent = opTelemetry != null; + + if (initializeFromCurrent) + { + initializeFromCurrent &= !(opTelemetry is DependencyTelemetry dependency && + dependency.Type == SqlRemoteDependencyType && + dependency.Context.GetInternalContext().SdkVersion + .StartsWith(RddDiagnosticSourcePrefix, StringComparison.Ordinal)); + } + + if (!string.IsNullOrEmpty(context.TraceState)) + { + opTelemetry.Properties["w3c_tracestate"] = context.TraceState; + } + + TraceParent traceParent = TraceParent.FromString(context.TraceParent); + + if (initializeFromCurrent) + { + if (string.IsNullOrEmpty(opTelemetry.Id)) + { + opTelemetry.Id = traceParent.SpanId; + } + + if (string.IsNullOrEmpty(context.ParentSpanId)) + { + telemetry.Context.Operation.ParentId = telemetry.Context.Operation.Id; + } + } + else + { + if (telemetry.Context.Operation.Id == null) + { + telemetry.Context.Operation.Id = traceParent.TraceId; + } + + if (telemetry.Context.Operation.ParentId == null) + { + telemetry.Context.Operation.ParentId = traceParent.SpanId; + } + } + } + + internal void SuppressTelemetry(ITelemetry telemetry) + { + // TODO For suppressing Dependency, I make the Id as suppressed. This stragey increase the number of telemetery. + // However, new implementation already supressed. Once it fully tested the logic, remove the suppression logic on this class. + telemetry.Context.Operation.Id = "suppressed"; + telemetry.Context.Operation.ParentId = "suppressed"; +#pragma warning disable 618 + + // Context. Properties. ai_legacyRequestId , ai_legacyRequestId + foreach (var key in telemetry.Context.Properties.Keys) + { + if (key == "ai_legacyRootId" || + key == "ai_legacyRequestId") + { + telemetry.Context.Properties[key] = "suppressed"; + } + } +#pragma warning restore 618 + + ((OperationTelemetry)telemetry).Id = "suppressed"; + } + + internal bool IsSuppressedTelemetry(ITelemetry telemetry) + { + OperationTelemetry opTelemetry = telemetry as OperationTelemetry; + if (telemetry is DependencyTelemetry) + { + DependencyTelemetry dTelemetry = telemetry as DependencyTelemetry; +#pragma warning disable 618 + if (!string.IsNullOrEmpty(dTelemetry.CommandName)) + { + var host = new Uri(dTelemetry.CommandName).Host; +#pragma warning restore 618 + if (this.ExcludeComponentCorrelationHttpHeadersOnDomains.Contains(host)) + { + return true; + } + } + } + + return false; + } + + internal static void UpdateTelemetryExceptionForHTTPCorrelationProtocol(ExceptionTelemetry telemetry, Activity activity) + { + telemetry.Context.Operation.ParentId = activity.Id; + telemetry.Context.Operation.Id = activity.RootId; + } + + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "This method has different code for Net45/NetCore")] + internal static void UpdateTelemetry(ITelemetry telemetry, Activity activity, bool forceUpdate) + { + if (activity == null) + { + return; + } + + // Requests and dependencies are initialized from the Activity.Current. + // (i.e. telemetry.Id = current.Id). Activity is created for such requests specifically + // Traces, exceptions, events on the other side are children of current activity + // There is one exception - SQL DiagnosticSource where current Activity is a parent + // for dependency calls. + + OperationTelemetry opTelemetry = telemetry as OperationTelemetry; + bool initializeFromCurrent = opTelemetry != null; + + if (initializeFromCurrent) + { + initializeFromCurrent &= !(opTelemetry is DependencyTelemetry dependency && + dependency.Type == SqlRemoteDependencyType && + dependency.Context.GetInternalContext().SdkVersion + .StartsWith(RddDiagnosticSourcePrefix, StringComparison.Ordinal)); + } + + if (telemetry is OperationTelemetry operation) + { + operation.Properties[TracestateTag] = activity.TraceStateString; + } + + if (initializeFromCurrent) + { + opTelemetry.Id = activity.SpanId.ToHexString(); + if (activity.ParentSpanId != null) + { + opTelemetry.Context.Operation.ParentId = activity.ParentSpanId.ToHexString(); + } + } + else + { + telemetry.Context.Operation.ParentId = activity.SpanId.ToHexString(); + } + } + } +} diff --git a/src/WebJobs.Extensions.DurableTask/Correlation/ITelemetryActivator.cs b/src/WebJobs.Extensions.DurableTask/Correlation/ITelemetryActivator.cs new file mode 100644 index 000000000..1e2071da4 --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Correlation/ITelemetryActivator.cs @@ -0,0 +1,16 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation +{ + /// + /// ITelemetryActivator is an interface. + /// + public interface ITelemetryActivator + { + /// + /// Initialize is initialize the telemetry client. + /// + void Initialize(); + } +} diff --git a/src/WebJobs.Extensions.DurableTask/Correlation/NoOpTelemetryChannel.cs b/src/WebJobs.Extensions.DurableTask/Correlation/NoOpTelemetryChannel.cs new file mode 100644 index 000000000..c7dee9c9c --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Correlation/NoOpTelemetryChannel.cs @@ -0,0 +1,83 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using Microsoft.ApplicationInsights.Channel; + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation +{ + /// + /// A stub of . + /// + public sealed class NoOpTelemetryChannel : ITelemetryChannel + { + /// + /// Initializes a new instance of the class. + /// + public NoOpTelemetryChannel() + { + this.OnSend = telemetry => { }; + this.OnFlush = () => { }; + this.OnDispose = () => { }; + } + + /// + /// Gets or sets a value indicating whether this channel is in developer mode. + /// + public bool? DeveloperMode { get; set; } + + /// + /// Gets or sets a value indicating the channel's URI. To this URI the telemetry is expected to be sent. + /// + public string EndpointAddress { get; set; } + + /// + /// Gets or sets a value indicating whether to throw an error. + /// + public bool ThrowError { get; set; } + + /// + /// Gets or sets the callback invoked by the method. + /// + public Action OnSend { get; set; } + + /// + /// Gets or sets the callback invoked by the method. + /// + public Action OnFlush { get; set; } + + /// + /// Gets or sets the callback invoked by the method. + /// + public Action OnDispose { get; set; } + + /// + /// Implements the method by invoking the callback. + /// + public void Send(ITelemetry item) + { + if (this.ThrowError) + { + throw new Exception("test error"); + } + + this.OnSend(item); + } + + /// + /// Implements the method. + /// + public void Dispose() + { + this.OnDispose(); + } + + /// + /// Implements the method. + /// + public void Flush() + { + this.OnFlush(); + } + } +} diff --git a/src/WebJobs.Extensions.DurableTask/Correlation/TelemetryActivator.cs b/src/WebJobs.Extensions.DurableTask/Correlation/TelemetryActivator.cs new file mode 100644 index 000000000..fde4ca2ca --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Correlation/TelemetryActivator.cs @@ -0,0 +1,99 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using DurableTask.Core; +using DurableTask.Core.Settings; +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.Channel; +using Microsoft.ApplicationInsights.Extensibility; +using Microsoft.Extensions.Options; + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation +{ + /// + /// TelemetryActivator activates Distributed Tracing. This class only works for netstandard2.0. + /// + public class TelemetryActivator : ITelemetryActivator + { + private TelemetryClient telemetryClient; + private IOptions options; + + /// + /// Constructor for activating Distributed Tracing. + /// + /// DurableTask options. + public TelemetryActivator(IOptions options) + { + this.options = options; + } + + /// + /// OnSend is an action that enable to hook of sending telemetry. + /// You can use this property for testing. + /// + public Action OnSend { get; set; } = null; + + /// + /// Initialize is initialize the telemetry client. + /// + public void Initialize() + { + this.SetUpDistributedTracing(); + + this.SetUpTelemetryClient(); + this.SetUpTelemetryCallbacks(); + } + + private void SetUpDistributedTracing() + { + DurableTaskOptions durableTaskOptions = this.options.Value; + CorrelationSettings.Current.EnableDistributedTracing = + durableTaskOptions.Tracing.DistributedTracingEnabled; + CorrelationSettings.Current.Protocol = + durableTaskOptions.Tracing.DistributedTracingProtocol == Protocol.W3CTraceContext.ToString() + ? Protocol.W3CTraceContext + : Protocol.HttpCorrelationProtocol; + } + + private void SetUpTelemetryCallbacks() + { + CorrelationTraceClient.SetUp( + (TraceContextBase requestTraceContext) => + { + requestTraceContext.Stop(); + + var requestTelemetry = requestTraceContext.CreateRequestTelemetry(); + this.telemetryClient.TrackRequest(requestTelemetry); + }, + (TraceContextBase dependencyTraceContext) => + { + dependencyTraceContext.Stop(); + var dependencyTelemetry = dependencyTraceContext.CreateDependencyTelemetry(); + this.telemetryClient.TrackDependency(dependencyTelemetry); + }, + (Exception e) => + { + this.telemetryClient.TrackException(e); + }); + } + + private void SetUpTelemetryClient() + { + TelemetryConfiguration config = TelemetryConfiguration.CreateDefault(); + if (this.OnSend != null) + { + config.TelemetryChannel = new NoOpTelemetryChannel { OnSend = this.OnSend }; + } + + var telemetryInitializer = new DurableTaskCorrelationTelemetryInitializer(); + + telemetryInitializer.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("127.0.0.1"); + config.TelemetryInitializers.Add(telemetryInitializer); + + config.InstrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY"); + + this.telemetryClient = new TelemetryClient(config); + } + } +} \ No newline at end of file diff --git a/src/WebJobs.Extensions.DurableTask/Correlation/TraceContextBaseExtensions.cs b/src/WebJobs.Extensions.DurableTask/Correlation/TraceContextBaseExtensions.cs new file mode 100644 index 000000000..d0562d5b9 --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Correlation/TraceContextBaseExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using DurableTask.Core; +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.DataContracts; + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation +{ + /// + /// TraceContextBase extension methods. + /// + public static class TraceContextBaseExtensions + { + /// + /// Create RequestTelemetry from the TraceContext. + /// + /// TraceContext. + /// RequestTelemetry. + public static RequestTelemetry CreateRequestTelemetry(this TraceContextBase context) + { + var telemetry = new RequestTelemetry { Name = context.OperationName }; + telemetry.Duration = context.Duration; + telemetry.Timestamp = context.StartTime; + telemetry.Id = context.TelemetryId; + telemetry.Context.Operation.Id = context.TelemetryContextOperationId; + telemetry.Context.Operation.ParentId = context.TelemetryContextOperationParentId; + + return telemetry; + } + + /// + /// Create DependencyTelemetry from the Activity. + /// + /// TraceContext. + /// DependencyTelemetry. + public static DependencyTelemetry CreateDependencyTelemetry(this TraceContextBase context) + { + var telemetry = new DependencyTelemetry { Name = context.OperationName }; + telemetry.Start(); + telemetry.Duration = context.Duration; + telemetry.Timestamp = context.StartTime; // TimeStamp is the time of ending the Activity. + telemetry.Id = context.TelemetryId; + telemetry.Context.Operation.Id = context.TelemetryContextOperationId; + telemetry.Context.Operation.ParentId = context.TelemetryContextOperationParentId; + + return telemetry; + } + } +} diff --git a/src/WebJobs.Extensions.DurableTask/Correlation/TraceParent.cs b/src/WebJobs.Extensions.DurableTask/Correlation/TraceParent.cs new file mode 100644 index 000000000..51cdbb387 --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Correlation/TraceParent.cs @@ -0,0 +1,62 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation +{ + /// + /// Represents a traceParent that is defined W3C TraceContext. + /// + public class TraceParent + { + /// + /// Gets or sets the Version of the traceParent. + /// + public string Version { get; set; } + + /// + /// Gets or sets the TraceId of the traceParent. + /// + public string TraceId { get; set; } + + /// + /// Gets or sets the SpanId of the traceParent. + /// + public string SpanId { get; set; } + + /// + /// Gets or sets the TraceFlags of the traceParent. + /// + public string TraceFlags { get; set; } + + /// + /// Convert a traceParent string to TraceParent object. + /// + /// string representations of traceParent. + /// TraceParent object. + public static TraceParent FromString(string traceparent) + { + var exceptionString = + $"Traceparent doesn't respect the spec. spec: {{version}}-{{traceId}}-{{spanId}}-{{traceFlags}} actual: {traceparent}"; + if (!string.IsNullOrEmpty(traceparent)) + { + var substrings = traceparent.Split('-'); + if (substrings.Length != 4) + { + throw new ArgumentException(exceptionString); + } + + return new TraceParent + { + Version = substrings[0], + TraceId = substrings[1], + SpanId = substrings[2], + TraceFlags = substrings[3], + }; + } + + throw new ArgumentException(exceptionString); + } + } +} diff --git a/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs b/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs index 150932152..8b6b09d2d 100644 --- a/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs +++ b/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs @@ -17,6 +17,9 @@ using DurableTask.Core.History; using DurableTask.Core.Middleware; using Microsoft.Azure.WebJobs.Description; +#if !FUNCTIONS_V1 +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation; +#endif using Microsoft.Azure.WebJobs.Host; using Microsoft.Azure.WebJobs.Host.Config; using Microsoft.Azure.WebJobs.Host.Executors; @@ -58,7 +61,11 @@ public class DurableTaskExtension : new ConcurrentDictionary(); private readonly AsyncLock taskHubLock = new AsyncLock(); - +#if !FUNCTIONS_V1 +#pragma warning disable CS0169 + private readonly ITelemetryActivator telemetryActivator; +#pragma warning restore CS0169 +#endif private readonly bool isOptionsConfigured; private IDurabilityProviderFactory durabilityProviderFactory; private INameResolver nameResolver; @@ -81,7 +88,7 @@ public DurableTaskExtension() this.isOptionsConfigured = false; } #endif - +#pragma warning disable CS1572 /// /// Initializes a new instance of the . /// @@ -94,6 +101,8 @@ public DurableTaskExtension() /// The lifecycle notification helper used for custom orchestration tracking. /// The factory used to create for message settings. /// The factory used to create for error settings. + /// The activator of DistributedTracing. .netstandard2.0 only. +#pragma warning restore CS1572 public DurableTaskExtension( IOptions options, ILoggerFactory loggerFactory, @@ -103,7 +112,14 @@ public DurableTaskExtension( IDurableHttpMessageHandlerFactory durableHttpMessageHandlerFactory = null, ILifeCycleNotificationHelper lifeCycleNotificationHelper = null, IMessageSerializerSettingsFactory messageSerializerSettingsFactory = null, +#if !FUNCTIONS_V1 + IErrorSerializerSettingsFactory errorSerializerSettingsFactory = null, +#pragma warning disable SA1113, SA1001, SA1115 + ITelemetryActivator telemetryActivator = null) +#pragma warning restore SA1113, SA1001, SA1115 +#else IErrorSerializerSettingsFactory errorSerializerSettingsFactory = null) +#endif { // Options will be null in Functions v1 runtime - populated later. this.Options = options?.Value ?? new DurableTaskOptions(); @@ -149,6 +165,8 @@ public DurableTaskExtension( // The RPC server is started when the extension is initialized. // The RPC server is stopped when the host has finished shutting down. hostLifetimeService.OnStopped.Register(this.StopLocalRcpServer); + this.telemetryActivator = telemetryActivator; + this.telemetryActivator?.Initialize(); #endif } diff --git a/src/WebJobs.Extensions.DurableTask/DurableTaskJobHostConfigurationExtensions.cs b/src/WebJobs.Extensions.DurableTask/DurableTaskJobHostConfigurationExtensions.cs index 359dbde79..8fc4eec47 100644 --- a/src/WebJobs.Extensions.DurableTask/DurableTaskJobHostConfigurationExtensions.cs +++ b/src/WebJobs.Extensions.DurableTask/DurableTaskJobHostConfigurationExtensions.cs @@ -5,6 +5,7 @@ using System.Net.Http; using System.Threading; #if !FUNCTIONS_V1 +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; @@ -43,6 +44,9 @@ public static IWebJobsBuilder AddDurableTask(this IWebJobsBuilder builder) serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); +#if !FUNCTIONS_V1 + serviceCollection.AddSingleton(); +#endif return builder; } diff --git a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask-net461.xml b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask-net461.xml index 7e760a467..e7c7a743e 100644 --- a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask-net461.xml +++ b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask-net461.xml @@ -1395,6 +1395,62 @@ Now obsolete: use instead. + + + A stub of . + This is the copy of the https://github.com/Microsoft/ApplicationInsights-dotnet/Test/TestFramework/Shared/StubTelemetryClient + + + + + Initializes a new instance of the class. + + + + + Gets or sets a value indicating whether this channel is in developer mode. + + + + + Gets or sets a value indicating the channel's URI. To this URI the telemetry is expected to be sent. + + + + + Gets or sets a value indicating whether to throw an error. + + + + + Gets or sets the callback invoked by the method. + + + + + Implements the method by invoking the callback. + + + + + Implements the method. + + + + + Implements the method. + + + + + ITelemetryActivator is an interface. + + + + + Initialize is initialize the telemetry client. + + Attribute used with the Durable Functions Analyzer to label a method as Deterministic. This allows the method to be called in an Orchestration function without causing a compiler warning. @@ -1892,6 +1948,7 @@ The lifecycle notification helper used for custom orchestration tracking. The factory used to create for message settings. The factory used to create for error settings. + The activator of DistributedTracing. .netstandard2.0 only. @@ -3362,6 +3419,19 @@ Boolean value specifying if the replay events should be logged. + + + Gets or sets a flag indicating whether to disable distributed tracing. + The default value is false. + + + + + Gets or sets a protocol for distributed Tracing. + Possible values are "HttpCorrelationProtocol" and "W3CTraceContext". + The default value is "HttpCorrelationProtocol". + + Represents the possible runtime execution status values for an orchestration instance. diff --git a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry-net461.xml b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry-net461.xml new file mode 100644 index 000000000..33da85dc2 --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry-net461.xml @@ -0,0 +1,3721 @@ + + + + Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry + + + + + The Azure Storage implementation of additional methods not required by IOrchestrationService. + + + + + The app setting containing the Azure Storage connection string. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The default parameter type for activity functions. + + + + + + + + Returns the input of the task activity in its raw JSON string value. + + + The raw JSON-formatted activity input as a string value. + + + + + Gets the input of the current activity function instance as a JToken. + + + The parsed JToken representation of the activity input. + + + + + + + + Sets the JSON-serializeable output of the activity function. + + + If this method is not called explicitly, the return value of the activity function is used as the output. + + + The JSON-serializeable value to use as the activity function output. + + + + + Client for starting, querying, terminating, and raising events to orchestration instances. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Common functionality used by both + and . + + + + + Context object passed to application code executing entity operations. + + + + + Parameter data for orchestration bindings that can be used to schedule function-based activities. + + + + + + + + + + + + + + + + + + + + Returns the orchestrator function input as a raw JSON string value. + + + The raw JSON-formatted orchestrator function input. + + + + + Gets the input of the current orchestrator function instance as a JToken. + + + The parsed JToken representation of the orchestrator function input. + + + + + + + + Sets the JSON-serializeable output of the current orchestrator function. + + + If this method is not called explicitly, the return value of the orchestrator function is used as the output. + + The JSON-serializeable value to use as the orchestrator function output. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines convenient overloads for calling the context methods, for all the contexts. + + + + + Schedules an activity function named for execution. + + The context object. + The name of the activity function to call. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an activity function named for execution with retry options. + + The context object. + The name of the activity function to call. + The retry option for the activity function. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called activity function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution. + + The context object. + The name of the orchestrator function to call. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The sub-orchestrator function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution. + + The context object. + The name of the orchestrator function to call. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestration function named for execution. + + The return type of the scheduled orchestrator function. + The context object. + The name of the orchestrator function to call. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The context object. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The context object. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The return type of the scheduled orchestrator function. + The context object. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Creates a durable timer that expires at a specified time. + + + All durable timers created using this method must either expire or be cancelled + using the before the orchestrator function completes. + Otherwise the underlying framework will keep the instance alive until the timer expires. + + The context object. + The time at which the timer should expire. + The CancellationToken to use for cancelling the timer. + A durable task that completes when the durable timer expires. + + + + Waits asynchronously for an event to be raised with name . + + + External clients can raise events to a waiting orchestration instance using + with the object parameter set to null. + + The context object. + The name of the event to wait for. + A durable task that completes when the external event is received. + + + + Waits asynchronously for an event to be raised with name . + + + External clients can raise events to a waiting orchestration instance using + with the object parameter set to null. + + The context object. + The name of the event to wait for. + The duration after which to throw a TimeoutException. + A durable task that completes when the external event is received. + + The external event was not received before the timeout expired. + + + + + Calls an operation on an entity and returns the result asynchronously. + + The JSON-serializable result type of the operation. + The context object. + The target entity. + The name of the operation. + A task representing the result of the operation. + + + + Calls an operation on an entity and waits for it to complete. + + The context object. + The target entity. + The name of the operation. + A task representing the completion of the operation on the entity. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the default 10 second timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within this timeout, then the HTTP response will be identical to that of the + API. + + The client object. + The HTTP request that triggered the current function. + The unique ID of the instance to check. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The client object. + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Starts a new execution of the specified orchestrator function. + + The client object. + The name of the orchestrator function to start. + The ID to use for the new orchestration instance. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Starts a new execution of the specified orchestrator function. + + The client object. + The name of the orchestrator function to start. + JSON-serializeable input value for the orchestrator function. + The type of the input value for the orchestrator function. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Starts a new execution of the specified orchestrator function. + + The client object. + The name of the orchestrator function to start. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Sends an event notification message to a waiting orchestration instance. + + + + In order to handle the event, the target orchestration instance must be waiting for an + event named using the + API. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The client object. + The ID of the orchestration instance that will handle the event. + The name of the event. + A task that completes when the event notification message has been enqueued. + + + + Gets the status of the specified orchestration instance. + + The client object. + The ID of the orchestration instance to query. + Returns a task which completes when the status has been fetched. + + + + Gets the status of the specified orchestration instance. + + The client object. + The ID of the orchestration instance to query. + Boolean marker for including execution history in the response. + Returns a task which completes when the status has been fetched. + + + + Returns an instance of ILogger that is replay safe, ensuring the logger logs only when the orchestrator + is not replaying that line of code. + + The context object. + An instance of ILogger. + An instance of a replay safe ILogger. + + + + Provides functionality available to durable activities. + + + + + Gets the instance ID of the currently executing orchestration. + + + The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The ID of the current orchestration instance. + + + + + Gets the input of the current activity function as a deserialized value. + + Any data contract type that matches the JSON input. + The deserialized input value. + + + + Provides functionality available to durable orchestration and entity clients. + + + + + Gets the name of the task hub configured on this client instance. + + + The name of the task hub. + + + + + Provides functionality available to durable entity clients. + + + + + Gets the name of the task hub configured on this client instance. + + + The name of the task hub. + + + + + Signals an entity to perform an operation. + + The target entity. + The name of the operation. + The input for the operation. + The TaskHubName of the target entity. + The name of the connection string associated with . + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation, at a specified time. + + The target entity. + The time at which to start the operation. + The name of the operation. + The input for the operation. + The TaskHubName of the target entity. + The name of the connection string associated with . + A task that completes when the message has been reliably enqueued. + + + + Tries to read the current state of an entity. Returns default() if the entity does not + exist, or if the JSON-serialized state of the entity is larger than 16KB. + + The JSON-serializable type of the entity. + The target entity. + The TaskHubName of the target entity. + The name of the connection string associated with . + a response containing the current state of the entity. + + + + Gets the status of all entity instances with paging that match the specified query conditions. + + Return entity instances that match the specified query conditions. + Cancellation token that can be used to cancel the query operation. + Returns a page of entity instances and a continuation token for fetching the next page. + + + + Provides functionality for application code implementing an entity operation. + + + + + Gets the name of the currently executing entity. + + + + + Gets the key of the currently executing entity. + + + + + Gets the id of the currently executing entity. + + + + + Gets the name of the operation that was called. + + + An operation invocation on an entity includes an operation name, which states what + operation to perform, and optionally an operation input. + + + + + Whether this entity has a state. + + + + + Gets the current state of this entity, for reading and/or updating. + If this entity has no state yet, creates it. + + The JSON-serializable type of the entity state. + Provides an initial value to use for the state, instead of default(). + The current state of this entity. + If the current state has an incompatible type. + + + + Sets the current state of this entity. + + The JSON-serializable state of the entity. + + + + Deletes the state of this entity. + + + + + Gets the input for this operation, as a deserialized value. + + The JSON-serializable type used for the operation input. + The operation input, or default() if none. + + An operation invocation on an entity includes an operation name, which states what + operation to perform, and optionally an operation input. + + + + + Gets the input for this operation, as a deserialized value. + + The JSON-serializable type used for the operation input. + The operation input, or default() if none. + + An operation invocation on an entity includes an operation name, which states what + operation to perform, and optionally an operation input. + + + + + Returns the given result to the caller of this operation. + + the result to return. + + + + Signals an entity to perform an operation, without waiting for a response. Any result or exception is ignored (fire and forget). + + The target entity. + The name of the operation. + The operation input. + + + + Signals an entity to perform an operation, at a specified time. Any result or exception is ignored (fire and forget). + + The target entity. + The time at which to start the operation. + The name of the operation. + The input for the operation. + + + + Schedules a orchestration function named for execution./>. + Any result or exception is ignored (fire and forget). + + The name of the orchestrator function to call. + the input to pass to the orchestrator function. + optionally, an instance id for the orchestration. By default, a random GUID is used. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + The instance id of the new orchestration. + + + + Provides functionality available to durable orchestration clients. + + + + + Gets the name of the task hub configured on this client instance. + + + The name of the task hub. + + + + + Creates an HTTP response that is useful for checking the status of the specified instance. + + + The payload of the returned contains HTTP API URLs that can + be used to query the status of the orchestration, raise events to the orchestration, or + terminate the orchestration. + + The HTTP request that triggered the current orchestration instance. + The ID of the orchestration instance to check. + Optional parameter that configures the http response code returned. Defaults to false. + If true, the returned http response code will be a 500 when the orchestrator is in a failed state, when false it will + return 200. + An HTTP 202 response with a Location header and a payload containing instance control URLs. + + + + Creates an HTTP response that is useful for checking the status of the specified instance. + + + The payload of the returned contains HTTP API URLs that can + be used to query the status of the orchestration, raise events to the orchestration, or + terminate the orchestration. + + The HTTP request that triggered the current orchestration instance. + The ID of the orchestration instance to check. + Optional parameter that configures the http response code returned. Defaults to false. + If true, the returned http response code will be a 500 when the orchestrator is in a failed state, when false it will + return 200. + An HTTP 202 response with a Location header and a payload containing instance control URLs. + + + + Creates a object that contains status, terminate and send external event HTTP endpoints. + + The ID of the orchestration instance to check. + Instance of the class. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + The timeout between checks for output from the durable function. The default value is 1 second. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + The timeout between checks for output from the durable function. The default value is 1 second. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Starts a new instance of the specified orchestrator function. + + + If an orchestration instance with the specified ID already exists, the existing instance + will be silently replaced by this new instance. + + The name of the orchestrator function to start. + The ID to use for the new orchestration instance. + JSON-serializeable input value for the orchestrator function. + The type of the input value for the orchestrator function. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Sends an event notification message to a waiting orchestration instance. + + + + In order to handle the event, the target orchestration instance must be waiting for an + event named using the + API. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The ID of the orchestration instance that will handle the event. + The name of the event. + The JSON-serializeable data associated with the event. + A task that completes when the event notification message has been enqueued. + + + + Sends an event notification message to a waiting orchestration instance. + + + + In order to handle the event, the target orchestration instance must be waiting for an + event named using the + API. + + If the specified instance is not found or not running, this operation will throw an exception. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The TaskHubName of the orchestration that will handle the event. + The ID of the orchestration instance that will handle the event. + The name of the event. + The JSON-serializeable data associated with the event. + The name of the connection string associated with . + A task that completes when the event notification message has been enqueued. + + + + Terminates a running orchestration instance. + + + + A terminated instance will eventually transition into the state. + However, this transition will not happen immediately. Rather, the terminate operation will be queued in the task hub + along with other operations for that instance. You can use the + method to know when a terminated instance has actually reached the Terminated state. + + + Terminating an orchestration instance has no effect on any in-flight activity function executions + or sub-orchestrations that were started by the current orchestration instance. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The ID of the orchestration instance to terminate. + The reason for terminating the orchestration instance. + A task that completes when the terminate message is enqueued if necessary. + + + + Rewinds the specified failed orchestration instance with a reason. + + The ID of the orchestration instance to rewind. + The reason for rewinding the orchestration instance. + A task that completes when the rewind message is enqueued. + + + + Gets the status of the specified orchestration instance. + + The ID of the orchestration instance to query. + Boolean marker for including execution history in the response. + Boolean marker for including input and output in the execution history response. + If set, fetch and return the input for the orchestration instance. + Returns a task which completes when the status has been fetched. + + + + Gets all the status of the orchestration instances. + + Cancellation token that can be used to cancel the status query operation. + Returns orchestration status for all instances. + + + + Gets the status of all orchestration instances that match the specified conditions. + + Return orchestration instances which were created after this DateTime. + Return orchestration instances which were created before this DateTime. + Return orchestration instances which matches the runtimeStatus. + Cancellation token that can be used to cancel the status query operation. + Returns orchestration status for all instances. + + + + Purge the history for a concrete instance. + + The ID of the orchestration instance to purge. + Returns an instance of . + + + + Purge the orchestration history for instances that match the conditions. + + Start creation time for querying instances for purging. + End creation time for querying instances for purging. + List of runtime status for querying instances for purging. Only Completed, Terminated, or Failed will be processed. + Returns an instance of . + + + + Gets the status of all orchestration instances with paging that match the specified conditions. + + Return orchestration instances that match the specified conditions. + Cancellation token that can be used to cancel the status query operation. + Returns each page of orchestration status for all instances and continuation token of next page. + + + + Gets the status of all orchestration instances with paging that match the specified conditions. + + Return orchestration instances that match the specified conditions. + Cancellation token that can be used to cancel the status query operation. + Returns each page of orchestration status for all instances and continuation token of next page. + + + + Provides functionality available to orchestration code. + + + + + Gets the name of the current orchestration function. + + + + + Gets the instance ID of the currently executing orchestration. + + + The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The ID of the current orchestration instance. + + + + + Gets the parent instance ID of the currently executing sub-orchestration. + + + The parent instance ID is generated and fixed when the parent orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The ID of the parent orchestration of the current sub-orchestration instance. The value will be available only in sub-orchestrations. + + + + + Gets the current date/time in a way that is safe for use in orchestrations and entity operations. + + + This date/time value is derived from the orchestration or entity history. It always returns the same value + at specific points in the orchestrator function code, making it deterministic and safe for replay. + + The orchestration or entity's current date/time in UTC. + + + + Gets a value indicating whether the orchestration or operation is currently replaying itself. + + + This property is useful when there is logic that needs to run only when *not* replaying. For example, certain types of application logging may become too noisy when duplicated + as part of replay. The application code could check to see whether the function is + being replayed and then issue the log statements when this value is false. + + + true if the orchestration or operation is currently being replayed; otherwise false. + + + + + Gets the input of the current orchestrator function as a deserialized value. + + Any data contract type that matches the JSON input. + The deserialized input value. + + + + Sets the output for the current orchestration. + + The JSON-serializeable output of the orchestration. + + + + Restarts the orchestration by clearing its history. + + + Large orchestration histories can consume a lot of memory and cause delays in + instance load times. This method can be used to periodically truncate the stored + history of an orchestration instance. + Note that any unprocessed external events will be discarded when an orchestration + instance restarts itself using this method. + + The JSON-serializeable data to re-initialize the instance with. + + If set to true, re-adds any unprocessed external events into the new execution + history when the orchestration instance restarts. If false, any unprocessed + external events will be discarded when the orchestration instance restarts. + + + + + Sets the JSON-serializeable status of the current orchestrator function. + + + The value is serialized to JSON and will + be made available to the orchestration status query APIs. The serialized JSON + value must not exceed 16 KB of UTF-16 encoded text. + + The JSON-serializeable value to use as the orchestrator function's custom status. + + + + Makes an HTTP call to the specified uri. + + HttpMethod used for api call. + uri used to make the HTTP call. + Content passed in the HTTP request. + A Result of the HTTP call. + + + + Makes an HTTP call using the information in the DurableHttpRequest. + + The DurableHttpRequest used to make the HTTP call. + A Result of the HTTP call. + + + + Calls an operation on an entity, passing an argument, and returns the result asynchronously. + + The JSON-serializable result type of the operation. + The target entity. + The name of the operation. + The input for the operation. + A task representing the result of the operation. + if the context already holds some locks, but not the one for . + + + + Calls an operation on an entity, passing an argument, and waits for it to complete. + + The target entity. + The name of the operation. + The input for the operation. + A task representing the completion of the operation on the entity. + if the context already holds some locks, but not the one for . + + + + Schedules an orchestration function named for execution. + + The return type of the scheduled orchestrator function. + The name of the orchestrator function to call. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The return type of the scheduled orchestrator function. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Creates a durable timer that expires at a specified time. + + + All durable timers created using this method must either expire or be cancelled + using the before the orchestrator function completes. + Otherwise the underlying framework will keep the instance alive until the timer expires. + + The type of . + The time at which the timer should expire. + Any state to be preserved by the timer. + The CancellationToken to use for cancelling the timer. + A durable task that completes when the durable timer expires. + + + + Waits asynchronously for an event to be raised with name and returns the event data. + + + External clients can raise events to a waiting orchestration instance using + . + + The name of the event to wait for. + Any serializeable type that represents the JSON event payload. + A durable task that completes when the external event is received. + + + + Waits asynchronously for an event to be raised with name and returns the event data. + + + External clients can raise events to a waiting orchestration instance using + . + + The name of the event to wait for. + The duration after which to throw a TimeoutException. + Any serializeable type that represents the JSON event payload. + A durable task that completes when the external event is received. + + The external event was not received before the timeout expired. + + + + + Waits asynchronously for an event to be raised with name and returns the event data. + + + External clients can raise events to a waiting orchestration instance using + . + + The name of the event to wait for. + The duration after which to return the value in the parameter. + The default value to return if the timeout expires before the external event is received. + Any serializeable type that represents the JSON event payload. + A durable task that completes when the external event is received, or returns the value of + if the timeout expires. + + + + Acquires one or more locks, for the specified entities. + + + Locks can only be acquired if the current context does not hold any locks already. + + The entities whose locks should be acquired. + An IDisposable that releases the lock when disposed. + if the context already holds some locks. + + + + Determines whether the current context is locked, and if so, what locks are currently owned. + + The collection of owned locks. + + Note that the collection of owned locks can be empty even if the context is locked. This happens + if an orchestration calls a suborchestration without lending any locks. + + true if the context already holds some locks. + + + + Creates a new GUID that is safe for replay within an orchestration or operation. + + + The default implementation of this method creates a name-based UUID using the algorithm from + RFC 4122 §4.3. The name input used to generate this value is a combination of the orchestration + instance ID and an internally managed sequence number. + + The new value. + + + + Schedules an activity function named for execution. + + The return type of the scheduled activity function. + The name of the activity function to call. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called activity function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an activity function named for execution with retry options. + + The return type of the scheduled activity function. + The name of the activity function to call. + The retry option for the activity function. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called activity function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Signals an entity to perform an operation, without waiting for a response. Any result or exception is ignored (fire and forget). + + The target entity. + The name of the operation. + The input for the operation. + + + + Signals an operation to be performed by an entity at a specified time. Any result or exception is ignored (fire and forget). + + The target entity. + The time at which to start the operation. + The name of the operation. + The input for the operation. + + + + Schedules a orchestration function named for execution./>. + Any result or exception is ignored (fire and forget). + + The name of the orchestrator function to call. + the input to pass to the orchestrator function. + optionally, an instance id for the orchestration. By default, a random GUID is used. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + The instance id of the new orchestration. + + + + Formerly, the abstract base class for DurableOrchestrationContext. + Now obsolete: use instead. + + + + + Formerly, the abstract base class for DurableActivityContext. + Now obsolete: use instead. + + + + + Formerly, the abstract base class for DurableOrchestrationClient. + Now obsolete: use instead. + + + + + Attribute used with the Durable Functions Analyzer to label a method as Deterministic. This allows the method to be called in an Orchestration function without causing a compiler warning. + + + + + The backend storage provider that provides the actual durability of Durable Functions. + This is functionally a superset of and . + If the storage provider does not any of the Durable Functions specific operations, they can use this class + directly with the expectation that only those interfaces will be implemented. All of the Durable Functions specific + methods/operations are virtual and can be overwritten by creating a subclass. + + + + + Creates the default . + + The name of the storage backend providing the durability. + The internal that provides functionality + for this classes implementions of . + The internal that provides functionality + for this classes implementions of . + The name of the app setting that stores connection details for the storage provider. + + + + The name of the environment variable that contains connection details for how to connect to storage providers. + Corresponds to the for binding data. + + + + + Specifies whether the durability provider supports Durable Entities. + + + + + JSON representation of configuration to emit in telemetry. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the status of all orchestration instances. + + A token to cancel the request. + Returns a task which completes when the status has been fetched. + + + + Gets the status of all orchestration instances within the specified parameters. + + Return orchestration instances which were created after this DateTime. + Return orchestration instances which were created before this DateTime. + Return orchestration instances which matches the runtimeStatus. + A token to cancel the request. + Returns a task which completes when the status has been fetched. + + + + Gets the state of the specified orchestration instance. + + The ID of the orchestration instance to query. + If set, fetch and return the input for the orchestration instance. + Returns a task which completes when the state has been fetched. + + + + Gets paginated result of all orchestration instances that match query status parameters. + + The filtering conditions of the query. + A token to cancel the request. + Paginated result of orchestration state. + + + + Purges history that meet the required parameters. + + Purge the history of orchestration instances which were created after this DateTime. + Purge the history of orchestration instances which were created before this DateTime. + Purge the history of orchestration instances which matches the runtimeStatus. + The number of instances purged. + + + + Purges the instance history for the provided instance id. + + The instance id for the instance history to purge. + The number of instances purged. + + + + Retrieves the state for a serialized entity. + + Entity id to fetch state for. + JsonSerializerSettings for custom deserialization. + State for the entity. + + + + Rewinds the specified failed orchestration instance with a reason. + + The ID of the orchestration instance to rewind. + The reason for rewinding the orchestration instance. + A task that completes when the rewind message is enqueued. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Uses durability provider specific logic to verify whether a timespan for a timer, timeout + or retry interval is allowed by the provider. + + The timespan that the code will have to wait for. + The error message if the timespan is invalid. + A boolean indicating whether the time interval is valid. + + + + Attribute used to bind a function parameter to a , , or instance. + + + + + Optional. Gets or sets the name of the task hub in which the orchestration data lives. + + The task hub used by this binding. + + The default behavior is to use the task hub name specified in . + If no value exists there, then a default value will be used. + + + + + Optional. Gets or sets the setting name for the app setting containing connection details used by this binding to connect + to instances of the storage provider other than the default one this application communicates with. + + The name of an app setting containing connection details. + + For Azure Storage the default behavior is to use the value of . + If no value exists there, then the default behavior is to use the standard `AzureWebJobsStorage` connection string for all storage usage. + + + + + Returns a hash code for this attribute. + + A hash code for this attribute. + + + + Compares two instances for value equality. + + The object to compare with. + true if the two attributes have the same configuration; otherwise false. + + + + Compares two instances for value equality. + + The object to compare with. + true if the two attributes have the same configuration; otherwise false. + + + + Represents the status of a durable entity instance. + + + + + Gets the EntityId of the queried entity instance. + + + The unique EntityId of the instance. + + + + + Gets the time of the last operation processed by the entity instance. + + + The last operation time in UTC. + + + + + Gets the state of the entity instance. + + + The state as either a JToken or null if no state was provided. + + + + + Request used to make an HTTP call through Durable Functions. + + + + + Initializes a new instance of the class. + + Method used for HTTP request. + Uri used to make the HTTP request. + Headers added to the HTTP request. + Content added to the body of the HTTP request. + AAD authentication attached to the HTTP request. + Specifies whether the DurableHttpRequest should handle the asynchronous pattern. + + + + HttpMethod used in the HTTP request made by the Durable Function. + + + + + Uri used in the HTTP request made by the Durable Function. + + + + + Headers passed with the HTTP request made by the Durable Function. + + + + + Content passed with the HTTP request made by the Durable Function. + + + + + Mechanism for attaching an OAuth token to the request. + + + + + Specifies whether the Durable HTTP APIs should automatically + handle the asynchronous HTTP pattern. + + + + + Response received from the HTTP request made by the Durable Function. + + + + + Initializes a new instance of the class. + + HTTP Status code returned from the HTTP call. + Headers returned from the HTTP call. + Content returned from the HTTP call. + + + + Status code returned from an HTTP request. + + + + + Headers in the response from an HTTP request. + + + + + Content returned from an HTTP request. + + + + + Creates a DurableHttpResponse from an HttpResponseMessage. + + HttpResponseMessage returned from the HTTP call. + A representing the result of the asynchronous operation. + + + + Represents the status of a durable orchestration instance. + + + An external client can fetch the status of an orchestration instance using + . + + + + + Gets the name of the queried orchestrator function. + + + The orchestrator function name. + + + + + Gets the ID of the queried orchestration instance. + + + The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The unique ID of the instance. + + + + + Gets the time at which the orchestration instance was created. + + + If the orchestration instance is in the + status, this time represents the time at which the orchestration instance was scheduled. + + + The instance creation time in UTC. + + + + + Gets the time at which the orchestration instance last updated its execution history. + + + The last-updated time in UTC. + + + + + Gets the input of the orchestrator function instance. + + + The input as either a JToken or null if no input was provided. + + + + + Gets the output of the queried orchestration instance. + + + The output as either a JToken object or null if it has not yet completed. + + + + + Gets the runtime status of the queried orchestration instance. + + + Expected values include `Running`, `Pending`, `Failed`, `Canceled`, `Terminated`, `Completed`. + + + + + Gets the custom status payload (if any) that was set by the orchestrator function. + + + Orchestrator functions can set a custom status using . + + + The custom status as either a JToken object or null if no custom status has been set. + + + + + Gets the execution history of the orchestration instance. + + + The history log can be large and is therefore null by default. + It is populated only when explicitly requested in the call to + . + + + The output as a JArray object or null. + + + + + Configuration for the Durable Functions extension. + + + + + Obsolete. Please use an alternate constructor overload. + + + + + Initializes a new instance of the . + + The configuration options for this extension. + The logger factory used for extension-specific logging and orchestration tracking. + The name resolver to use for looking up application settings. + The factory used to create orchestration service based on the configured storage provider. + The HTTP message handler that handles HTTP requests and HTTP responses. + The host shutdown notification service for detecting and reacting to host shutdowns. + The lifecycle notification helper used for custom orchestration tracking. + The factory used to create for message settings. + The factory used to create for error settings. + The activator of DistributedTracing. .netstandard2.0 only. + + + + Gets or sets default task hub name to be used by all , , , + , and instances. + + + A task hub is a logical grouping of storage resources. Alternate task hub names can be used to isolate + multiple Durable Functions applications from each other, even if they are using the same storage backend. + + The name of the default task hub. + + + + Internal initialization call from the WebJobs host. + + Extension context provided by WebJobs. + + + + + + + Deletes all data stored in the current task hub. + + A task representing the async delete operation. + + + + Called by the Durable Task Framework: Not used. + + This parameter is not used. + + + + Called by the Durable Task Framework: Returns the specified . + + The name of the orchestration to return. + Not used. + An orchestration shim that delegates execution to an orchestrator function. + + + + Called by the durable task framework: Not used. + + This parameter is not used. + + + + Called by the Durable Task Framework: Returns the specified . + + The name of the activity to return. + Not used. + An activity shim that delegates execution to an activity function. + + + + Gets a using configuration from a instance. + + The attribute containing the client configuration parameters. + Returns a instance. The returned instance may be a cached instance. + + + + + + + Extension for registering a Durable Functions configuration with JobHostConfiguration. + + + + + Enable running durable orchestrations implemented as functions. + + Configuration settings of the current JobHost instance. + Durable Functions configuration. + + + + Query condition for searching the status of entity instances. + + + + + Return entity instances associated with this entity name. + + + + + Return entity instances which had operations after this DateTime. + + + + + Return entity instances which had operations before this DateTime. + + + + + Number of records per one request. The default value is 100. + + + + + ContinuationToken of the pager. + + + + + Determines whether the query will include the state of the entity. + + + + + The status of all entity instances with paging for a given query. + + + + + Gets or sets a collection of statuses of entity instances matching the query description. + + A collection of entity instance status values. + + + + Gets or sets a token that can be used to resume the query with data not already returned by this query. + + A server-generated continuation token or null if there are no further continuations. + + + + Statically accessible context for entity operations. + + + + + The context of the currently executing entity. + + + + + Sets the current context to a mocked context for unit testing. + + The mocked context. + + + + Information about the current status of an operation executing on an entity. + Excludes potentially large data (such as the operation input) so it can be read with low latency. + + + + + The name of the operation. + + + + + The unique identifier for this operation. + + + + + The parent instance that called this operation. + + + + + The UTC time at which the entity started processing this operation. + + + + + A unique identifier for an entity, consisting of entity name and entity key. + + + + + Create an entity id for an entity. + + The name of this class of entities. + The entity key. + + + + The name for this class of entities. + + + + + The entity key. Uniquely identifies an entity among all entities of the same name. + + + + + + + + + + + + + + + + + + + + Determines event names to use for messages sent to and from entities. + + + + + Exception used to describe various issues encountered by the entity scheduler. + + + + + Initializes a new instance of the class. + + + + + Initializes an new instance of the class. + + The message that describes the error. + The exception that was caught. + + + + Initializes a new instance of the class with serialized data. + + The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown. + The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination. + + + + The response returned by . + + The JSON-serializable type of the entity. + + + + Whether this entity exists or not. + + + + + The current state of the entity, if it exists, or default() otherwise. + + + + + Information about the current status of an entity. Excludes potentially large data + (such as the entity state, or the contents of the queue) so it can always be read with low latency. + + + + + Whether this entity exists or not. + + + + + The size of the queue, i.e. the number of operations that are waiting for the current operation to complete. + + + + + The instance id of the orchestration that currently holds the lock of this entity. + + + + + The operation that is currently executing on this entity. + + + + + The exception that is thrown when application code violates the locking rules. + + + + + provides message ordering and deduplication of request messages (operations or lock requests) + that are sent to entities, from other entities, or from orchestrations. + + + + + Used for testing purposes. + + + + + Called on the sending side, to fill in timestamp and predecessor fields. + + + + + Called on the receiving side, to reorder and deduplicate within the window. + + + + + Exception result representing an operation that failed, in case + the original exception is not serializable, or out-of-proc. + + + + + Initializes a new instance of the class. + + + + + Initializes an new instance of the class. + + The message that describes the error. + + + + Initializes a new instance of the class with serialized data. + + The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown. + The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination. + + + + Defines convenient overloads for creating entity proxy, for all the contexts. + + + + + Signals an entity to perform an operation. + + Entity interface. + orchestration client. + The target entity key. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation, at a specified time. + + Entity interface. + orchestration client. + The target entity key. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation. + + Entity interface. + orchestration client. + The target entity. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation, at a specified time. + + Entity interface. + orchestration client. + The target entity. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Create an entity proxy. + + orchestration context. + The target entity key. + Entity interface. + Entity proxy. + + + + Create an entity proxy. + + orchestration context. + The target entity. + Entity interface. + Entity proxy. + + + + Signals an entity to perform an operation. + + entity context. + The target entity key. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Signals an entity to perform an operation, at a specified time. + + entity context. + The target entity key. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Signals an entity to perform an operation. + + entity context. + The target entity. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Signals an entity to perform an operation, at a specified time. + + entity context. + The target entity. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Provides the base implementation for the entity proxy. + + + + + Create an entity proxy. + + context. + Entity id. + + + + Call entity function. + + The name of the operation. + The input for the operation. + A representing the result of the asynchronous operation. + + + + Call entity function. + + The return type of the called entity function. + The name of the operation. + The input for the operation. + A representing the result of the asynchronous operation. + + + + Signal entity function. + + The name of the operation. + The input for the operation. + + + + Abstract entity proxy context. + + + + + Call entity function. + + Entity id. + Entity operation name. + Entity input value. + A representing the result of the asynchronous operation. + + + + Call entity function. + + Result type. + Entity id. + Entity operation name. + Entity input value. + A representing the result of the asynchronous operation. + + + + Signal entity function. + + Entity id. + Entity operation name. + Entity input value. + + + + A message that represents an operation request or a lock request. + + + + + The name of the operation being called (if this is an operation message) or null + (if this is a lock request). + + + + + Whether or not this is a one-way message. + + + + + The operation input. + + + + + A unique identifier for this operation. + + + + + The parent instance that called this operation. + + + + + The parent instance that called this operation. + + + + + Optionally, a scheduled time at which to start the operation. + + + + + A timestamp for this request. + Used for duplicate filtering and in-order delivery. + + + + + A timestamp for the predecessor request in the stream, or DateTime.MinValue if none. + Used for duplicate filtering and in-order delivery. + + + + + For lock requests, the set of locks being acquired. Is sorted, + contains at least one element, and has no repetitions. + + + + + For lock requests involving multiple locks, the message number. + + + + + The persisted state of an entity scheduler, as handed forward between ContinueAsNew instances. + + + + + Whether this entity exists or not. + + + + + The serialized entity state. This can be stale while CurrentStateView != null. + + + + + The queue of waiting operations, or null if none. + + + + + The instance id of the orchestration that currently holds the lock of this entity. + + + + + The metadata used for reordering and deduplication of messages sent to entities. + + + + + Extends the durable entity context to support reflection-based invocation of entity operations. + + + + + Dynamically dispatches the incoming entity operation using reflection. + + The class to use for entity instances. + A task that completes when the dispatched operation has finished. + If there is more than one method with the given operation name. + If there is no method with the given operation name. + If the method has more than one argument. + + If the entity's state is null, an object of type is created first. Then, reflection + is used to try to find a matching method. This match is based on the method name + (which is the operation name) and the argument list (which is the operation content, deserialized into + an object array). + + Context object to use to dispatch entity operations. + Parameters to feed to the entity constructor. Should be primarily used for + output bindings. Parameters must match the order in the constructor after ignoring parameters populated on + constructor via dependency injection. + + + + ETW Event Provider for the WebJobs.Extensions.DurableTask extension. + + + + + The exception that is thrown when a sub-orchestrator or activity function fails + with an error. + + + The `InnerException` property of this instance will contain additional information + about the failed sub-orchestrator or activity function. + + + + + Initializes a new instance of a . + + A message describing where to look for more details. + + + + Initializes a new instance of a . + + A message describing where to look for more details. + The exception that caused the function to fail. + + + + The name of a durable function. + + + + + Initializes a new instance of the struct. + + The name of the function. + + + + Gets the name of the function without the version. + + + The name of the activity function without the version. + + + + + Compares two objects for equality. + + The first to compare. + The second to compare. + true if the two objects are equal; otherwise false. + + + + Compares two objects for inequality. + + The first to compare. + The second to compare. + true if the two objects are not equal; otherwise false. + + + + Gets a value indicating whether to objects + are equal using value semantics. + + The other object to compare to. + true if the two objects are equal using value semantics; otherwise false. + + + + Gets a value indicating whether to objects + are equal using value semantics. + + The other object to compare to. + true if the two objects are equal using value semantics; otherwise false. + + + + Calculates a hash code value for the current instance. + + A 32-bit hash code value. + + + + Gets the string value of the current instance. + + The name and optional version of the current instance. + + + + The type of a function. + + + + + Class for creating deterministic . + + + + + Data structure containing orchestration instance creation HTTP endpoints. + + + + + Gets the HTTP POST orchestration instance creation endpoint URL. + + + The HTTP URL for creating a new orchestration instance. + + + + + Gets the HTTP POST orchestration instance create-and-wait endpoint URL. + + + The HTTP URL for creating a new orchestration instance and waiting on its completion. + + + + + Data structure containing status, terminate and send external event HTTP endpoints. + + + + + Gets the ID of the orchestration instance. + + + The ID of the orchestration instance. + + + + + Gets the HTTP GET status query endpoint URL. + + + The HTTP URL for fetching the instance status. + + + + + Gets the HTTP POST external event sending endpoint URL. + + + The HTTP URL for posting external event notifications. + + + + + Gets the HTTP POST instance termination endpoint. + + + The HTTP URL for posting instance termination commands. + + + + + Gets the HTTP POST instance rewind endpoint. + + + The HTTP URL for rewinding orchestration instances. + + + + + Gets the HTTP DELETE purge instance history by instance ID endpoint. + + + The HTTP URL for purging instance history by instance ID. + + + + + Custom service interface for signaling the extension when the function app is starting up or shutting down. + + + This interface is expected to be used as an injected service. We use a "wrapper" interface instead of + directly using the "real" IApplicationLifetime interface so that we can have an injected service + that is available in both .NET Core (Functions 2.0+) and .NET Framework (Functions 1.0). + + + + + Gets a that can be used to detect function app startup events. + + + A that is signalled when the function app has started up. + + + + + Gets a that can be used to detect function app stopping events. + + + A that is signalled when the function app is beginning to shut down. + + + + + Gets a that can be used to detect function app shutdown events. + + + A that is signalled when the function app has completed shutting down. + + + + + Interface defining methods to resolve connection strings. + + + + + Looks up a connection string value given a name. + + The name of the connection string. + Returns the resolved connection string value. + + + + Interface defining methods to build instances of . + + + + + Creates or retrieves a durability provider to be used throughout the extension. + + An durability provider to be used by the Durable Task Extension. + + + + Creates or retrieves a cached durability provider to be used in a given function execution. + + A durable client attribute with parameters for the durability provider. + A durability provider to be used by a client function. + + + + Interface used for testing Durable HTTP. + + + + + Creates an HttpClientHandler and returns it. + + Returns an HttpClientHandler. + + + + Interface defining methods to build instances of for error serialization. + + + + + Creates or retrieves to be used throughout the extension for error serialization. + + to be used by the Durable Task Extension for error serialization. + + + + Interface defining methods to life cycle notifications. + + + + + The orchestrator was starting. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + The orchestrator function is currently replaying itself. + A task that completes when the lifecycle notification message has been sent. + + + + The orchestrator was completed. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + The orchestration completed with ContinueAsNew as is in the process of restarting. + The orchestrator function is currently replaying itself. + A task that completes when the lifecycle notification message has been sent. + + + + The orchestrator was failed. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + Additional data associated with the tracking event. + The orchestrator function is currently replaying itself. + A task that completes when the lifecycle notification message has been sent. + + + + The orchestrator was terminated. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + Additional data associated with the tracking event. + A task that completes when the lifecycle notification message has been sent. + + + + Interface defining methods to build instances of for message serialization. + + + + + Creates or retrieves to be used throughout the extension for message serialization. + + to be used by the Durable Task Extension for message serialization. + + + + Implementations of this interface can be used to provide authorization tokens for outbound HTTP requests. + + + + + Gets a token for a resource. + + A representing the result of the asynchronous operation. + + + + Not intended for public consumption. + + + + + Initializes a new instance of the class. + + The orchestration execution context. + + + + Not intended for public consumption. + + The result of the out-of-proc execution. + true if there are more executions to process; false otherwise. + + + + Task activity implementation which delegates the implementation to a function. + + + + + Common functionality of and . + + + + + Implements the entity scheduler as a looping orchestration. + There is one such orchestration per entity. + The orchestration terminates if the entity is deleted and idle. + The orchestration calls ContinueAsNew when it is idle, but not deleted. + + + + + The results of executing a batch of operations on the entity out of process. + + + + + Whether the entity exists after executing the batch. + This is false if the last operation in the batch deletes the entity, + and true otherwise. + + + + + The state of the entity after executing the batch. + Should be null if is false. + + + + + The results of executing the operations. The length of this list must always match + the size of the batch, even if there were exceptions. + + + + + The list of signals sent by the entity. Can be empty. + + + + + The results of executing an operation. + + + + + The returned value or error/exception. + + + + + Determines whether is a normal result, or an error/exception. + + + + + The measured duration of this operation's execution, in milliseconds. + + + + + Describes a signal that was emitted by one of the operations in the batch. + + + + + The destination of the signal. + + + + + The name of the operation being signaled. + + + + + The input of the operation being signaled. + + + + + Task orchestration implementation which delegates the orchestration implementation to a function. + + + + + Token Source implementation for Azure Managed Identities. + + + + + Initializes a new instance of the class. + + + The Azure Active Directory resource identifier of the web API being invoked. + For example, https://management.core.windows.net/ or https://graph.microsoft.com/. + + + + + Gets the Azure Active Directory resource identifier of the web API being invoked. + For example, https://management.core.windows.net/ or https://graph.microsoft.com/. + + + + + + + + JSON-serializes the specified object. + + + + + JSON-serializes the specified object and throws a if the + resulting JSON exceeds the maximum size specified by . + + + + + Configuration options for the Azure Storage storage provider. + + + + + Gets or sets the name of the Azure Storage connection string used to manage the underlying Azure Storage resources. + + + If not specified, the default behavior is to use the standard `AzureWebJobsStorage` connection string for all storage usage. + + The name of a connection string that exists in the app's application settings. + + + + Gets or sets the number of messages to pull from the control queue at a time. + + + Messages pulled from the control queue are buffered in memory until the internal + dispatcher is ready to process them. + + A positive integer configured by the host. The default value is 32. + + + + Gets or sets the partition count for the control queue. + + + Increasing the number of partitions will increase the number of workers + that can concurrently execute orchestrator functions. However, increasing + the partition count can also increase the amount of load placed on the storage + account and on the thread pool if the number of workers is smaller than the + number of partitions. + + A positive integer between 1 and 16. The default value is 4. + + + + Gets or set the number of control queue messages that can be buffered in memory + at a time, at which point the dispatcher will wait before dequeuing any additional + messages. The default is 256. The maximum value is 1000. + + + Increasing this value can improve orchestration throughput by pre-fetching more + orchestration messages from control queues. The downside is that it increases the + possibility of duplicate function executions if partition leases move between app + instances. This most often occurs when the number of app instances changes. + + A non-negative integer between 0 and 1000. The default value is 256. + + + + Gets or sets the visibility timeout of dequeued control queue messages. + + + A TimeSpan configured by the host. The default is 5 minutes. + + + + + Gets or sets the visibility timeout of dequeued work item queue messages. + + + A TimeSpan configured by the host. The default is 5 minutes. + + + + + Gets or sets the name of the Azure Storage connection string to use for the + durable tracking store (History and Instances tables). + + + If not specified, the connection string + is used for the durable tracking store. + + This property is primarily useful when deploying multiple apps that need to share the same + tracking infrastructure. For example, when deploying two versions of an app side by side, using + the same tracking store allows both versions to save history into the same table, which allows + clients to query for instance status across all versions. + + The name of a connection string that exists in the app's application settings. + + + + Gets or sets the name prefix to use for history and instance tables in Azure Storage. + + + This property is only used when is specified. + If no prefix is specified, the default prefix value is "DurableTask". + + The prefix to use when naming the generated Azure tables. + + + + Gets or sets whether the extension will automatically fetch large messages in orchestration status + queries. If set to false, the extension will return large messages as a blob url. + + A boolean indicating whether will automatically fetch large messages . + + + + Gets or sets the maximum queue polling interval. + + Maximum interval for polling control and work-item queues. + + + + Throws an exception if the provided hub name violates any naming conventions for the storage provider. + + + + + Throws an exception if any of the settings of the storage provider are invalid. + + + + + Configuration options for the Durable Task extension. + + + + + Settings used for Durable HTTP functionality. + + + + + Gets or sets default task hub name to be used by all , , , + , and instances. + + + A task hub is a logical grouping of storage resources. Alternate task hub names can be used to isolate + multiple Durable Functions applications from each other, even if they are using the same storage backend. + + The name of the default task hub. + + + + The section of configuration related to storage providers. If using Azure Storage provider, the schema should match + . + + + + + The section of configuration related to tracing. + + + + + The section of configuration related to notifications. + + + + + Gets or sets the maximum number of activity functions that can be processed concurrently on a single host instance. + + + Increasing activity function concurrent can result in increased throughput but can + also increase the total CPU and memory usage on a single worker instance. + + + A positive integer configured by the host. The default value is 10X the number of processors on the current machine. + + + + + Gets or sets the maximum number of orchestrator functions that can be processed concurrently on a single host instance. + + + A positive integer configured by the host. The default value is 10X the number of processors on the current machine. + + + + + Gets or sets the base URL for the HTTP APIs managed by this extension. + + + This property is intended for use only by runtime hosts. + + + A URL pointing to the hosted function app that responds to status polling requests. + + + + + Gets or sets a value indicating whether to enable the local RPC endpoint managed by this extension. + + + The local RPC endpoint is intended to allow out-of-process functions to make direct calls into this + extension. This is primarily intended to support instance management APIs used by the durable client + binding. The following values are allowed: + + + null + (Default) The local RPC endpoint is enabled only for non-.NET function apps. + + + true + A local RPC endpoint will be enabled and listen at http://127.0.0.1:17071/durabletask/. + + + false + The local RPC endpoint will be disabled. + + + + + + + Gets or sets a flag indicating whether to enable extended sessions. + + + Extended sessions can improve the performance of orchestrator functions by allowing them to skip + replays when new messages are received within short periods of time. + Note that orchestrator functions which are extended this way will continue to count against the + limit. To avoid starvation, only half of the maximum + number of allowed concurrent orchestrator functions can be concurrently extended at any given time. + The property can also be used to control how long an idle + orchestrator function is allowed to be extended. + It is recommended that this property be set to false during development to help + ensure that the orchestrator code correctly obeys the idempotency rules. + + + true to enable extended sessions; otherwise false. + + + + + Gets or sets the amount of time in seconds before an idle session times out. The default value is 30 seconds. + + + This setting is applicable when is set to true. + + + The number of seconds before an idle session times out. + + + + + Gets or sets the maximum number of orchestration actions. The default value is 100,000. + + + + + States that will override an existing orchestrator when attempting to start a new orchestrator with the same instance Id. + + + + + Gets or sets the time window within which entity messages get deduplicated and reordered. + + + + + Preview setting for gracefully shutting down to prevent WebJob shutdowns from failing + activities or orchestrations. + + + + + Sets HubName to a value that is considered a default value. + + TaskHub name that is considered the default. + + + + Configuration of the Event Grid notification options + for the Durable Task Extension. + + + + + Gets or sets the URL of an Azure Event Grid custom topic endpoint. + When set, orchestration life cycle notification events will be automatically + published to this endpoint. + + + Azure Event Grid topic URLs are generally expected to be in the form + https://{topic_name}.{region}.eventgrid.azure.net/api/events. + + + The Azure Event Grid custom topic URL. + + + + + Gets or sets the name of the app setting containing the key used for authenticating with the Azure Event Grid custom topic at . + + + The name of the app setting that stores the Azure Event Grid key. + + + + + Gets or sets the Event Grid publish request retry count. + + The number of retry attempts. + + + + Gets orsets the Event Grid publish request retry interval. + + A representing the retry interval. The default value is 5 minutes. + + + + Gets or sets the Event Grid publish request http status. + + A list of HTTP status codes, e.g. 400, 403. + + + + Gets or sets the event types that will be published to Event Grid. + + + A list of strings. Possible values 'Started', 'Completed', 'Failed', 'Terminated'. + + + + + Used for Durable HTTP functionality. + + + + + Reserved name to know when a TaskActivity should be an HTTP activity. + + + + + Gets or sets the default number of milliseconds between async HTTP status poll requests. + + + + + Configuration of the notification options + for the Durable Task Extension. + + + + + The section of configuration related to Event Grid notifications. + + + + + Configuration of the trace options + for the Durable Task Extension. + + + + + Gets or sets a value indicating whether to trace the inputs and outputs of function calls. + + + The default behavior when tracing function execution events is to include the number of bytes in the serialized + inputs and outputs for function calls. This provides minimal information about what the inputs and outputs look + like without bloating the logs or inadvertently exposing sensitive information to the logs. Setting + to true will instead cause the default function logging to log + the entire contents of function inputs and outputs. + + + true to trace the raw values of inputs and outputs; otherwise false. + + + + + Gets or sets if logs for replay events need to be recorded. + + + The default value is false, which disables the logging of replay events. + + + Boolean value specifying if the replay events should be logged. + + + + + Represents the possible runtime execution status values for an orchestration instance. + + + + + The status of the orchestration could not be determined. + + + + + The orchestration is running (it may be actively running or waiting for input). + + + + + The orchestration ran to completion. + + + + + The orchestration completed with ContinueAsNew as is in the process of restarting. + + + + + The orchestration failed with an error. + + + + + The orchestration was canceled. + + + + + The orchestration was terminated via an API call. + + + + + The orchestration was scheduled but has not yet started. + + + + + Query condition for searching the status of orchestration instances. + + + + + Initializes a new instance of the class. + + + + + Return orchestration instances which matches the runtimeStatus. + + + + + Return orchestration instances which were created after this DateTime. + + + + + Return orchestration instances which were created before this DateTime. + + + + + Return orchestration instances which matches the TaskHubNames. + + + + + Number of records per one request. The default value is 100. + + + + + ContinuationToken of the pager. + + + + + Return orchestration instances that have this instance id prefix. + + + + + Determines whether the query will include the input of the orchestration. + + + + + The status of all orchestration instances with paging for a given query. + + + + + Gets or sets a collection of statuses of orchestration instances matching the query description. + + A collection of orchestration instance status values. + + + + Gets or sets a token that can be used to resume the query with data not already returned by this query. + + A server-generated continuation token or null if there are no further continuations. + + + + Represents options for different states that an existing orchestrator can be in to be able to be overwritten by + an attempt to start a new instance with the same instance Id. + + + + + Option to start a new orchestrator instance with an existing instnace Id when the existing + instance is in any state. + + + + + Option to only start a new orchestrator instance with an existing instance Id when the existing + instance is in a terminated, failed, or completed state. + + + + + Class to hold statistics about this execution of purge history. + + + + + Constructor for purge history statistics. + + Number of instances deleted. + + + + Gets the number of deleted instances. + + The number of deleted instances. + + + + Defines retry policies that can be passed as parameters to various operations. + + + + + Creates a new instance RetryOptions with the supplied first retry and max attempts. + + Timespan to wait for the first retry. + Max number of attempts to retry. + + The value must be greater than . + + + + + Gets or sets the first retry interval. + + + The TimeSpan to wait for the first retries. + + + + + Gets or sets the max retry interval. + + + The TimeSpan of the max retry interval, defaults to . + + + + + Gets or sets the backoff coefficient. + + + The backoff coefficient used to determine rate of increase of backoff. Defaults to 1. + + + + + Gets or sets the timeout for retries. + + + The TimeSpan timeout for retries, defaults to . + + + + + Gets or sets the max number of attempts. + + + The maximum number of retry attempts. + + + + + Gets or sets a delegate to call on exception to determine if retries should proceed. + + + The delegate to handle exception to determie if retries should proceed. + + + + + Parameters for starting a new instance of an orchestration. + + + This class is primarily intended for use with IAsyncCollector<T>. + + + + + Initializes a new instance of the class. + + The name of the orchestrator function to start. + The JSON-serializeable input for the orchestrator function. + + + + Initializes a new instance of the class. + + + + + Gets or sets the name of the orchestrator function to start. + + The name of the orchestrator function to start. + + + + Gets or sets the instance ID to assign to the started orchestration. + + + If this property value is null (the default), then a randomly generated instance ID will be assigned automatically. + + The instance ID to assign. + + + + Gets or sets the JSON-serializeable input data for the orchestrator function. + + JSON-serializeable input value for the orchestrator function. + + + + Response for Orchestration Status Query. + + + + + Name. + + + + + InstanceId. + + + + + Runtime status. + + + + + Input. + + + + + Custom status. + + + + + Output. + + + + + Created time value. + + + + + Last updated time. + + + + + JSON object representing history for an orchestration execution. + + + + + Trigger attribute used for durable activity functions. + + + + + Gets or sets the name of the activity function. + + + The name of the activity function or null to use the function name. + + + + + Trigger attribute used for durable entity functions. + + + + + Gets or sets the name of the entity. + + + If not specified, the function name is used as the name of the entity. + + + The name of the entity or null to use the function name. + + + + + Trigger attribute used for durable orchestrator functions. + + + + + Gets or sets the name of the orchestrator function. + + + If not specified, the function name is used as the name of the orchestration. + + + The name of the orchestrator function or null to use the function name. + + + + + Connection string provider which resolves connection strings from the WebJobs context. + + + + + + + diff --git a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry.xml b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry.xml new file mode 100644 index 000000000..23717cfbe --- /dev/null +++ b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry.xml @@ -0,0 +1,4009 @@ + + + + Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry + + + + + The Azure Storage implementation of additional methods not required by IOrchestrationService. + + + + + The app setting containing the Azure Storage connection string. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The default parameter type for activity functions. + + + + + + + + Returns the input of the task activity in its raw JSON string value. + + + The raw JSON-formatted activity input as a string value. + + + + + Gets the input of the current activity function instance as a JToken. + + + The parsed JToken representation of the activity input. + + + + + + + + Sets the JSON-serializeable output of the activity function. + + + If this method is not called explicitly, the return value of the activity function is used as the output. + + + The JSON-serializeable value to use as the activity function output. + + + + + Client for starting, querying, terminating, and raising events to orchestration instances. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Common functionality used by both + and . + + + + + Context object passed to application code executing entity operations. + + + + + Parameter data for orchestration bindings that can be used to schedule function-based activities. + + + + + + + + + + + + + + + + + + + + Returns the orchestrator function input as a raw JSON string value. + + + The raw JSON-formatted orchestrator function input. + + + + + Gets the input of the current orchestrator function instance as a JToken. + + + The parsed JToken representation of the orchestrator function input. + + + + + + + + Sets the JSON-serializeable output of the current orchestrator function. + + + If this method is not called explicitly, the return value of the orchestrator function is used as the output. + + The JSON-serializeable value to use as the orchestrator function output. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines convenient overloads for calling the context methods, for all the contexts. + + + + + Schedules an activity function named for execution. + + The context object. + The name of the activity function to call. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an activity function named for execution with retry options. + + The context object. + The name of the activity function to call. + The retry option for the activity function. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called activity function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution. + + The context object. + The name of the orchestrator function to call. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The sub-orchestrator function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution. + + The context object. + The name of the orchestrator function to call. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestration function named for execution. + + The return type of the scheduled orchestrator function. + The context object. + The name of the orchestrator function to call. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The context object. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The context object. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The return type of the scheduled orchestrator function. + The context object. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Creates a durable timer that expires at a specified time. + + + All durable timers created using this method must either expire or be cancelled + using the before the orchestrator function completes. + Otherwise the underlying framework will keep the instance alive until the timer expires. + + The context object. + The time at which the timer should expire. + The CancellationToken to use for cancelling the timer. + A durable task that completes when the durable timer expires. + + + + Waits asynchronously for an event to be raised with name . + + + External clients can raise events to a waiting orchestration instance using + with the object parameter set to null. + + The context object. + The name of the event to wait for. + A durable task that completes when the external event is received. + + + + Waits asynchronously for an event to be raised with name . + + + External clients can raise events to a waiting orchestration instance using + with the object parameter set to null. + + The context object. + The name of the event to wait for. + The duration after which to throw a TimeoutException. + A durable task that completes when the external event is received. + + The external event was not received before the timeout expired. + + + + + Calls an operation on an entity and returns the result asynchronously. + + The JSON-serializable result type of the operation. + The context object. + The target entity. + The name of the operation. + A task representing the result of the operation. + + + + Calls an operation on an entity and waits for it to complete. + + The context object. + The target entity. + The name of the operation. + A task representing the completion of the operation on the entity. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the default 10 second timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within this timeout, then the HTTP response will be identical to that of the + API. + + The client object. + The HTTP request that triggered the current function. + The unique ID of the instance to check. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the default 10 second timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within this timeout, then the HTTP response will be identical to that of the + API. + + The client object. + The HTTP request that triggered the current function. + The unique ID of the instance to check. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The client object. + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The client object. + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Starts a new execution of the specified orchestrator function. + + The client object. + The name of the orchestrator function to start. + The ID to use for the new orchestration instance. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Starts a new execution of the specified orchestrator function. + + The client object. + The name of the orchestrator function to start. + JSON-serializeable input value for the orchestrator function. + The type of the input value for the orchestrator function. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Starts a new execution of the specified orchestrator function. + + The client object. + The name of the orchestrator function to start. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Sends an event notification message to a waiting orchestration instance. + + + + In order to handle the event, the target orchestration instance must be waiting for an + event named using the + API. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The client object. + The ID of the orchestration instance that will handle the event. + The name of the event. + A task that completes when the event notification message has been enqueued. + + + + Gets the status of the specified orchestration instance. + + The client object. + The ID of the orchestration instance to query. + Returns a task which completes when the status has been fetched. + + + + Gets the status of the specified orchestration instance. + + The client object. + The ID of the orchestration instance to query. + Boolean marker for including execution history in the response. + Returns a task which completes when the status has been fetched. + + + + Returns an instance of ILogger that is replay safe, ensuring the logger logs only when the orchestrator + is not replaying that line of code. + + The context object. + An instance of ILogger. + An instance of a replay safe ILogger. + + + + Provides functionality available to durable activities. + + + + + Gets the instance ID of the currently executing orchestration. + + + The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The ID of the current orchestration instance. + + + + + Gets the input of the current activity function as a deserialized value. + + Any data contract type that matches the JSON input. + The deserialized input value. + + + + Provides functionality available to durable orchestration and entity clients. + + + + + Gets the name of the task hub configured on this client instance. + + + The name of the task hub. + + + + + Provides functionality available to durable entity clients. + + + + + Gets the name of the task hub configured on this client instance. + + + The name of the task hub. + + + + + Signals an entity to perform an operation. + + The target entity. + The name of the operation. + The input for the operation. + The TaskHubName of the target entity. + The name of the connection string associated with . + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation, at a specified time. + + The target entity. + The time at which to start the operation. + The name of the operation. + The input for the operation. + The TaskHubName of the target entity. + The name of the connection string associated with . + A task that completes when the message has been reliably enqueued. + + + + Tries to read the current state of an entity. Returns default() if the entity does not + exist, or if the JSON-serialized state of the entity is larger than 16KB. + + The JSON-serializable type of the entity. + The target entity. + The TaskHubName of the target entity. + The name of the connection string associated with . + a response containing the current state of the entity. + + + + Gets the status of all entity instances with paging that match the specified query conditions. + + Return entity instances that match the specified query conditions. + Cancellation token that can be used to cancel the query operation. + Returns a page of entity instances and a continuation token for fetching the next page. + + + + Provides functionality for application code implementing an entity operation. + + + + + Gets the name of the currently executing entity. + + + + + Gets the key of the currently executing entity. + + + + + Gets the id of the currently executing entity. + + + + + Gets the name of the operation that was called. + + + An operation invocation on an entity includes an operation name, which states what + operation to perform, and optionally an operation input. + + + + + Contains function invocation context to assist with dependency injection at Entity construction time. + + + + + Whether this entity has a state. + + + + + Gets the current state of this entity, for reading and/or updating. + If this entity has no state yet, creates it. + + The JSON-serializable type of the entity state. + Provides an initial value to use for the state, instead of default(). + The current state of this entity. + If the current state has an incompatible type. + + + + Sets the current state of this entity. + + The JSON-serializable state of the entity. + + + + Deletes the state of this entity. + + + + + Gets the input for this operation, as a deserialized value. + + The JSON-serializable type used for the operation input. + The operation input, or default() if none. + + An operation invocation on an entity includes an operation name, which states what + operation to perform, and optionally an operation input. + + + + + Gets the input for this operation, as a deserialized value. + + The JSON-serializable type used for the operation input. + The operation input, or default() if none. + + An operation invocation on an entity includes an operation name, which states what + operation to perform, and optionally an operation input. + + + + + Returns the given result to the caller of this operation. + + the result to return. + + + + Signals an entity to perform an operation, without waiting for a response. Any result or exception is ignored (fire and forget). + + The target entity. + The name of the operation. + The operation input. + + + + Signals an entity to perform an operation, at a specified time. Any result or exception is ignored (fire and forget). + + The target entity. + The time at which to start the operation. + The name of the operation. + The input for the operation. + + + + Schedules a orchestration function named for execution./>. + Any result or exception is ignored (fire and forget). + + The name of the orchestrator function to call. + the input to pass to the orchestrator function. + optionally, an instance id for the orchestration. By default, a random GUID is used. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + The instance id of the new orchestration. + + + + Provides functionality available to durable orchestration clients. + + + + + Gets the name of the task hub configured on this client instance. + + + The name of the task hub. + + + + + Creates an HTTP response that is useful for checking the status of the specified instance. + + + The payload of the returned contains HTTP API URLs that can + be used to query the status of the orchestration, raise events to the orchestration, or + terminate the orchestration. + + The HTTP request that triggered the current orchestration instance. + The ID of the orchestration instance to check. + Optional parameter that configures the http response code returned. Defaults to false. + If true, the returned http response code will be a 500 when the orchestrator is in a failed state, when false it will + return 200. + An HTTP 202 response with a Location header and a payload containing instance control URLs. + + + + Creates an HTTP response that is useful for checking the status of the specified instance. + + + The payload of the returned contains HTTP API URLs that can + be used to query the status of the orchestration, raise events to the orchestration, or + terminate the orchestration. + + The HTTP request that triggered the current orchestration instance. + The ID of the orchestration instance to check. + Optional parameter that configures the http response code returned. Defaults to false. + If true, the returned http response code will be a 500 when the orchestrator is in a failed state, when false it will + return 200. + An HTTP 202 response with a Location header and a payload containing instance control URLs. + + + + Creates a object that contains status, terminate and send external event HTTP endpoints. + + The ID of the orchestration instance to check. + Instance of the class. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + The timeout between checks for output from the durable function. The default value is 1 second. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Creates an HTTP response which either contains a payload of management URLs for a non-completed instance + or contains the payload containing the output of the completed orchestration. + + + If the orchestration instance completes within the specified timeout, then the HTTP response payload will + contain the output of the orchestration instance formatted as JSON. However, if the orchestration does not + complete within the specified timeout, then the HTTP response will be identical to that of the + API. + + The HTTP request that triggered the current function. + The unique ID of the instance to check. + Total allowed timeout for output from the durable function. The default value is 10 seconds. + The timeout between checks for output from the durable function. The default value is 1 second. + An HTTP response which may include a 202 and location header or a 200 with the durable function output in the response body. + + + + Starts a new instance of the specified orchestrator function. + + + If an orchestration instance with the specified ID already exists, the existing instance + will be silently replaced by this new instance. + + The name of the orchestrator function to start. + The ID to use for the new orchestration instance. + JSON-serializeable input value for the orchestrator function. + The type of the input value for the orchestrator function. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + + + Sends an event notification message to a waiting orchestration instance. + + + + In order to handle the event, the target orchestration instance must be waiting for an + event named using the + API. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The ID of the orchestration instance that will handle the event. + The name of the event. + The JSON-serializeable data associated with the event. + A task that completes when the event notification message has been enqueued. + + + + Sends an event notification message to a waiting orchestration instance. + + + + In order to handle the event, the target orchestration instance must be waiting for an + event named using the + API. + + If the specified instance is not found or not running, this operation will throw an exception. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The TaskHubName of the orchestration that will handle the event. + The ID of the orchestration instance that will handle the event. + The name of the event. + The JSON-serializeable data associated with the event. + The name of the connection string associated with . + A task that completes when the event notification message has been enqueued. + + + + Terminates a running orchestration instance. + + + + A terminated instance will eventually transition into the state. + However, this transition will not happen immediately. Rather, the terminate operation will be queued in the task hub + along with other operations for that instance. You can use the + method to know when a terminated instance has actually reached the Terminated state. + + + Terminating an orchestration instance has no effect on any in-flight activity function executions + or sub-orchestrations that were started by the current orchestration instance. + + + The instance id does not corespond to a valid orchestration instance. + The orchestration instance with the provided instance id is not running. + The ID of the orchestration instance to terminate. + The reason for terminating the orchestration instance. + A task that completes when the terminate message is enqueued if necessary. + + + + Rewinds the specified failed orchestration instance with a reason. + + The ID of the orchestration instance to rewind. + The reason for rewinding the orchestration instance. + A task that completes when the rewind message is enqueued. + + + + Gets the status of the specified orchestration instance. + + The ID of the orchestration instance to query. + Boolean marker for including execution history in the response. + Boolean marker for including input and output in the execution history response. + If set, fetch and return the input for the orchestration instance. + Returns a task which completes when the status has been fetched. + + + + Gets all the status of the orchestration instances. + + Cancellation token that can be used to cancel the status query operation. + Returns orchestration status for all instances. + + + + Gets the status of all orchestration instances that match the specified conditions. + + Return orchestration instances which were created after this DateTime. + Return orchestration instances which were created before this DateTime. + Return orchestration instances which matches the runtimeStatus. + Cancellation token that can be used to cancel the status query operation. + Returns orchestration status for all instances. + + + + Purge the history for a concrete instance. + + The ID of the orchestration instance to purge. + Returns an instance of . + + + + Purge the orchestration history for instances that match the conditions. + + Start creation time for querying instances for purging. + End creation time for querying instances for purging. + List of runtime status for querying instances for purging. Only Completed, Terminated, or Failed will be processed. + Returns an instance of . + + + + Gets the status of all orchestration instances with paging that match the specified conditions. + + Return orchestration instances that match the specified conditions. + Cancellation token that can be used to cancel the status query operation. + Returns each page of orchestration status for all instances and continuation token of next page. + + + + Gets the status of all orchestration instances with paging that match the specified conditions. + + Return orchestration instances that match the specified conditions. + Cancellation token that can be used to cancel the status query operation. + Returns each page of orchestration status for all instances and continuation token of next page. + + + + Provides functionality available to orchestration code. + + + + + Gets the name of the current orchestration function. + + + + + Gets the instance ID of the currently executing orchestration. + + + The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The ID of the current orchestration instance. + + + + + Gets the parent instance ID of the currently executing sub-orchestration. + + + The parent instance ID is generated and fixed when the parent orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The ID of the parent orchestration of the current sub-orchestration instance. The value will be available only in sub-orchestrations. + + + + + Gets the current date/time in a way that is safe for use in orchestrations and entity operations. + + + This date/time value is derived from the orchestration or entity history. It always returns the same value + at specific points in the orchestrator function code, making it deterministic and safe for replay. + + The orchestration or entity's current date/time in UTC. + + + + Gets a value indicating whether the orchestration or operation is currently replaying itself. + + + This property is useful when there is logic that needs to run only when *not* replaying. For example, certain types of application logging may become too noisy when duplicated + as part of replay. The application code could check to see whether the function is + being replayed and then issue the log statements when this value is false. + + + true if the orchestration or operation is currently being replayed; otherwise false. + + + + + Gets the input of the current orchestrator function as a deserialized value. + + Any data contract type that matches the JSON input. + The deserialized input value. + + + + Sets the output for the current orchestration. + + The JSON-serializeable output of the orchestration. + + + + Restarts the orchestration by clearing its history. + + + Large orchestration histories can consume a lot of memory and cause delays in + instance load times. This method can be used to periodically truncate the stored + history of an orchestration instance. + Note that any unprocessed external events will be discarded when an orchestration + instance restarts itself using this method. + + The JSON-serializeable data to re-initialize the instance with. + + If set to true, re-adds any unprocessed external events into the new execution + history when the orchestration instance restarts. If false, any unprocessed + external events will be discarded when the orchestration instance restarts. + + + + + Sets the JSON-serializeable status of the current orchestrator function. + + + The value is serialized to JSON and will + be made available to the orchestration status query APIs. The serialized JSON + value must not exceed 16 KB of UTF-16 encoded text. + + The JSON-serializeable value to use as the orchestrator function's custom status. + + + + Makes an HTTP call to the specified uri. + + HttpMethod used for api call. + uri used to make the HTTP call. + Content passed in the HTTP request. + A Result of the HTTP call. + + + + Makes an HTTP call using the information in the DurableHttpRequest. + + The DurableHttpRequest used to make the HTTP call. + A Result of the HTTP call. + + + + Calls an operation on an entity, passing an argument, and returns the result asynchronously. + + The JSON-serializable result type of the operation. + The target entity. + The name of the operation. + The input for the operation. + A task representing the result of the operation. + if the context already holds some locks, but not the one for . + + + + Calls an operation on an entity, passing an argument, and waits for it to complete. + + The target entity. + The name of the operation. + The input for the operation. + A task representing the completion of the operation on the entity. + if the context already holds some locks, but not the one for . + + + + Schedules an orchestration function named for execution. + + The return type of the scheduled orchestrator function. + The name of the orchestrator function to call. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an orchestrator function named for execution with retry options. + + The return type of the scheduled orchestrator function. + The name of the orchestrator function to call. + The retry option for the orchestrator function. + A unique ID to use for the sub-orchestration instance. + The JSON-serializeable input to pass to the orchestrator function. + A durable task that completes when the called orchestrator function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Creates a durable timer that expires at a specified time. + + + All durable timers created using this method must either expire or be cancelled + using the before the orchestrator function completes. + Otherwise the underlying framework will keep the instance alive until the timer expires. + + The type of . + The time at which the timer should expire. + Any state to be preserved by the timer. + The CancellationToken to use for cancelling the timer. + A durable task that completes when the durable timer expires. + + + + Waits asynchronously for an event to be raised with name and returns the event data. + + + External clients can raise events to a waiting orchestration instance using + . + + The name of the event to wait for. + Any serializeable type that represents the JSON event payload. + A durable task that completes when the external event is received. + + + + Waits asynchronously for an event to be raised with name and returns the event data. + + + External clients can raise events to a waiting orchestration instance using + . + + The name of the event to wait for. + The duration after which to throw a TimeoutException. + Any serializeable type that represents the JSON event payload. + A durable task that completes when the external event is received. + + The external event was not received before the timeout expired. + + + + + Waits asynchronously for an event to be raised with name and returns the event data. + + + External clients can raise events to a waiting orchestration instance using + . + + The name of the event to wait for. + The duration after which to return the value in the parameter. + The default value to return if the timeout expires before the external event is received. + Any serializeable type that represents the JSON event payload. + A durable task that completes when the external event is received, or returns the value of + if the timeout expires. + + + + Acquires one or more locks, for the specified entities. + + + Locks can only be acquired if the current context does not hold any locks already. + + The entities whose locks should be acquired. + An IDisposable that releases the lock when disposed. + if the context already holds some locks. + + + + Determines whether the current context is locked, and if so, what locks are currently owned. + + The collection of owned locks. + + Note that the collection of owned locks can be empty even if the context is locked. This happens + if an orchestration calls a suborchestration without lending any locks. + + true if the context already holds some locks. + + + + Creates a new GUID that is safe for replay within an orchestration or operation. + + + The default implementation of this method creates a name-based UUID using the algorithm from + RFC 4122 §4.3. The name input used to generate this value is a combination of the orchestration + instance ID and an internally managed sequence number. + + The new value. + + + + Schedules an activity function named for execution. + + The return type of the scheduled activity function. + The name of the activity function to call. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called activity function completes or fails. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Schedules an activity function named for execution with retry options. + + The return type of the scheduled activity function. + The name of the activity function to call. + The retry option for the activity function. + The JSON-serializeable input to pass to the activity function. + A durable task that completes when the called activity function completes or fails. + + The retry option object is null. + + + The specified function does not exist, is disabled, or is not an orchestrator function. + + + The current thread is different than the thread which started the orchestrator execution. + + + The activity function failed with an unhandled exception. + + + + + Signals an entity to perform an operation, without waiting for a response. Any result or exception is ignored (fire and forget). + + The target entity. + The name of the operation. + The input for the operation. + + + + Signals an operation to be performed by an entity at a specified time. Any result or exception is ignored (fire and forget). + + The target entity. + The time at which to start the operation. + The name of the operation. + The input for the operation. + + + + Schedules a orchestration function named for execution./>. + Any result or exception is ignored (fire and forget). + + The name of the orchestrator function to call. + the input to pass to the orchestrator function. + optionally, an instance id for the orchestration. By default, a random GUID is used. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + The instance id of the new orchestration. + + + + Formerly, the abstract base class for DurableOrchestrationContext. + Now obsolete: use instead. + + + + + Formerly, the abstract base class for DurableActivityContext. + Now obsolete: use instead. + + + + + Formerly, the abstract base class for DurableOrchestrationClient. + Now obsolete: use instead. + + + + + Telemetry Initializer that sets correlation ids for W3C. + This source is based on W3COperationCorrelationTelemetryInitializer.cs + 1. Modified with CorrelationTraceContext.Current + 2. Avoid to be overriden when it is RequestTelemetry + Original Source is here https://github.com/microsoft/ApplicationInsights-dotnet-server/blob/2.8.0/Src/Common/W3C/W3COperationCorrelationTelemetryInitializer.cs. + + + + These internal property is copied from W3CConstants + Trace-Id tag name. + + + Span-Id tag name. + + + Parent span-Id tag name. + + + Version tag name. + + + Sampled tag name. + + + Tracestate tag name. + + + Default version value. + + + + Default sampled flag value: may be recorded, not requested. + + + + Recorded and requested sampled flag value. + + + Requested trace flag. + + + Legacy root Id tag name. + + + Legacy root Id tag name. + + + + Constructor. + + + + + Set of suppress telemetry tracking if you add Host name on this. + + + + + Initializes telemetry item. + + Telemetry item. + + + + ITelemetryActivator is an interface. + + + + + Initialize is initialize the telemetry client. + + + + + A stub of . + + + + + Initializes a new instance of the class. + + + + + Gets or sets a value indicating whether this channel is in developer mode. + + + + + Gets or sets a value indicating the channel's URI. To this URI the telemetry is expected to be sent. + + + + + Gets or sets a value indicating whether to throw an error. + + + + + Gets or sets the callback invoked by the method. + + + + + Gets or sets the callback invoked by the method. + + + + + Gets or sets the callback invoked by the method. + + + + + Implements the method by invoking the callback. + + + + + Implements the method. + + + + + Implements the method. + + + + + TelemetryActivator activates Distributed Tracing. This class only works for netstandard2.0. + + + + + Constructor for activating Distributed Tracing. + + DurableTask options. + + + + OnSend is an action that enable to hook of sending telemetry. + You can use this property for testing. + + + + + Initialize is initialize the telemetry client. + + + + + TraceContextBase extension methods. + + + + + Create RequestTelemetry from the TraceContext. + + TraceContext. + RequestTelemetry. + + + + Create DependencyTelemetry from the Activity. + + TraceContext. + DependencyTelemetry. + + + + Represents a traceParent that is defined W3C TraceContext. + + + + + Gets or sets the Version of the traceParent. + + + + + Gets or sets the TraceId of the traceParent. + + + + + Gets or sets the SpanId of the traceParent. + + + + + Gets or sets the TraceFlags of the traceParent. + + + + + Convert a traceParent string to TraceParent object. + + string representations of traceParent. + TraceParent object. + + + + Attribute used with the Durable Functions Analyzer to label a method as Deterministic. This allows the method to be called in an Orchestration function without causing a compiler warning. + + + + + The backend storage provider that provides the actual durability of Durable Functions. + This is functionally a superset of and . + If the storage provider does not any of the Durable Functions specific operations, they can use this class + directly with the expectation that only those interfaces will be implemented. All of the Durable Functions specific + methods/operations are virtual and can be overwritten by creating a subclass. + + + + + Creates the default . + + The name of the storage backend providing the durability. + The internal that provides functionality + for this classes implementions of . + The internal that provides functionality + for this classes implementions of . + The name of the app setting that stores connection details for the storage provider. + + + + The name of the environment variable that contains connection details for how to connect to storage providers. + Corresponds to the for binding data. + + + + + Specifies whether the durability provider supports Durable Entities. + + + + + JSON representation of configuration to emit in telemetry. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the status of all orchestration instances. + + A token to cancel the request. + Returns a task which completes when the status has been fetched. + + + + Gets the status of all orchestration instances within the specified parameters. + + Return orchestration instances which were created after this DateTime. + Return orchestration instances which were created before this DateTime. + Return orchestration instances which matches the runtimeStatus. + A token to cancel the request. + Returns a task which completes when the status has been fetched. + + + + Gets the state of the specified orchestration instance. + + The ID of the orchestration instance to query. + If set, fetch and return the input for the orchestration instance. + Returns a task which completes when the state has been fetched. + + + + Gets paginated result of all orchestration instances that match query status parameters. + + The filtering conditions of the query. + A token to cancel the request. + Paginated result of orchestration state. + + + + Purges history that meet the required parameters. + + Purge the history of orchestration instances which were created after this DateTime. + Purge the history of orchestration instances which were created before this DateTime. + Purge the history of orchestration instances which matches the runtimeStatus. + The number of instances purged. + + + + Purges the instance history for the provided instance id. + + The instance id for the instance history to purge. + The number of instances purged. + + + + Retrieves the state for a serialized entity. + + Entity id to fetch state for. + JsonSerializerSettings for custom deserialization. + State for the entity. + + + + Rewinds the specified failed orchestration instance with a reason. + + The ID of the orchestration instance to rewind. + The reason for rewinding the orchestration instance. + A task that completes when the rewind message is enqueued. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Uses durability provider specific logic to verify whether a timespan for a timer, timeout + or retry interval is allowed by the provider. + + The timespan that the code will have to wait for. + The error message if the timespan is invalid. + A boolean indicating whether the time interval is valid. + + + + Attribute used to bind a function parameter to a , , or instance. + + + + + Optional. Gets or sets the name of the task hub in which the orchestration data lives. + + The task hub used by this binding. + + The default behavior is to use the task hub name specified in . + If no value exists there, then a default value will be used. + + + + + Optional. Gets or sets the setting name for the app setting containing connection details used by this binding to connect + to instances of the storage provider other than the default one this application communicates with. + + The name of an app setting containing connection details. + + For Azure Storage the default behavior is to use the value of . + If no value exists there, then the default behavior is to use the standard `AzureWebJobsStorage` connection string for all storage usage. + + + + + Returns a hash code for this attribute. + + A hash code for this attribute. + + + + Compares two instances for value equality. + + The object to compare with. + true if the two attributes have the same configuration; otherwise false. + + + + Compares two instances for value equality. + + The object to compare with. + true if the two attributes have the same configuration; otherwise false. + + + + Represents the status of a durable entity instance. + + + + + Gets the EntityId of the queried entity instance. + + + The unique EntityId of the instance. + + + + + Gets the time of the last operation processed by the entity instance. + + + The last operation time in UTC. + + + + + Gets the state of the entity instance. + + + The state as either a JToken or null if no state was provided. + + + + + Request used to make an HTTP call through Durable Functions. + + + + + Initializes a new instance of the class. + + Method used for HTTP request. + Uri used to make the HTTP request. + Headers added to the HTTP request. + Content added to the body of the HTTP request. + AAD authentication attached to the HTTP request. + Specifies whether the DurableHttpRequest should handle the asynchronous pattern. + + + + HttpMethod used in the HTTP request made by the Durable Function. + + + + + Uri used in the HTTP request made by the Durable Function. + + + + + Headers passed with the HTTP request made by the Durable Function. + + + + + Content passed with the HTTP request made by the Durable Function. + + + + + Mechanism for attaching an OAuth token to the request. + + + + + Specifies whether the Durable HTTP APIs should automatically + handle the asynchronous HTTP pattern. + + + + + Response received from the HTTP request made by the Durable Function. + + + + + Initializes a new instance of the class. + + HTTP Status code returned from the HTTP call. + Headers returned from the HTTP call. + Content returned from the HTTP call. + + + + Status code returned from an HTTP request. + + + + + Headers in the response from an HTTP request. + + + + + Content returned from an HTTP request. + + + + + Creates a DurableHttpResponse from an HttpResponseMessage. + + HttpResponseMessage returned from the HTTP call. + A representing the result of the asynchronous operation. + + + + Represents the status of a durable orchestration instance. + + + An external client can fetch the status of an orchestration instance using + . + + + + + Gets the name of the queried orchestrator function. + + + The orchestrator function name. + + + + + Gets the ID of the queried orchestration instance. + + + The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either + auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format. + + + The unique ID of the instance. + + + + + Gets the time at which the orchestration instance was created. + + + If the orchestration instance is in the + status, this time represents the time at which the orchestration instance was scheduled. + + + The instance creation time in UTC. + + + + + Gets the time at which the orchestration instance last updated its execution history. + + + The last-updated time in UTC. + + + + + Gets the input of the orchestrator function instance. + + + The input as either a JToken or null if no input was provided. + + + + + Gets the output of the queried orchestration instance. + + + The output as either a JToken object or null if it has not yet completed. + + + + + Gets the runtime status of the queried orchestration instance. + + + Expected values include `Running`, `Pending`, `Failed`, `Canceled`, `Terminated`, `Completed`. + + + + + Gets the custom status payload (if any) that was set by the orchestrator function. + + + Orchestrator functions can set a custom status using . + + + The custom status as either a JToken object or null if no custom status has been set. + + + + + Gets the execution history of the orchestration instance. + + + The history log can be large and is therefore null by default. + It is populated only when explicitly requested in the call to + . + + + The output as a JArray object or null. + + + + + Configuration for the Durable Functions extension. + + + + + Initializes a new instance of the . + + The configuration options for this extension. + The logger factory used for extension-specific logging and orchestration tracking. + The name resolver to use for looking up application settings. + The factory used to create orchestration service based on the configured storage provider. + The HTTP message handler that handles HTTP requests and HTTP responses. + The host shutdown notification service for detecting and reacting to host shutdowns. + The lifecycle notification helper used for custom orchestration tracking. + The factory used to create for message settings. + The factory used to create for error settings. + The activator of DistributedTracing. .netstandard2.0 only. + + + + Internal initialization call from the WebJobs host. + + Extension context provided by WebJobs. + + + + + + + Deletes all data stored in the current task hub. + + A task representing the async delete operation. + + + + Called by the Durable Task Framework: Not used. + + This parameter is not used. + + + + Called by the Durable Task Framework: Returns the specified . + + The name of the orchestration to return. + Not used. + An orchestration shim that delegates execution to an orchestrator function. + + + + Called by the durable task framework: Not used. + + This parameter is not used. + + + + Called by the Durable Task Framework: Returns the specified . + + The name of the activity to return. + Not used. + An activity shim that delegates execution to an activity function. + + + + Gets a using configuration from a instance. + + The attribute containing the client configuration parameters. + Returns a instance. The returned instance may be a cached instance. + + + + + + + Extension for registering a Durable Functions configuration with JobHostConfiguration. + + + + + Adds the Durable Task extension to the provided . + + The to configure. + Returns the provided . + + + + Adds the Durable Task extension to the provided . + + The to configure. + The configuration options for this extension. + Returns the provided . + + + + Adds the Durable Task extension to the provided . + + The to configure. + An to configure the provided . + Returns the modified object. + + + + Query condition for searching the status of entity instances. + + + + + Return entity instances associated with this entity name. + + + + + Return entity instances which had operations after this DateTime. + + + + + Return entity instances which had operations before this DateTime. + + + + + Number of records per one request. The default value is 100. + + + + + ContinuationToken of the pager. + + + + + Determines whether the query will include the state of the entity. + + + + + The status of all entity instances with paging for a given query. + + + + + Gets or sets a collection of statuses of entity instances matching the query description. + + A collection of entity instance status values. + + + + Gets or sets a token that can be used to resume the query with data not already returned by this query. + + A server-generated continuation token or null if there are no further continuations. + + + + Statically accessible context for entity operations. + + + + + The context of the currently executing entity. + + + + + Sets the current context to a mocked context for unit testing. + + The mocked context. + + + + Information about the current status of an operation executing on an entity. + Excludes potentially large data (such as the operation input) so it can be read with low latency. + + + + + The name of the operation. + + + + + The unique identifier for this operation. + + + + + The parent instance that called this operation. + + + + + The UTC time at which the entity started processing this operation. + + + + + A unique identifier for an entity, consisting of entity name and entity key. + + + + + Create an entity id for an entity. + + The name of this class of entities. + The entity key. + + + + The name for this class of entities. + + + + + The entity key. Uniquely identifies an entity among all entities of the same name. + + + + + + + + + + + + + + + + + + + + Determines event names to use for messages sent to and from entities. + + + + + Exception used to describe various issues encountered by the entity scheduler. + + + + + Initializes a new instance of the class. + + + + + Initializes an new instance of the class. + + The message that describes the error. + The exception that was caught. + + + + Initializes a new instance of the class with serialized data. + + The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown. + The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination. + + + + The response returned by . + + The JSON-serializable type of the entity. + + + + Whether this entity exists or not. + + + + + The current state of the entity, if it exists, or default() otherwise. + + + + + Information about the current status of an entity. Excludes potentially large data + (such as the entity state, or the contents of the queue) so it can always be read with low latency. + + + + + Whether this entity exists or not. + + + + + The size of the queue, i.e. the number of operations that are waiting for the current operation to complete. + + + + + The instance id of the orchestration that currently holds the lock of this entity. + + + + + The operation that is currently executing on this entity. + + + + + The exception that is thrown when application code violates the locking rules. + + + + + provides message ordering and deduplication of request messages (operations or lock requests) + that are sent to entities, from other entities, or from orchestrations. + + + + + Used for testing purposes. + + + + + Called on the sending side, to fill in timestamp and predecessor fields. + + + + + Called on the receiving side, to reorder and deduplicate within the window. + + + + + Exception result representing an operation that failed, in case + the original exception is not serializable, or out-of-proc. + + + + + Initializes a new instance of the class. + + + + + Initializes an new instance of the class. + + The message that describes the error. + + + + Initializes a new instance of the class with serialized data. + + The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown. + The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination. + + + + Defines convenient overloads for creating entity proxy, for all the contexts. + + + + + Signals an entity to perform an operation. + + Entity interface. + orchestration client. + The target entity key. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation, at a specified time. + + Entity interface. + orchestration client. + The target entity key. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation. + + Entity interface. + orchestration client. + The target entity. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Signals an entity to perform an operation, at a specified time. + + Entity interface. + orchestration client. + The target entity. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + A task that completes when the message has been reliably enqueued. + + + + Create an entity proxy. + + orchestration context. + The target entity key. + Entity interface. + Entity proxy. + + + + Create an entity proxy. + + orchestration context. + The target entity. + Entity interface. + Entity proxy. + + + + Signals an entity to perform an operation. + + entity context. + The target entity key. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Signals an entity to perform an operation, at a specified time. + + entity context. + The target entity key. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Signals an entity to perform an operation. + + entity context. + The target entity. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Signals an entity to perform an operation, at a specified time. + + entity context. + The target entity. + The time at which to start the operation. + A delegate that performs the desired operation on the entity. + Entity interface. + + + + Provides the base implementation for the entity proxy. + + + + + Create an entity proxy. + + context. + Entity id. + + + + Call entity function. + + The name of the operation. + The input for the operation. + A representing the result of the asynchronous operation. + + + + Call entity function. + + The return type of the called entity function. + The name of the operation. + The input for the operation. + A representing the result of the asynchronous operation. + + + + Signal entity function. + + The name of the operation. + The input for the operation. + + + + Abstract entity proxy context. + + + + + Call entity function. + + Entity id. + Entity operation name. + Entity input value. + A representing the result of the asynchronous operation. + + + + Call entity function. + + Result type. + Entity id. + Entity operation name. + Entity input value. + A representing the result of the asynchronous operation. + + + + Signal entity function. + + Entity id. + Entity operation name. + Entity input value. + + + + A message that represents an operation request or a lock request. + + + + + The name of the operation being called (if this is an operation message) or null + (if this is a lock request). + + + + + Whether or not this is a one-way message. + + + + + The operation input. + + + + + A unique identifier for this operation. + + + + + The parent instance that called this operation. + + + + + The parent instance that called this operation. + + + + + Optionally, a scheduled time at which to start the operation. + + + + + A timestamp for this request. + Used for duplicate filtering and in-order delivery. + + + + + A timestamp for the predecessor request in the stream, or DateTime.MinValue if none. + Used for duplicate filtering and in-order delivery. + + + + + For lock requests, the set of locks being acquired. Is sorted, + contains at least one element, and has no repetitions. + + + + + For lock requests involving multiple locks, the message number. + + + + + The persisted state of an entity scheduler, as handed forward between ContinueAsNew instances. + + + + + Whether this entity exists or not. + + + + + The serialized entity state. This can be stale while CurrentStateView != null. + + + + + The queue of waiting operations, or null if none. + + + + + The instance id of the orchestration that currently holds the lock of this entity. + + + + + The metadata used for reordering and deduplication of messages sent to entities. + + + + + Extends the durable entity context to support reflection-based invocation of entity operations. + + + + + Dynamically dispatches the incoming entity operation using reflection. + + The class to use for entity instances. + A task that completes when the dispatched operation has finished. + If there is more than one method with the given operation name. + If there is no method with the given operation name. + If the method has more than one argument. + + If the entity's state is null, an object of type is created first. Then, reflection + is used to try to find a matching method. This match is based on the method name + (which is the operation name) and the argument list (which is the operation content, deserialized into + an object array). + + Context object to use to dispatch entity operations. + Parameters to feed to the entity constructor. Should be primarily used for + output bindings. Parameters must match the order in the constructor after ignoring parameters populated on + constructor via dependency injection. + + + + ETW Event Provider for the WebJobs.Extensions.DurableTask extension. + + + + + The exception that is thrown when a sub-orchestrator or activity function fails + with an error. + + + The `InnerException` property of this instance will contain additional information + about the failed sub-orchestrator or activity function. + + + + + Initializes a new instance of a . + + A message describing where to look for more details. + + + + Initializes a new instance of a . + + A message describing where to look for more details. + The exception that caused the function to fail. + + + + The name of a durable function. + + + + + Initializes a new instance of the struct. + + The name of the function. + + + + Gets the name of the function without the version. + + + The name of the activity function without the version. + + + + + Compares two objects for equality. + + The first to compare. + The second to compare. + true if the two objects are equal; otherwise false. + + + + Compares two objects for inequality. + + The first to compare. + The second to compare. + true if the two objects are not equal; otherwise false. + + + + Gets a value indicating whether to objects + are equal using value semantics. + + The other object to compare to. + true if the two objects are equal using value semantics; otherwise false. + + + + Gets a value indicating whether to objects + are equal using value semantics. + + The other object to compare to. + true if the two objects are equal using value semantics; otherwise false. + + + + Calculates a hash code value for the current instance. + + A 32-bit hash code value. + + + + Gets the string value of the current instance. + + The name and optional version of the current instance. + + + + The type of a function. + + + + + Class for creating deterministic . + + + + + Data structure containing orchestration instance creation HTTP endpoints. + + + + + Gets the HTTP POST orchestration instance creation endpoint URL. + + + The HTTP URL for creating a new orchestration instance. + + + + + Gets the HTTP POST orchestration instance create-and-wait endpoint URL. + + + The HTTP URL for creating a new orchestration instance and waiting on its completion. + + + + + Data structure containing status, terminate and send external event HTTP endpoints. + + + + + Gets the ID of the orchestration instance. + + + The ID of the orchestration instance. + + + + + Gets the HTTP GET status query endpoint URL. + + + The HTTP URL for fetching the instance status. + + + + + Gets the HTTP POST external event sending endpoint URL. + + + The HTTP URL for posting external event notifications. + + + + + Gets the HTTP POST instance termination endpoint. + + + The HTTP URL for posting instance termination commands. + + + + + Gets the HTTP POST instance rewind endpoint. + + + The HTTP URL for rewinding orchestration instances. + + + + + Gets the HTTP DELETE purge instance history by instance ID endpoint. + + + The HTTP URL for purging instance history by instance ID. + + + + + Custom service interface for signaling the extension when the function app is starting up or shutting down. + + + This interface is expected to be used as an injected service. We use a "wrapper" interface instead of + directly using the "real" IApplicationLifetime interface so that we can have an injected service + that is available in both .NET Core (Functions 2.0+) and .NET Framework (Functions 1.0). + + + + + Gets a that can be used to detect function app startup events. + + + A that is signalled when the function app has started up. + + + + + Gets a that can be used to detect function app stopping events. + + + A that is signalled when the function app is beginning to shut down. + + + + + Gets a that can be used to detect function app shutdown events. + + + A that is signalled when the function app has completed shutting down. + + + + + Interface defining methods to resolve connection strings. + + + + + Looks up a connection string value given a name. + + The name of the connection string. + Returns the resolved connection string value. + + + + Interface defining methods to build instances of . + + + + + Creates or retrieves a durability provider to be used throughout the extension. + + An durability provider to be used by the Durable Task Extension. + + + + Creates or retrieves a cached durability provider to be used in a given function execution. + + A durable client attribute with parameters for the durability provider. + A durability provider to be used by a client function. + + + + Interface used for testing Durable HTTP. + + + + + Creates an HttpClientHandler and returns it. + + Returns an HttpClientHandler. + + + + Interface defining methods to build instances of for error serialization. + + + + + Creates or retrieves to be used throughout the extension for error serialization. + + to be used by the Durable Task Extension for error serialization. + + + + Interface defining methods to life cycle notifications. + + + + + The orchestrator was starting. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + The orchestrator function is currently replaying itself. + A task that completes when the lifecycle notification message has been sent. + + + + The orchestrator was completed. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + The orchestration completed with ContinueAsNew as is in the process of restarting. + The orchestrator function is currently replaying itself. + A task that completes when the lifecycle notification message has been sent. + + + + The orchestrator was failed. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + Additional data associated with the tracking event. + The orchestrator function is currently replaying itself. + A task that completes when the lifecycle notification message has been sent. + + + + The orchestrator was terminated. + + The name of the task hub. + The name of the orchestrator function to call. + The ID to use for the orchestration instance. + Additional data associated with the tracking event. + A task that completes when the lifecycle notification message has been sent. + + + + Interface defining methods to build instances of for message serialization. + + + + + Creates or retrieves to be used throughout the extension for message serialization. + + to be used by the Durable Task Extension for message serialization. + + + + Implementations of this interface can be used to provide authorization tokens for outbound HTTP requests. + + + + + Gets a token for a resource. + + A representing the result of the asynchronous operation. + + + + The number of partitions in the task hub. + + + + + The number of messages across control queues. This will + be in the form of a serialized array of ints, e.g. "[1,2,3,4]". + + + + + The latency of messages across control queues. This will + be in the form of a serialized array of TimeSpans in string + format, e.g. "["00:00:00.0010000","00:00:00.0020000","00:00:00.0030000","00:00:00.0040000"]". + + + + + The number of messages in the work-item queue. + + + + + The approximate age of the first work-item queue message. This + will be a TimeSpan in string format, e.g. "00:00:00.0010000". + + + + + Not intended for public consumption. + + + + + Initializes a new instance of the class. + + The orchestration execution context. + + + + Not intended for public consumption. + + The result of the out-of-proc execution. + true if there are more executions to process; false otherwise. + + + + Task activity implementation which delegates the implementation to a function. + + + + + Common functionality of and . + + + + + Implements the entity scheduler as a looping orchestration. + There is one such orchestration per entity. + The orchestration terminates if the entity is deleted and idle. + The orchestration calls ContinueAsNew when it is idle, but not deleted. + + + + + The results of executing a batch of operations on the entity out of process. + + + + + Whether the entity exists after executing the batch. + This is false if the last operation in the batch deletes the entity, + and true otherwise. + + + + + The state of the entity after executing the batch. + Should be null if is false. + + + + + The results of executing the operations. The length of this list must always match + the size of the batch, even if there were exceptions. + + + + + The list of signals sent by the entity. Can be empty. + + + + + The results of executing an operation. + + + + + The returned value or error/exception. + + + + + Determines whether is a normal result, or an error/exception. + + + + + The measured duration of this operation's execution, in milliseconds. + + + + + Describes a signal that was emitted by one of the operations in the batch. + + + + + The destination of the signal. + + + + + The name of the operation being signaled. + + + + + The input of the operation being signaled. + + + + + Task orchestration implementation which delegates the orchestration implementation to a function. + + + + + Token Source implementation for Azure Managed Identities. + + + + + Initializes a new instance of the class. + + + The Azure Active Directory resource identifier of the web API being invoked. + For example, https://management.core.windows.net/ or https://graph.microsoft.com/. + + + + + Gets the Azure Active Directory resource identifier of the web API being invoked. + For example, https://management.core.windows.net/ or https://graph.microsoft.com/. + + + + + + + + JSON-serializes the specified object. + + + + + JSON-serializes the specified object and throws a if the + resulting JSON exceeds the maximum size specified by . + + + + + Configuration options for the Azure Storage storage provider. + + + + + Gets or sets the name of the Azure Storage connection string used to manage the underlying Azure Storage resources. + + + If not specified, the default behavior is to use the standard `AzureWebJobsStorage` connection string for all storage usage. + + The name of a connection string that exists in the app's application settings. + + + + Gets or sets the number of messages to pull from the control queue at a time. + + + Messages pulled from the control queue are buffered in memory until the internal + dispatcher is ready to process them. + + A positive integer configured by the host. The default value is 32. + + + + Gets or sets the partition count for the control queue. + + + Increasing the number of partitions will increase the number of workers + that can concurrently execute orchestrator functions. However, increasing + the partition count can also increase the amount of load placed on the storage + account and on the thread pool if the number of workers is smaller than the + number of partitions. + + A positive integer between 1 and 16. The default value is 4. + + + + Gets or set the number of control queue messages that can be buffered in memory + at a time, at which point the dispatcher will wait before dequeuing any additional + messages. The default is 256. The maximum value is 1000. + + + Increasing this value can improve orchestration throughput by pre-fetching more + orchestration messages from control queues. The downside is that it increases the + possibility of duplicate function executions if partition leases move between app + instances. This most often occurs when the number of app instances changes. + + A non-negative integer between 0 and 1000. The default value is 256. + + + + Gets or sets the visibility timeout of dequeued control queue messages. + + + A TimeSpan configured by the host. The default is 5 minutes. + + + + + Gets or sets the visibility timeout of dequeued work item queue messages. + + + A TimeSpan configured by the host. The default is 5 minutes. + + + + + Gets or sets the name of the Azure Storage connection string to use for the + durable tracking store (History and Instances tables). + + + If not specified, the connection string + is used for the durable tracking store. + + This property is primarily useful when deploying multiple apps that need to share the same + tracking infrastructure. For example, when deploying two versions of an app side by side, using + the same tracking store allows both versions to save history into the same table, which allows + clients to query for instance status across all versions. + + The name of a connection string that exists in the app's application settings. + + + + Gets or sets the name prefix to use for history and instance tables in Azure Storage. + + + This property is only used when is specified. + If no prefix is specified, the default prefix value is "DurableTask". + + The prefix to use when naming the generated Azure tables. + + + + Gets or sets whether the extension will automatically fetch large messages in orchestration status + queries. If set to false, the extension will return large messages as a blob url. + + A boolean indicating whether will automatically fetch large messages . + + + + Gets or sets the maximum queue polling interval. + + Maximum interval for polling control and work-item queues. + + + + Throws an exception if the provided hub name violates any naming conventions for the storage provider. + + + + + Throws an exception if any of the settings of the storage provider are invalid. + + + + + Configuration options for the Durable Task extension. + + + + + Settings used for Durable HTTP functionality. + + + + + Gets or sets default task hub name to be used by all , , , + , and instances. + + + A task hub is a logical grouping of storage resources. Alternate task hub names can be used to isolate + multiple Durable Functions applications from each other, even if they are using the same storage backend. + + The name of the default task hub. + + + + The section of configuration related to storage providers. If using Azure Storage provider, the schema should match + . + + + + + The section of configuration related to tracing. + + + + + The section of configuration related to notifications. + + + + + Gets or sets the maximum number of activity functions that can be processed concurrently on a single host instance. + + + Increasing activity function concurrent can result in increased throughput but can + also increase the total CPU and memory usage on a single worker instance. + + + A positive integer configured by the host. The default value is 10X the number of processors on the current machine. + + + + + Gets or sets the maximum number of orchestrator functions that can be processed concurrently on a single host instance. + + + A positive integer configured by the host. The default value is 10X the number of processors on the current machine. + + + + + Gets or sets the base URL for the HTTP APIs managed by this extension. + + + This property is intended for use only by runtime hosts. + + + A URL pointing to the hosted function app that responds to status polling requests. + + + + + Gets or sets a value indicating whether to enable the local RPC endpoint managed by this extension. + + + The local RPC endpoint is intended to allow out-of-process functions to make direct calls into this + extension. This is primarily intended to support instance management APIs used by the durable client + binding. The following values are allowed: + + + null + (Default) The local RPC endpoint is enabled only for non-.NET function apps. + + + true + A local RPC endpoint will be enabled and listen at http://127.0.0.1:17071/durabletask/. + + + false + The local RPC endpoint will be disabled. + + + + + + + Gets or sets a flag indicating whether to enable extended sessions. + + + Extended sessions can improve the performance of orchestrator functions by allowing them to skip + replays when new messages are received within short periods of time. + Note that orchestrator functions which are extended this way will continue to count against the + limit. To avoid starvation, only half of the maximum + number of allowed concurrent orchestrator functions can be concurrently extended at any given time. + The property can also be used to control how long an idle + orchestrator function is allowed to be extended. + It is recommended that this property be set to false during development to help + ensure that the orchestrator code correctly obeys the idempotency rules. + + + true to enable extended sessions; otherwise false. + + + + + Gets or sets the amount of time in seconds before an idle session times out. The default value is 30 seconds. + + + This setting is applicable when is set to true. + + + The number of seconds before an idle session times out. + + + + + Gets or sets the maximum number of orchestration actions. The default value is 100,000. + + + + + States that will override an existing orchestrator when attempting to start a new orchestrator with the same instance Id. + + + + + Gets or sets the time window within which entity messages get deduplicated and reordered. + + + + + Preview setting for gracefully shutting down to prevent WebJob shutdowns from failing + activities or orchestrations. + + + + + Sets HubName to a value that is considered a default value. + + TaskHub name that is considered the default. + + + + Configuration of the Event Grid notification options + for the Durable Task Extension. + + + + + Gets or sets the URL of an Azure Event Grid custom topic endpoint. + When set, orchestration life cycle notification events will be automatically + published to this endpoint. + + + Azure Event Grid topic URLs are generally expected to be in the form + https://{topic_name}.{region}.eventgrid.azure.net/api/events. + + + The Azure Event Grid custom topic URL. + + + + + Gets or sets the name of the app setting containing the key used for authenticating with the Azure Event Grid custom topic at . + + + The name of the app setting that stores the Azure Event Grid key. + + + + + Gets or sets the Event Grid publish request retry count. + + The number of retry attempts. + + + + Gets orsets the Event Grid publish request retry interval. + + A representing the retry interval. The default value is 5 minutes. + + + + Gets or sets the Event Grid publish request http status. + + A list of HTTP status codes, e.g. 400, 403. + + + + Gets or sets the event types that will be published to Event Grid. + + + A list of strings. Possible values 'Started', 'Completed', 'Failed', 'Terminated'. + + + + + Used for Durable HTTP functionality. + + + + + Reserved name to know when a TaskActivity should be an HTTP activity. + + + + + Gets or sets the default number of milliseconds between async HTTP status poll requests. + + + + + Configuration of the notification options + for the Durable Task Extension. + + + + + The section of configuration related to Event Grid notifications. + + + + + Configuration of the trace options + for the Durable Task Extension. + + + + + Gets or sets a value indicating whether to trace the inputs and outputs of function calls. + + + The default behavior when tracing function execution events is to include the number of bytes in the serialized + inputs and outputs for function calls. This provides minimal information about what the inputs and outputs look + like without bloating the logs or inadvertently exposing sensitive information to the logs. Setting + to true will instead cause the default function logging to log + the entire contents of function inputs and outputs. + + + true to trace the raw values of inputs and outputs; otherwise false. + + + + + Gets or sets if logs for replay events need to be recorded. + + + The default value is false, which disables the logging of replay events. + + + Boolean value specifying if the replay events should be logged. + + + + + Gets or sets a flag indicating whether to enable distributed tracing. + The default value is true. + + + + + Gets or sets a protocol for distributed Tracing. + Possible values are "HttpCorrelationProtocol" and "W3CTraceContext". + The default value is "HttpCorrelationProtocol". + + + + + Represents the possible runtime execution status values for an orchestration instance. + + + + + The status of the orchestration could not be determined. + + + + + The orchestration is running (it may be actively running or waiting for input). + + + + + The orchestration ran to completion. + + + + + The orchestration completed with ContinueAsNew as is in the process of restarting. + + + + + The orchestration failed with an error. + + + + + The orchestration was canceled. + + + + + The orchestration was terminated via an API call. + + + + + The orchestration was scheduled but has not yet started. + + + + + Query condition for searching the status of orchestration instances. + + + + + Initializes a new instance of the class. + + + + + Return orchestration instances which matches the runtimeStatus. + + + + + Return orchestration instances which were created after this DateTime. + + + + + Return orchestration instances which were created before this DateTime. + + + + + Return orchestration instances which matches the TaskHubNames. + + + + + Number of records per one request. The default value is 100. + + + + + ContinuationToken of the pager. + + + + + Return orchestration instances that have this instance id prefix. + + + + + Determines whether the query will include the input of the orchestration. + + + + + The status of all orchestration instances with paging for a given query. + + + + + Gets or sets a collection of statuses of orchestration instances matching the query description. + + A collection of orchestration instance status values. + + + + Gets or sets a token that can be used to resume the query with data not already returned by this query. + + A server-generated continuation token or null if there are no further continuations. + + + + Represents options for different states that an existing orchestrator can be in to be able to be overwritten by + an attempt to start a new instance with the same instance Id. + + + + + Option to start a new orchestrator instance with an existing instnace Id when the existing + instance is in any state. + + + + + Option to only start a new orchestrator instance with an existing instance Id when the existing + instance is in a terminated, failed, or completed state. + + + + + Class to hold statistics about this execution of purge history. + + + + + Constructor for purge history statistics. + + Number of instances deleted. + + + + Gets the number of deleted instances. + + The number of deleted instances. + + + + Defines retry policies that can be passed as parameters to various operations. + + + + + Creates a new instance RetryOptions with the supplied first retry and max attempts. + + Timespan to wait for the first retry. + Max number of attempts to retry. + + The value must be greater than . + + + + + Gets or sets the first retry interval. + + + The TimeSpan to wait for the first retries. + + + + + Gets or sets the max retry interval. + + + The TimeSpan of the max retry interval, defaults to . + + + + + Gets or sets the backoff coefficient. + + + The backoff coefficient used to determine rate of increase of backoff. Defaults to 1. + + + + + Gets or sets the timeout for retries. + + + The TimeSpan timeout for retries, defaults to . + + + + + Gets or sets the max number of attempts. + + + The maximum number of retry attempts. + + + + + Gets or sets a delegate to call on exception to determine if retries should proceed. + + + The delegate to handle exception to determie if retries should proceed. + + + + + Parameters for starting a new instance of an orchestration. + + + This class is primarily intended for use with IAsyncCollector<T>. + + + + + Initializes a new instance of the class. + + The name of the orchestrator function to start. + The JSON-serializeable input for the orchestrator function. + + + + Initializes a new instance of the class. + + + + + Gets or sets the name of the orchestrator function to start. + + The name of the orchestrator function to start. + + + + Gets or sets the instance ID to assign to the started orchestration. + + + If this property value is null (the default), then a randomly generated instance ID will be assigned automatically. + + The instance ID to assign. + + + + Gets or sets the JSON-serializeable input data for the orchestrator function. + + JSON-serializeable input value for the orchestrator function. + + + + Response for Orchestration Status Query. + + + + + Name. + + + + + InstanceId. + + + + + Runtime status. + + + + + Input. + + + + + Custom status. + + + + + Output. + + + + + Created time value. + + + + + Last updated time. + + + + + JSON object representing history for an orchestration execution. + + + + + Trigger attribute used for durable activity functions. + + + + + Gets or sets the name of the activity function. + + + The name of the activity function or null to use the function name. + + + + + Trigger attribute used for durable entity functions. + + + + + Gets or sets the name of the entity. + + + If not specified, the function name is used as the name of the entity. + + + The name of the entity or null to use the function name. + + + + + Trigger attribute used for durable orchestrator functions. + + + + + Gets or sets the name of the orchestrator function. + + + If not specified, the function name is used as the name of the orchestration. + + + The name of the orchestrator function or null to use the function name. + + + + + Connection string provider which resolves connection strings from the WebJobs context. + + + + + Initializes a new instance of the class. + + A object provided by the WebJobs host. + + + + + + diff --git a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml index 1b56e8793..7bc78d5ab 100644 --- a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml +++ b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml @@ -1433,6 +1433,167 @@ Now obsolete: use instead. + + + Telemetry Initializer that sets correlation ids for W3C. + This source is based on W3COperationCorrelationTelemetryInitializer.cs + 1. Modified with CorrelationTraceContext.Current + 2. Avoid to be overriden when it is RequestTelemetry + Original Source is here + + + + These internal property is copied from W3CConstants + Trace-Id tag name. + + + Span-Id tag name. + + + Parent span-Id tag name. + + + Version tag name. + + + Sampled tag name. + + + Tracestate tag name. + + + Default version value. + + + + Default sampled flag value: may be recorded, not requested + + + + Recorded and requested sampled flag value + + + Requested trace flag + + + Legacy root Id tag name. + + + Legacy root Id tag name. + + + + Set of suppress telemetry tracking if you add Host name on this. + + + + + Constructor + + + + + Initializes telemety item. + + Telemetry item. + + + + A stub of . + This is the copy of the https://github.com/Microsoft/ApplicationInsights-dotnet/Test/TestFramework/Shared/StubTelemetryClient + + + + + Initializes a new instance of the class. + + + + + Gets or sets a value indicating whether this channel is in developer mode. + + + + + Gets or sets a value indicating the channel's URI. To this URI the telemetry is expected to be sent. + + + + + Gets or sets a value indicating whether to throw an error. + + + + + Gets or sets the callback invoked by the method. + + + + + Implements the method by invoking the callback. + + + + + Implements the method. + + + + + Implements the method. + + + + + TelemetryActivator activates Distributed Tracing. This class only works for netstandard2.0. + + + + + Constructor for activating Distributed Tracing. + + DurableTask options. + + + + OnSend is an action that enable to hook of sending telemetry. + You can use this property for testing. + + + + + Initialize is initialize the telemetry client. + + + + + ITelemetryActivator is an interface. + + + + + Initialize is initialize the telemetry client. + + + + + TraceContextBase extension methods. + + + + + Create RequestTelemetry from the TraceContext. + + TraceContext. + RequestTelemetry. + + + + Create DependencyTelemetry from the Activity. + + TraceContext. + DependencyTelemetry. + Attribute used with the Durable Functions Analyzer to label a method as Deterministic. This allows the method to be called in an Orchestration function without causing a compiler warning. @@ -1912,7 +2073,7 @@ Configuration for the Durable Functions extension. - + Initializes a new instance of the . @@ -1925,6 +2086,7 @@ The lifecycle notification helper used for custom orchestration tracking. The factory used to create for message settings. The factory used to create for error settings. + The activator of DistributedTracing. .netstandard2.0 only. @@ -3429,6 +3591,19 @@ Boolean value specifying if the replay events should be logged. + + + Gets or sets a flag indicating whether to disable distributed tracing. + The default value is false. + + + + + Gets or sets a protocol for distributed Tracing. + Possible values are "HttpCorrelationProtocol" and "W3CTraceContext". + The default value is "HttpCorrelationProtocol". + + Represents the possible runtime execution status values for an orchestration instance. diff --git a/src/WebJobs.Extensions.DurableTask/Options/TraceOptions.cs b/src/WebJobs.Extensions.DurableTask/Options/TraceOptions.cs index 2dabcae49..95a3d8034 100644 --- a/src/WebJobs.Extensions.DurableTask/Options/TraceOptions.cs +++ b/src/WebJobs.Extensions.DurableTask/Options/TraceOptions.cs @@ -37,6 +37,21 @@ public class TraceOptions /// public bool TraceReplayEvents { get; set; } +#if !FUNCTIONS_V1 + /// + /// Gets or sets a flag indicating whether to enable distributed tracing. + /// The default value is true. + /// + public bool DistributedTracingEnabled { get; set; } = true; + + /// + /// Gets or sets a protocol for distributed Tracing. + /// Possible values are "HttpCorrelationProtocol" and "W3CTraceContext". + /// The default value is "HttpCorrelationProtocol". + /// + public string DistributedTracingProtocol { get; set; } = "HttpCorrelationProtocol"; + +#endif internal void AddToDebugString(StringBuilder builder) { builder.Append(nameof(this.TraceReplayEvents)).Append(": ").Append(this.TraceReplayEvents).Append(", "); diff --git a/src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj b/src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj index 7d4403ecf..e68a6c277 100644 --- a/src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj +++ b/src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj @@ -2,12 +2,12 @@ netstandard2.0;net461 - Microsoft.Azure.WebJobs.Extensions.DurableTask + Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry Microsoft.Azure.WebJobs.Extensions.DurableTask 2 2 0 - $(MajorVersion).$(MinorVersion).$(PatchVersion) + 2.2.0-alpha $(MajorVersion).$(MinorVersion).$(PatchVersion) $(MajorVersion).0.0.0 Microsoft Corporation @@ -41,8 +41,14 @@ FUNCTIONS_V1 + false + + + + + @@ -52,14 +58,21 @@ + + - + + + + + + @@ -73,10 +86,8 @@ - - - + diff --git a/test/Common/TestHelpers.cs b/test/Common/TestHelpers.cs index 448bb0cdd..b7e8a8cda 100644 --- a/test/Common/TestHelpers.cs +++ b/test/Common/TestHelpers.cs @@ -7,6 +7,10 @@ using System.Net.Http; using System.Threading.Tasks; using DurableTask.AzureStorage; +using Microsoft.ApplicationInsights.Channel; +#if !FUNCTIONS_V1 +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation; +#endif using Microsoft.Azure.WebJobs.Host.TestCommon; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -49,7 +53,8 @@ public static ITestHost GetJobHost( ILifeCycleNotificationHelper lifeCycleNotificationHelper = null, IMessageSerializerSettingsFactory serializerSettings = null, bool? localRpcEndpointEnabled = false, - DurableTaskOptions options = null) + DurableTaskOptions options = null, + Action onSend = null) { switch (storageProviderType) { @@ -131,7 +136,8 @@ public static ITestHost GetJobHost( nameResolver, durableHttpMessageHandler, lifeCycleNotificationHelper, - serializerSettings); + serializerSettings, + onSend); } public static ITestHost GetJobHostWithOptions( @@ -141,7 +147,8 @@ public static ITestHost GetJobHostWithOptions( INameResolver nameResolver = null, IDurableHttpMessageHandlerFactory durableHttpMessageHandler = null, ILifeCycleNotificationHelper lifeCycleNotificationHelper = null, - IMessageSerializerSettingsFactory serializerSettings = null) + IMessageSerializerSettingsFactory serializerSettings = null, + Action onSend = null) { if (serializerSettings == null) { @@ -156,13 +163,14 @@ public static ITestHost GetJobHostWithOptions( } return PlatformSpecificHelpers.CreateJobHost( - optionsWrapper, - storageProviderType, - loggerProvider, - testNameResolver, - durableHttpMessageHandler, - lifeCycleNotificationHelper, - serializerSettings); + options: optionsWrapper, + storageProvider: storageProviderType, + loggerProvider: loggerProvider, + nameResolver: testNameResolver, + durableHttpMessageHandler: durableHttpMessageHandler, + lifeCycleNotificationHelper: lifeCycleNotificationHelper, + serializerSettingsFactory: serializerSettings, + onSend: onSend); } public static DurableTaskOptions GetDurableTaskOptionsForStorageProvider(string storageProvider) diff --git a/test/FunctionsV1/PlatformSpecificHelpers.FunctionsV1.cs b/test/FunctionsV1/PlatformSpecificHelpers.FunctionsV1.cs index 45f8f48bb..c4f077330 100644 --- a/test/FunctionsV1/PlatformSpecificHelpers.FunctionsV1.cs +++ b/test/FunctionsV1/PlatformSpecificHelpers.FunctionsV1.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Reflection; using System.Threading.Tasks; +using Microsoft.ApplicationInsights.Channel; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -27,8 +28,9 @@ public static ITestHost CreateJobHost( INameResolver nameResolver, IDurableHttpMessageHandlerFactory durableHttpMessageHandler, ILifeCycleNotificationHelper lifeCycleNotificationHelper, - IMessageSerializerSettingsFactory serializerSettings, - IApplicationLifetimeWrapper shutdownNotificationService = null) + IMessageSerializerSettingsFactory serializerSettingsFactory, + IApplicationLifetimeWrapper shutdownNotificationService = null, + Action onSend = null) { var config = new JobHostConfiguration { HostId = "durable-task-host" }; config.TypeLocator = TestHelpers.GetTypeLocator(); @@ -48,7 +50,7 @@ public static ITestHost CreateJobHost( shutdownNotificationService ?? new TestHostShutdownNotificationService(), durableHttpMessageHandler, lifeCycleNotificationHelper, - serializerSettings); + serializerSettingsFactory); config.UseDurableTask(extension); // Mock INameResolver for not setting EnvironmentVariables. diff --git a/test/FunctionsV1/WebJobs.Extensions.DurableTask.Tests.V1.csproj b/test/FunctionsV1/WebJobs.Extensions.DurableTask.Tests.V1.csproj index 64558a4da..c39f6e464 100644 --- a/test/FunctionsV1/WebJobs.Extensions.DurableTask.Tests.V1.csproj +++ b/test/FunctionsV1/WebJobs.Extensions.DurableTask.Tests.V1.csproj @@ -16,7 +16,7 @@ - + diff --git a/test/FunctionsV2/CorrelationEndToEndTests.cs b/test/FunctionsV2/CorrelationEndToEndTests.cs new file mode 100644 index 000000000..ec5f55730 --- /dev/null +++ b/test/FunctionsV2/CorrelationEndToEndTests.cs @@ -0,0 +1,253 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DurableTask.AzureStorage; +using DurableTask.Core; +using DurableTask.Core.Settings; +using FluentAssertions.Collections; +using Microsoft.ApplicationInsights.Channel; +using Microsoft.ApplicationInsights.DataContracts; +using Microsoft.ApplicationInsights.Extensibility.Implementation; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests; +using Microsoft.Azure.WebJobs.Host.TestCommon; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests +{ + [Collection("Non-Parallel Collection")] + public class CorrelationEndToEndTests + { + private readonly ITestOutputHelper output; + private readonly TestLoggerProvider loggerProvider; + + public CorrelationEndToEndTests(ITestOutputHelper output) + { + this.output = output; + this.loggerProvider = new TestLoggerProvider(output); + } + + [Theory] + [Trait("Category", PlatformSpecificHelpers.TestCategory)] + [InlineData(false, "W3CTraceContext")] + [InlineData(true, "HttpCorrelationProtocol")] + [InlineData(true, "W3CTraceContext")] + [InlineData(false, "HttpCorrelationProtocol")] + public async Task SingleOrchestration_With_Activity(bool extendedSessions, string protocol) + { + string[] orchestrationFunctionNames = + { + nameof(TestOrchestrations.SayHelloWithActivity), + }; + + var result = await + this.ExecuteOrchestrationWithExceptionAsync( + orchestrationFunctionNames, + "SingleOrchestration", + "world", + extendedSessions, + protocol); + var actual = result.Item1; + Assert.Equal(5, actual.Count); + Assert.Empty(result.Item2); + Assert.Equal( + new (Type, string)[] + { + (typeof(RequestTelemetry), $"{TraceConstants.Client}: "), + (typeof(DependencyTelemetry), TraceConstants.Client), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} SayHelloWithActivity"), + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} Hello"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} Hello"), + }.ToList(), actual.Select(x => (x.GetType(), x.Name)).ToList()); + } + + [Theory] + [Trait("Category", PlatformSpecificHelpers.TestCategory)] + [InlineData(false, "W3CTraceContext")] + [InlineData(true, "HttpCorrelationProtocol")] + [InlineData(true, "W3CTraceContext")] + [InlineData(false, "HttpCorrelationProtocol")] + public async Task AllOrchestrationActivityActions(bool extendedSessions, string protocol) + { + string[] orchestrationFunctionNames = + { + nameof(TestOrchestrations.AllOrchestratorActivityActions), + }; + + var counterEntityId = new EntityId("Counter", Guid.NewGuid().ToString()); + + var result = await + this.ExecuteOrchestrationWithExceptionAsync( + orchestrationFunctionNames, + nameof(this.AllOrchestrationActivityActions), + counterEntityId, + extendedSessions, + protocol); + var actual = result.Item1; + Assert.Equal(15, actual.Count); + Assert.Single(result.Item2); // Error inside of HttpActivity since the request set to null. + Assert.Equal( + new (Type, string)[] + { + (typeof(RequestTelemetry), $"{TraceConstants.Client}: "), // start orchestration + (typeof(DependencyTelemetry), TraceConstants.Client), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} AllOrchestratorActivityActions"), // Orchestrator started + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} Hello"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} Hello"), // Activity Hello Started + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} Hello"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} Hello"), // Activity Hello Started + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} SayHelloInline"), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} SayHelloInline"), // SubOrchestrator SayHelloInline Started + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} SayHelloWithActivity"), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} SayHelloWithActivity"), // SubOrchestrator SayHelloWithActivity Started + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} Hello"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} Hello"), // Activity Hello Started by SubOrchestrator SayHelloWithActivity + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} BuiltIn::HttpActivity"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} BuiltIn::HttpActivity"), // HttpActivity Started + }.ToList(), actual.Select(x => (x.GetType(), x.Name)).ToList()); + } + + internal async Task, List>> + ExecuteOrchestrationWithExceptionAsync( + string[] orchestratorFunctionNames, + string testName, + object input, + bool extendedSessions, + string protocol) + { + ConcurrentQueue sendItems = new ConcurrentQueue(); + var sendAction = new Action( + delegate(ITelemetry telemetry) { sendItems.Enqueue(telemetry); }); + using (var host = TestHelpers.GetJobHost( + this.loggerProvider, + testName, + extendedSessions, + options: new DurableTaskOptions() + { + Tracing = new TraceOptions() + { + DistributedTracingProtocol = protocol, + }, + }, + onSend: sendAction)) + { + await host.StartAsync(); + var client = await host.StartOrchestratorAsync(orchestratorFunctionNames[0], input, this.output); + var status = await client.WaitForCompletionAsync(this.output, timeout: TimeSpan.FromSeconds(90)); + await host.StopAsync(); + } + + var sendItemList = this.ConvertTo(sendItems); + var operationTelemetryList = sendItemList.OfType(); + var exceptionTelemetryList = sendItemList.OfType().ToList(); + var result = this.FilterOperationTelemetry(operationTelemetryList).ToList(); + return new Tuple, List>(result.CorrelationSort(), exceptionTelemetryList); + } + + private IEnumerable FilterOperationTelemetry(IEnumerable operationTelemetries) + { + return operationTelemetries.Where( + p => p.Name.Contains(TraceConstants.Activity) || p.Name.Contains(TraceConstants.Orchestrator) || p.Name.Contains(TraceConstants.Client) || p.Name.Contains("Operation")); + } + + private List ConvertTo(ConcurrentQueue queue) + { + var converted = new List(); + while (!queue.IsEmpty) + { + ITelemetry x; + if (queue.TryDequeue(out x)) + { + converted.Add(x); + } + } + + return converted; + } + } + +#pragma warning disable SA1402 + public static class ListExtensions + { + public static List CorrelationSort(this List telemetries) + { + var result = new List(); + if (telemetries.Count == 0) + { + return result; + } + + // Sort by the timestamp + var sortedTelemetries = telemetries.OrderBy(p => p.Timestamp.Ticks).ToList(); + + // pick the first one as the parent. remove it from the list. + var parent = sortedTelemetries.First(); + result.Add(parent); + sortedTelemetries.RemoveOperationTelemetry(parent); + + // find the child recursively and remove the child and pass it as a parameter + var sortedList = GetCorrelationSortedList(parent, sortedTelemetries); + result.AddRange(sortedList); + return result; + } + + public static bool RemoveOperationTelemetry(this List telemetries, OperationTelemetry telemetry) + { + int index = -1; + for (var i = 0; i < telemetries.Count; i++) + { + if (telemetries[i].Id == telemetry.Id) + { + index = i; + } + } + + if (index == -1) + { + return false; + } + + telemetries.RemoveAt(index); + return true; + } + + private static List GetCorrelationSortedList(OperationTelemetry parent, List current) + { + var result = new List(); + if (current.Count != 0) + { + foreach (var some in current) + { + if (parent.Id == some.Context.Operation.ParentId) + { + Console.WriteLine("match"); + } + } + + IOrderedEnumerable nexts = current.Where(p => p.Context.Operation.ParentId == parent.Id).OrderBy(p => p.Timestamp.Ticks); + foreach (OperationTelemetry next in nexts) + { + current.RemoveOperationTelemetry(next); + result.Add(next); + var childResult = GetCorrelationSortedList(next, current); + result.AddRange(childResult); + } + } + + return result; + } + } + + [CollectionDefinition("Non-Parallel Collection", DisableParallelization = true)] + public class NonParallelCollectionDefinitionClass + { + } +#pragma warning restore SA1402 +} diff --git a/test/FunctionsV2/PlatformSpecificHelpers.FunctionsV2.cs b/test/FunctionsV2/PlatformSpecificHelpers.FunctionsV2.cs index a849a4ca5..454acc3ee 100644 --- a/test/FunctionsV2/PlatformSpecificHelpers.FunctionsV2.cs +++ b/test/FunctionsV2/PlatformSpecificHelpers.FunctionsV2.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Reflection; using System.Threading.Tasks; +using Microsoft.ApplicationInsights.Channel; +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -28,7 +30,8 @@ public static ITestHost CreateJobHost( INameResolver nameResolver, IDurableHttpMessageHandlerFactory durableHttpMessageHandler, ILifeCycleNotificationHelper lifeCycleNotificationHelper, - IMessageSerializerSettingsFactory serializerSettingsFactory) + IMessageSerializerSettingsFactory serializerSettingsFactory, + Action onSend) { IHost host = new HostBuilder() .ConfigureLogging( @@ -59,6 +62,19 @@ public static ITestHost CreateJobHost( { serviceCollection.AddSingleton(serializerSettingsFactory); } + + if (onSend != null) + { + serviceCollection.AddSingleton(serviceProvider => + { + var durableTaskOptions = serviceProvider.GetService>(); + var telemetryActivator = new TelemetryActivator(durableTaskOptions) + { + OnSend = onSend, + }; + return telemetryActivator; + }); + } }) .Build(); diff --git a/test/FunctionsV2/TraceParentTest.cs b/test/FunctionsV2/TraceParentTest.cs new file mode 100644 index 000000000..d898456c2 --- /dev/null +++ b/test/FunctionsV2/TraceParentTest.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Correlation; +using Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests; +using Xunit; +using Xunit.Extensions; + +namespace WebJobs.Extensions.DurableTask.Tests.V2 +{ + public class TraceParentTest + { + [Fact] + [Trait("Category", PlatformSpecificHelpers.TestCategory)] + public void FromString_NormalCase() + { + var expectedVersion = "00"; + var expectedTraceId = "0af7651916cd43dd8448eb211c80319c"; + var expectedSpanId = "00f067aa0ba902b7"; + var expectedTraceFlags = "01"; + var actual = TraceParent.FromString($"{expectedVersion}-{expectedTraceId}-{expectedSpanId}-{expectedTraceFlags}"); + Assert.Equal(expectedVersion, actual.Version); + Assert.Equal(expectedTraceId, actual.TraceId); + Assert.Equal(expectedSpanId, actual.SpanId); + Assert.Equal(expectedTraceFlags, actual.TraceFlags); + } + + [Fact] + [Trait("Category", PlatformSpecificHelpers.TestCategory)] + public void FromString_Exception() + { + var ex = Assert.Throws(() => { TraceParent.FromString("foobar"); }); + Assert.Contains("foobar", ex.Message); + ex = Assert.Throws(() => { TraceParent.FromString(""); }); + Assert.Contains("Traceparent", ex.Message); + } + } +} diff --git a/test/FunctionsV2/WebJobs.Extensions.DurableTask.Tests.V2.csproj b/test/FunctionsV2/WebJobs.Extensions.DurableTask.Tests.V2.csproj index a44d5f90d..2400a6cb2 100644 --- a/test/FunctionsV2/WebJobs.Extensions.DurableTask.Tests.V2.csproj +++ b/test/FunctionsV2/WebJobs.Extensions.DurableTask.Tests.V2.csproj @@ -16,10 +16,10 @@ - + - + @@ -27,8 +27,8 @@ - - + +