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

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

问题描述

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

function.json 文件:

解决方案

我之前的回答确实是对的,我操作的时候.经过大量测试,我认为是因为微软官方更新.如果你也有兴趣,可以尝试使用之前的azure函数进行测试.

再次提醒您,修改function.json文件也会修改发布文件的.dll,即您修改的TimerTrigger时间不会生效.

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

  1. 创建一个新的天蓝色函数.也可以使用前面的,记得删除SCM_DO_BUILD_DURING_DEPLOYMENTWEBSITE_RUN_FROM_PACKAGE这两个配置.

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

    步骤 2. 使用 func azure functionapp publish function_app_name --csharp --nozip --force 部署您的函数应用.

    如果中间有错误信息,可以忽略.我的屏幕截图显示了 NativeCommandError.只要最终结果已经上传成功.

  3. 打开 scm 网站或使用应用服务编辑器(预览版),进行测试.

  4. 检查函数是否可以正常运行,经测试可以正常运行.

以前的

我重新创建了一个 func,发现我现在无法修改 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重新部署功能app.

  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天全站免登陆