Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.32k stars 434 forks source link

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

Open marystory opened 9 months ago

marystory commented 9 months ago

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 https://github.com/Azure/azure-functions-core-tools/issues/2825

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

kolexinfos commented 8 months ago

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.