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:
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
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.
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
.
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.
step 2. Use func azure functionapp publish function_app_name --csharp --nozip --force
to deploy your function app.
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.
Open the scm website or use App Service Editor (Preview) ,carry out testing.
Check whether the function can run normally, and it can run normally after testing.
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.
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
Add SCM_DO_BUILD_DURING_DEPLOYMENT=true
.
Delete the WEBSITE_RUN_FROM_PACKAGE configuration
, or modify it to 0
.
Refresh the scm site, if the files under wwwroot are deleted, please use vs2019 redeploy function app.
Repeat the second step, and then modify the function.json
file to succeed.
schedule
on local in your vs 2019 and then publish it to azure. – Hury Shenfunction.json
file does not change the execution interval, so it is not necessary. – Jason Pan