From 390cc541eab1e2ae4759ae986f5af5dcdecfc203 Mon Sep 17 00:00:00 2001 From: Chris <66376200+crickman@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:06:40 -0700 Subject: [PATCH] .NET Workflows - Clean-up declarative docs and product-context. (#1134) * Clean-up * Rollback sample --------- Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> --- .../Workflows/Declarative/Program.cs | 4 +++- .../Workflows/Declarative/README.md | 15 ++++++++++++--- .../Workflows/DeclarativeEject/Program.cs | 7 ++++++- .../Interpreter/WorkflowTemplateVisitor.cs | 2 ++ .../PowerFx/WorkflowDiagnostics.cs | 8 ++++++++ .../PowerFx/WorkflowFormulaState.cs | 5 +---- workflow-samples/README.md | 3 ++- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs index da567b61d8..5308bb06b8 100644 --- a/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs +++ b/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs @@ -101,7 +101,9 @@ internal sealed class Program DeclarativeWorkflowOptions options = new(new AzureAgentProvider(this.FoundryEndpoint, new AzureCliCredential())) { - Configuration = this.Configuration + Configuration = this.Configuration, + //ConversationId = null, // Assign to continue a conversation + //LoggerFactory = null, // Assign to enable logging }; return DeclarativeWorkflowBuilder.Build(this.WorkflowFile, options); diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/README.md b/dotnet/samples/GettingStarted/Workflows/Declarative/README.md index 711b5377c8..48c6f91cbb 100644 --- a/dotnet/samples/GettingStarted/Workflows/Declarative/README.md +++ b/dotnet/samples/GettingStarted/Workflows/Declarative/README.md @@ -16,9 +16,12 @@ You can also use environment variables if you prefer. To set your secrets as an environment variable (PowerShell): ```pwsh -$env:AZURE_FOUNDRY_PROJECT_ENDPOINT="https://..." +$env:FOUNDRY_PROJECT_ENDPOINT="https://..." ``` +etc... + + To set your secrets with .NET Secret Manager: 1. From the root of the repository, navigate the console to the project folder: @@ -48,7 +51,13 @@ To set your secrets with .NET Secret Manager: 5. Define setting that identifies your Azure Foundry Model Deployment (endpoint): ``` - dotnet user-secrets set "FOUNDRY_MODEL_DEPLOYMENT_NAME" "https://..." + dotnet user-secrets set "FOUNDRY_MODEL_DEPLOYMENT_NAME" "gpt-4.1" + ``` + +6. Define setting that identifies your Bing Grounding connection: + + ``` + dotnet user-secrets set "FOUNDRY_CONNECTION_GROUNDING_TOOL" "mybinggrounding" ``` #### Authorization @@ -67,7 +76,7 @@ The sample workflows rely on agents defined in your Azure Foundry Project. To create agents, run the [`Create.ps1`](../../../../../workflow-samples/setup/) script. This will create the agents used in the sample workflows in your Azure Foundry Project and format a script you can copy and use to configure your environment. -> Note: `Create.ps1` relies upon the `FOUNDRY_PROJECT_ENDPOINT` and `FOUNDRY_MODEL_DEPLOYMENT_NAME` settings. +> Note: `Create.ps1` relies upon the `FOUNDRY_PROJECT_ENDPOINT`, `FOUNDRY_MODEL_DEPLOYMENT_NAME`, and `FOUNDRY_CONNECTION_GROUNDING_TOOL` settings. ## Execution diff --git a/dotnet/samples/GettingStarted/Workflows/DeclarativeEject/Program.cs b/dotnet/samples/GettingStarted/Workflows/DeclarativeEject/Program.cs index 0eeec60b17..859b74b194 100644 --- a/dotnet/samples/GettingStarted/Workflows/DeclarativeEject/Program.cs +++ b/dotnet/samples/GettingStarted/Workflows/DeclarativeEject/Program.cs @@ -30,7 +30,12 @@ internal sealed class Program Stopwatch timer = Stopwatch.StartNew(); // Use DeclarativeWorkflowBuilder to generate code based on a YAML file. - string code = DeclarativeWorkflowBuilder.Eject(this.WorkflowFile, DeclarativeWorkflowLanguage.CSharp, workflowNamespace: "Demo.DeclarativeCode", workflowPrefix: "Sample"); + string code = + DeclarativeWorkflowBuilder.Eject( + this.WorkflowFile, + DeclarativeWorkflowLanguage.CSharp, + workflowNamespace: "Demo.DeclarativeCode", + workflowPrefix: "Sample"); Notify($"\nWORKFLOW: Defined {timer.Elapsed}\n"); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowTemplateVisitor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowTemplateVisitor.cs index 88d4486255..4822a70024 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowTemplateVisitor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowTemplateVisitor.cs @@ -22,6 +22,8 @@ internal sealed class WorkflowTemplateVisitor : DialogActionVisitor { this._rootId = workflowId; this._workflowModel = new WorkflowModel(new RootTemplate(workflowId, typeInfo)); + + WorkflowDiagnostics.SetFoundryProduct(); } public bool HasUnsupportedActions { get; private set; } diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowDiagnostics.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowDiagnostics.cs index 63f1dc071a..5ddcfe61f2 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowDiagnostics.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowDiagnostics.cs @@ -19,6 +19,14 @@ internal static class WorkflowDiagnostics { private static readonly WorkflowFeatureConfiguration s_semanticFeatureConfig = new(); + public static void SetFoundryProduct() + { + if (!ProductContext.IsLocalScopeSupported()) + { + ProductContext.SetContext(Product.Foundry); + } + } + public static WorkflowTypeInfo Describe(this TElement workflowElement) where TElement : BotElement, IDialogBase { SemanticModel semanticModel = workflowElement.GetSemanticModel(new PowerFxExpressionChecker(s_semanticFeatureConfig), s_semanticFeatureConfig); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowFormulaState.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowFormulaState.cs index bf8d225ae8..ee58a3c63c 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowFormulaState.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowFormulaState.cs @@ -121,10 +121,7 @@ internal sealed class WorkflowFormulaState public static string GetScopeName(string? scopeName) { - if (!ProductContext.IsLocalScopeSupported()) - { - ProductContext.SetContext(Product.Foundry); - } + WorkflowDiagnostics.SetFoundryProduct(); scopeName ??= DefaultScopeName; diff --git a/workflow-samples/README.md b/workflow-samples/README.md index eaa96d5c78..3bea36472d 100644 --- a/workflow-samples/README.md +++ b/workflow-samples/README.md @@ -24,4 +24,5 @@ The sample workflows rely on agents defined in your Azure Foundry Project. To create agents, run the [`Create.ps1`](./setup) script. This will create the agents used in the sample workflows in your Azure Foundry Project and format a script you can copy and use to configure your environment. -> Note: `Create.ps1` relies upon the `FOUNDRY_PROJECT_ENDPOINT` setting. See [README.md](../dotnet/samples/GettingStarted/Workflows/Declarative/README.md) from the demo for configuration details. +> Note: `Create.ps1` relies upon the `FOUNDRY_PROJECT_ENDPOINT`, `FOUNDRY_MODEL_DEPLOYMENT_NAME`, and `FOUNDRY_CONNECTION_GROUNDING_TOOL` settings. +See [README.md](../dotnet/samples/GettingStarted/Workflows/Declarative/README.md) from the demo for configuration details.