0

I use Rider to create a new Azure Function by template, TimerTrigger based, almost everything by default, but got "System.Text.Json: The input does not contain any JSON tokens." The code is

using System;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Company.FunctionApp2;

public static class timeFunc
{
    [FunctionName("timeFunc")]
    public static async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
    {
        log.LogInformation($"C# Timer trigger function executed at: {DateTime.UtcNow}");
    
    }
}

And the error is

[2023-10-16T01:38:50.051Z] The listener for function 'timeFunc' was unable to start.
[2023-10-16T01:38:50.054Z] The listener for function 'timeFunc' was unable to start.System.Text.Json: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.

local.settings.json is

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

it's weird that this function doesn't even use "System.Text.Json". Can anyone offer some help, thanks a lot

Btw, I created another HTTPTrigger function, which works

1 Answer 1

0

I have created a solution in rider by using azure function template like below:

enter image description here

After created a solution added a timer trigger function like below:

enter image description here

azure-functions-core-tools package got installed successfully.

If you don't mention the version in host.json it will take latest version. In case the version is mentioned rebuild the project again and execute the Function mentioned.

The timer trigger function is executed successfully in my local environment. check the below:

enter image description here

function:

using System;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Company.FunctionApp1;

public static class timeFunc
{
    [FunctionName("timeFunc")]
    public static async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
    {
        log.LogInformation($"C# Timer trigger function executed at: {DateTime.UtcNow}");
        
    }
}

local.settings.json:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

host.json:

{  
  "version": "2.0",  
  "logging": {  
  "applicationInsights": {  
  "samplingSettings": {  
  "isEnabled": true,  
  "excludedTypes": "Request"  
  },  
  "enableLiveMetricsFilters": true  
  }  
 }
 }
Sign up to request clarification or add additional context in comments.

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.