1

Last 10 entries (specifically all those in last 4 days) show as failed in Run History and have this message in the "Execute CSharp Script Code" action

InvokeFunctionFailed

The function 'CSharp_receive-email-test_execute_csharp_script_code.csx' failed with the error 'Exception binding parameter 'context'' when executing. Please verify function code is valid.

Again, no code was changed. And I can't make sense of that error.

Was there a breaking change made to Logic Apps inline C#?

Edit: there certainly was a breaking change.

Steps to reproduce:

  1. In designer, add a "Execute CSharp Script Code" step
  2. Copy the code sample from https://learn.microsoft.com/en-us/azure/logic-apps/add-run-csharp-scripts
  3. Run the workflow. It works
  4. Add to the script this statement: using System.Text.Json;

The error now occurs.

Edit: 5/5/25: The breaking change in was that a reference is now needed to use System.Text.Json

#r "System.Text.Json"

6
  • Could you please share your code or some reproductible issue? Commented May 2 at 5:24
  • Editing main post with info Commented May 2 at 17:07
  • Not sure if system.text.json is supported. Also this feature is in preview so prob better to post on GitHub to the MS team ? Commented May 2 at 22:22
  • the sample is using Newtonsoft.Json not system.text.json . have you tried using Newtonsoft.Json only? Commented May 2 at 22:42
  • What is the sample code used from that doc? Commented May 5 at 5:00

2 Answers 2

1

You can use below sample code and designwhich works fine for me:

enter image description here

You also need to add #r "System.Text.Json":

#r "System.Text.Json"
#r "Microsoft.Azure.Workflows.Scripting"
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Workflows.Scripting;
using System.Text.Json;

public static async Task<Riouts> Run(WorkflowContext context, ILogger log)
{
  var testjson = JsonSerializer.Serialize(new { name = "Rithwik" });
  var rijsonobj = JsonSerializer.Deserialize<JsonElement>(testjson);
  var test = rijsonobj.GetProperty("name").GetString();

  return new Riouts
  {
    Peru = test 
  };
}
public class Riouts
{
  public string Peru { get; set; }
}

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

Still get error when I add other needed namespaces: using System.Linq; using System.IO; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Encodings.Web; using System.Xml; using System.Xml.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers;
Open a new question for that, as different namespaces need different packages. Community will help. The initial question was about only one package
I observe in the trace that the C# no longer compiles. Which leads to the conclusion that the version of .NET and C# being used by the script runner has changed. How can I determine the version of C# that the "Execute CSharp Script Code" action uses?
The c# version is Rolled back to 8.
Can someone please post a link to where this rollback is announced?
0

Trying to add references was a distraction and didn't resolve the issue.

The breaking change made on April 28th was that the version of C# used by script actions was rolled back from 11 to 8. Our code uses Raw String Literals (among other things), which is not supported in C# 8.

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.