Skip to content
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

Azure Functions Core Tools v4 unable deploy to Kubernetes for dotnet-isolated, "Invalid property identifier character: {. Path" #3585

Open
marystory opened this issue Jan 29, 2024 · 3 comments · May be fixed by #4228

Comments

@marystory
Copy link

I am experiencing issues with using func kubernetes deploy for dotnet-isolated on mac

func kubernetes deploy --name testdurfuncapp --image-name  myregistry.com/testdurfunc

error is

Invalid property identifier character: {. Path 'functionsJson.testDurableFunc_HttpStart', line 34, position 2.

when taking a close look it sounds like print-functions.sh does not create functions.json from functions.metadata properly and hence it breaks the subsequent deserialization logics

sed -nzE 's/^\[(.+\n {4}"name": "([^"]+)".+)\]$/"\2": \1/p' functions.metadata

Here is how this bash script convert the functions.metadata to functions.json:

functions.metadata

[
  {
    "name": "testDurableFunc",
    "scriptFile": "func-iso-dur-test.dll",
    "entryPoint": "func_iso_dur_test.testDurableFunc.RunOrchestrator",
    "language": "dotnet-isolated",
    "properties": {
      "IsCodeless": false
    },
    "bindings": [
      {
        "name": "context",
        "direction": "In",
        "type": "orchestrationTrigger",
        "properties": {}
      }
    ]
  },
  {
    "name": "SayHello",
    "scriptFile": "func-iso-dur-test.dll",
    "entryPoint": "func_iso_dur_test.testDurableFunc.SayHello",
    "language": "dotnet-isolated",
    "properties": {
      "IsCodeless": false
    },
    "bindings": [
      {
        "name": "name",
        "direction": "In",
        "type": "activityTrigger",
        "dataType": "String",
        "properties": {}
      }
    ]
  },
  {
    "name": "testDurableFunc_HttpStart",
    "scriptFile": "func-iso-dur-test.dll",
    "entryPoint": "func_iso_dur_test.testDurableFunc.HttpStart",
    "language": "dotnet-isolated",
    "properties": {
      "IsCodeless": false
    },
    "bindings": [
      {
        "name": "req",
        "direction": "In",
        "type": "httpTrigger",
        "authLevel": "Anonymous",
        "methods": [
          "get",
          "post"
        ],
        "properties": {}
      },
      {
        "name": "client",
        "direction": "In",
        "type": "durableClient",
        "properties": {}
      },
      {
        "name": "$return",
        "type": "http",
        "direction": "Out"
      }
    ]
  }
]

result of print-functions.sh, note "functionsJson": {"testDurableFunc_HttpStart":

{
"hostJson":
{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            },
            "enableLiveMetricsFilters": true
        }
    }
},
"functionsJson": {
"testDurableFunc_HttpStart":
  {
    "name": "testDurableFunc",
    "scriptFile": "func-iso-dur-test.dll",
    "entryPoint": "func_iso_dur_test.testDurableFunc.RunOrchestrator",
    "language": "dotnet-isolated",
    "properties": {
      "IsCodeless": false
    },
    "bindings": [
      {
        "name": "context",
        "direction": "In",
        "type": "orchestrationTrigger",
        "properties": {}
      }
    ]
  },
  {
    "name": "SayHello",
    "scriptFile": "func-iso-dur-test.dll",
    "entryPoint": "func_iso_dur_test.testDurableFunc.SayHello",
    "language": "dotnet-isolated",
    "properties": {
      "IsCodeless": false
    },
    "bindings": [
      {
        "name": "name",
        "direction": "In",
        "type": "activityTrigger",
        "dataType": "String",
        "properties": {}
      }
    ]
  },
  {
    "name": "testDurableFunc_HttpStart",
    "scriptFile": "func-iso-dur-test.dll",
    "entryPoint": "func_iso_dur_test.testDurableFunc.HttpStart",
    "language": "dotnet-isolated",
    "properties": {
      "IsCodeless": false
    },
    "bindings": [
      {
        "name": "req",
        "direction": "In",
        "type": "httpTrigger",
        "authLevel": "Anonymous",
        "methods": [
          "get",
          "post"
        ],
        "properties": {}
      },
      {
        "name": "client",
        "direction": "In",
        "type": "durableClient",
        "properties": {}
      },
      {
        "name": "$return",
        "type": "http",
        "direction": "Out"
      }
    ]
  }
}
}

how to reproduce the issue

func init --docker  # choose c#-isolated
func new  --template  "DurableFunctionsOrchestration"
func kubernetes deploy --name testdurfuncapp --image-name  myregistry.com/testdurfunc

Noticed the code change was introduced to address this other issue #2825

Any body else is running to this issue? any thoughts on this?

@kolexinfos
Copy link

kolexinfos commented Feb 20, 2024

I am facing a similar issue when trying to deploy an Azure Function App running on .Net8 and Runtime Version 4 to Kubernetes func kubernetes deploy command. Getting

Invalid property identifier character: {. Path 'functionsJson.RenderOAuth2Redirect', line 60, position 2.

@vigouredelaruse
Copy link

vigouredelaruse commented Jan 8, 2025

'this' is 'still happening' where

  • this = canonical template .net c# isolated, rabbitmq trigger, durable task trigger => canonical docker build
  • still happening = func kubernetes deploy --image => Invalid property identifier character: {. Path 'functionsJson.AlwaysSomeFunctionEvenIfYouDeleteTheMostRecentOneThatCausedThisError', line 60, position

the effect is one has to rely instead on a dev loop procedure

  • cd the function source tree
  • func kubernetes deploy --name thefuncs --registry theregistry--service-type ClusterIP --min-replicas 0 --max-replicas 1 --use-config-map --ignore-errors --dry-run --dotnet-isolated > rendered.yaml
  • edit rendered.yaml => fix any timer triggers / missing platform secrets
  • generate helm chart from yaml

on the other hand 'this' enables a flexible-cost-center option for using all these tools so add n grains of salt

this salient issue #2825 mentions a workaround that depends on custom msbuild tasks and while it works well for rendering functions.json sets during builds in visual studio it does not immediately function during docker builds on linux targets

@vigouredelaruse
Copy link

this issue contains an analysis of trigger mechanism for the bug referenced by this issue that may be of pull request interest

@f1x3d f1x3d linked a pull request Jan 11, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants