How to change content dynamically after function is called in Azure function app(如何在 Azure 函数应用中调用函数后动态更改内容)
问题描述
我正在使用 Visual Studio 2019 开发一个使用 Azure 函数 v3.0 的 Azure 函数应用.我实现了一个时间触发的功能.我想更改内容时间表"在 function.json
:
function.json
文件:
我之前的回答确实是对的,我操作的时候.经过大量测试,我认为是因为微软官方更新.如果你也有兴趣,可以尝试使用之前的azure函数进行测试.
再次提醒您,修改function.json文件也会修改发布文件的.dll
,即您修改的TimerTrigger时间不会生效.
让我描述一下我的最新进展.
创建一个新的天蓝色函数.也可以使用前面的,记得删除
SCM_DO_BUILD_DURING_DEPLOYMENT
和WEBSITE_RUN_FROM_PACKAGE
这两个配置.使用
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
.只要最终结果已经上传成功.打开 scm 网站或使用应用服务编辑器(预览版),进行测试.
检查函数是否可以正常运行,经测试可以正常运行.
以前的
我重新创建了一个 func,发现我现在无法修改 function.json.
我有办法让你修改function.js文件,但是修改不会生效.
原则:
当我们使用vs2019发布时,代码中的这一行
public static void Run([TimerTrigger("*/15 * * * * *")]TimerInfo myTimer, TraceWriter 日志)
编译后生成.dll
文件.生成的function.json
文件只是这个Function的属性和内容.修改后.dll
文件不会被修改所以不会生效.
以上结论是通过测试得出的.
如何实现function.json文件可以修改
添加
SCM_DO_BUILD_DURING_DEPLOYMENT=true
.删除
WEBSITE_RUN_FROM_PACKAGE配置
,或修改为0
.刷新scm站点,如果wwwroot下的文件被删除,请使用vs2019重新部署功能app.
重复第二步,然后修改
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.
Create a new azure function. You can also use the previous ones, remember to delete the two configurations
SCM_DO_BUILD_DURING_DEPLOYMENT
andWEBSITE_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 thehost.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.
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
Add
SCM_DO_BUILD_DURING_DEPLOYMENT=true
.Delete the
WEBSITE_RUN_FROM_PACKAGE configuration
, or modify it to0
.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.
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 函数应用中调用函数后动态更改内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Azure 函数应用中调用函数后动态更改内容
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01