在Azure函数应用中调用函数后如何动态更改内容 [英] How to change content dynamically after function is called in Azure function app

查看:83
本文介绍了在Azure函数应用中调用函数后如何动态更改内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2019使用Azure函数v3.0开发Azure函数应用程序.我实现了一个时间触发功能.我想更改内容时间表"在 function.json 中:

function.json 文件:

解决方案

操作时,我先前的回答确实是正确的.经过大量测试,我认为这是由于Microsoft的官方更新.如果您也有兴趣,可以尝试使用以前的azure函数进行测试.

再次提醒您,修改function.json文件还将修改已发布文件的 .dll ,也就是说,您修改的TimerTrigger时间不会生效.

让我描述一下我的最新进展.

  1. 创建一个新的天蓝色函数.您也可以使用以前的配置,记住要删除两个配置 SCM_DO_BUILD_DURING_DEPLOYMENT WEBSITE_RUN_FROM_PACKAGE .

  2. 使用 func azure functionapp发布function_app_name --csharp --nozip --force 命令发布您的函数应用.步骤1.使用cd命令进入包含 host.json 文件的文件夹.

    第2步.使用 func azure functionapp publish function_app_name --csharp --nozip --force 部署您的功能应用程序.

    如果中间出现错误消息,则可以忽略它.我的屏幕截图显示了 NativeCommandError .只要最终结果成功完成了上传.

  3. 打开scm网站或使用App Service编辑器(预览),进行测试.

  4. 检查该功能是否可以正常运行,并在测试后可以正常运行.

上一个

我重新创建了一个函子,发现我现在不能修改function.json.

我有一种方法可以修改function.js文件,但是修改不会生效.

原理:

当我们使用vs2019进行发布时,代码中的这一行

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

编译后,将生成 .dll 文件.生成的 function.json 文件只是此Function的属性和内容.修改后, .dll 文件将不会被修改,因此不会生效.

以上结论是通过测试得出的.

如何认识到function.json文件可以修改

  1. 添加 SCM_DO_BUILD_DURING_DEPLOYMENT = true .

  2. 删除 WEBSITE_RUN_FROM_PACKAGE配置,或将其修改为 0 .

  3. 刷新scm网站,如果wwwroot下的文件被删除,请使用vs2019重新部署功能应用程序.

  4. 重复第二步,然后修改 function.json 文件以成功.

以上内容仅允许在发布后修改内容,修改后的时间不会生效,因为未修改.dll.

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:

解决方案

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.

  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.

    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.

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

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

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.

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.

  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.

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.

这篇关于在Azure函数应用中调用函数后如何动态更改内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆