0
votes

I'm using Visual Studio 2019 to develop an Azure function app using Azure function v3.0. I implemented a time-triggered function. I want to change the content "schedule" in the function.json:

function.json file:

enter image description here

2
You can just edit the schedule on local in your vs 2019 and then publish it to azure.Hury Shen
I want to change the value dynamically when the time trigger function is calledMuthu mani
I explain the principle of this problem very clearly, because only modifying the function.json file does not change the execution interval, so it is not necessary.Jason Pan
Also find a way for you to modify the file, but it won't work. The suggestion is to look at @RyanThomas ’s suggestion, or cancel the idea of doing so, directly modify the code, redeploy will do.Jason Pan

2 Answers

0
votes

Change of function.json after deployment would not help at any time as the .dll does not get updated. rather redeployment is a better option.

for more read: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference#function-code

0
votes

My previous answer is indeed correct, when I operate. After a lot of testing, I think it is because of the official Microsoft update. If you are also interested, you can try to use the previous azure function for testing.

Remind you again that modifying the function.json file will also modify the .dll of the released file, that is, the TimerTrigger time you modified will not take effect.

Let me describe my latest progress.

  1. Create a new azure function. You can also use the previous ones, remember to delete the two configurations SCM_DO_BUILD_DURING_DEPLOYMENT and WEBSITE_RUN_FROM_PACKAGE.

    enter image description here

  2. Use the func azure functionapp publish function_app_name --csharp --nozip --force command to publish your function app. step 1. Use cd command enters the folder that contains the host.json file.

    enter image description here

    step 2. Use func azure functionapp publish function_app_name --csharp --nozip --force to deploy your function app.

    enter image description here

    If there is an error message in the middle, you can ignore it. My screenshot shows NativeCommandError. As long as the final result has Upload completed successfully.

    enter image description here

  3. Open the scm website or use App Service Editor (Preview) ,carry out testing.

    enter image description here

  4. Check whether the function can run normally, and it can run normally after testing.

    enter image description here

PREVIOUS

I recreate a func, and find I can't modify function.json now. Maybe it fixed in 4.1.

Now it impossible to create a new one and modify it.

Below function I created before.

enter image description here

enter image description here

enter image description here

I have a way for you to modify the function.js file, but the modification will not take effect.

Principle:

When we use vs2019 for publishing, this line in the code

public static void Run([TimerTrigger("*/15 * * * * *")]TimerInfo myTimer, TraceWriter log)

After compiling, the .dll file is generated. The generated function.json file is only the properties and content of this Function. After the modification, the .dll file will not be modified so it will not take effect.

The above conclusions are drawn through testing.

How to realize that the function.json file can be modified

  1. Add SCM_DO_BUILD_DURING_DEPLOYMENT=true.

    enter image description here

  2. Delete the WEBSITE_RUN_FROM_PACKAGE configuration, or modify it to 0.

  3. Refresh the scm site, if the files under wwwroot are deleted, please use vs2019 redeploy function app.

  4. Repeat the second step, and then modify the function.json file to succeed.

    enter image description here

The above is only allowed to modify the content after the release, the modified time does not take effect, because the .dll has not been modified.