Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
.NET: Support returning durable workflow results from HTTP trigger endpoint#5321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
61c28eb
Adding support for "wait for response" when invoking workflow http en…
kshyju f8976d3
update changelog.
kshyju 06f1654
PR comment fixes.
kshyju edf234a
Address PR review feedback.
kshyju 6503390
Merge branch 'main' into shkr/workflow_return_value
kshyju 438edf3
Merge branch 'main' into shkr/workflow_return_value
kshyju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47 ...ples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22 dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/demo.http
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 144 additions & 21 deletions
165 dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1 dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40 .../Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/WorkflowSamplesValidation.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,6 +3,7 @@ | ||
| using System.Diagnostics; | ||
| using System.Reflection; | ||
| using System.Text; | ||
| using System.Text.Json; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Logging; | ||
| using ModelContextProtocol.Client; | ||
| @@ -125,6 +126,45 @@ await this.WaitForConditionAsync( | ||
| }, | ||
| message: "OrderStatus workflow completed", | ||
| timeout: s_orchestrationTimeout); | ||
| // Test the CancelOrder workflow with x-ms-wait-for-response header | ||
| this._outputHelper.WriteLine("Starting CancelOrder workflow with x-ms-wait-for-response: true..."); | ||
| using HttpRequestMessage waitRequest = new(HttpMethod.Post, cancelOrderUri); | ||
| waitRequest.Content = new StringContent("55555", Encoding.UTF8, "text/plain"); | ||
| waitRequest.Headers.Add("x-ms-wait-for-response", "true"); | ||
| using HttpResponseMessage waitResponse = await s_sharedHttpClient.SendAsync(waitRequest); | ||
kshyju marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Assert.True(waitResponse.IsSuccessStatusCode, $"CancelOrder wait-for-response request failed with status: {waitResponse.StatusCode}"); | ||
| string waitResponseText = await waitResponse.Content.ReadAsStringAsync(); | ||
| this._outputHelper.WriteLine($"CancelOrder wait-for-response result: {waitResponseText}"); | ||
| // The response should contain the workflow result (not just "started for CancelOrder") | ||
| Assert.DoesNotContain("Workflow orchestration started", waitResponseText); | ||
| Assert.Contains("55555", waitResponseText); | ||
| // Test the wait-for-response with Accept: application/json header | ||
| this._outputHelper.WriteLine("Starting CancelOrder workflow with x-ms-wait-for-response and Accept: application/json..."); | ||
| using HttpRequestMessage jsonWaitRequest = new(HttpMethod.Post, cancelOrderUri); | ||
| jsonWaitRequest.Content = new StringContent("77777", Encoding.UTF8, "text/plain"); | ||
| jsonWaitRequest.Headers.Add("x-ms-wait-for-response", "true"); | ||
| jsonWaitRequest.Headers.Add("Accept", "application/json"); | ||
| using CancellationTokenSource jsonWaitCts = new(s_orchestrationTimeout); | ||
| using HttpResponseMessage jsonWaitResponse = await s_sharedHttpClient.SendAsync(jsonWaitRequest, jsonWaitCts.Token); | ||
| Assert.True(jsonWaitResponse.IsSuccessStatusCode, $"CancelOrder JSON wait-for-response request failed with status: {jsonWaitResponse.StatusCode}"); | ||
| string jsonWaitResponseText = await jsonWaitResponse.Content.ReadAsStringAsync(); | ||
| this._outputHelper.WriteLine($"CancelOrder JSON wait-for-response result: {jsonWaitResponseText}"); | ||
| using JsonDocument jsonDoc = JsonDocument.Parse(jsonWaitResponseText); | ||
| JsonElement root = jsonDoc.RootElement; | ||
| Assert.True(root.TryGetProperty("runId", out _), "JSON response missing 'runId' property"); | ||
| Assert.True(root.TryGetProperty("workflowStatus", out JsonElement statusEl), "JSON response missing 'workflowStatus' property"); | ||
| Assert.Equal("Completed", statusEl.GetString()); | ||
| Assert.True(root.TryGetProperty("result", out JsonElement resultEl), "JSON response missing 'result' property"); | ||
| Assert.Contains("77777", resultEl.GetString()); | ||
| }); | ||
| } | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.