我有以下函数,我在本地定义,可以正常调试.
[FunctionName("QueueTrigger")]公共静态无效 DUMMYFUNCTION([QueueTrigger("myqueue", Connection = "AzureWebJobsStorage")]string myQueueItem, TraceWriter 日志){log.Info($"处理的 C# 函数:{myQueueItem}");}
在本地,AzureWebJobsStorage"在 local.settings.json 文件中定义以使用具有myqueue"的存储帐户.在 Azure 上的功能设置中,AzureWebJobsStorage"也设置为正确的连接字符串(与本地设置的相同).这意味着,我没有与
部署后生成文件function.json,内容如下:
<代码>{"generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.8","configurationSource": "属性",绑定":[{类型":队列触发器",连接":AzureWebJobsStorage","queueName": "我的队列",名称":我的队列项目"}],禁用":假,"scriptFile": "../bin/myAssembly.dll",入口点":myAssembly.MyClass.DUMMYFUNCTION"}
问题是,当我在本地调试时将项目添加到队列中时,该函数已执行,但当该函数在 azure 上运行时却没有.
我需要对代码进行哪些更改才能使其在 azure 上也能正常工作?我认为它可以开箱即用.
你的函数运行了吗?如果您进入 KUDU,您是否看到您的函数实际运行的任何日志?
如果您的函数根本没有运行,Azure 函数 2(使用 .NET Standard 2 框架)仍处于预览阶段(测试版).因此,当您通过部署函数时,请确保进入函数应用的应用程序设置并将 FUNCTIONS_EXTENSION_VERSION 值设置为 beta
I have the following function, which I define locally and am able to debug it normally.
[FunctionName("QueueTrigger")]
public static void DUMMYFUNCTION(
[QueueTrigger("myqueue", Connection = "AzureWebJobsStorage")]string myQueueItem, TraceWriter log)
{
log.Info($"C# function processed: {myQueueItem}");
}
Locally, "AzureWebJobsStorage" is defined in the local.settings.json file to use the storage account which has "myqueue". In the function settings on Azure "AzureWebJobsStorage" is also set to the correct connection string (same as the one set locally). That means, I do not have the same problem as in Azure Function does not execute in Azure (No Error)
Now, I use Visual Studio Team Service to host my source code in a git repository. I've configured the deployment to use the source code and deploy the functions contained in it. I don't think the issue is related to VSTS because the deployment is performed successfully and the function is displayed in my functions list:
After the deployment, the file function.json is generated and has the content below:
{
"generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.8",
"configurationSource": "attributes",
"bindings": [
{
"type": "queueTrigger",
"connection": "AzureWebJobsStorage",
"queueName": "myqueue",
"name": "myQueueItem"
}],
"disabled": false,
"scriptFile": "../bin/myAssembly.dll",
"entryPoint": "myAssembly.MyClass.DUMMYFUNCTION"
}
The problem is that, when I add an item to the queue while debugging it locally, the function is executed, but when the function is running on azure it does not.
What do I need to change in the code to have it work on azure as well? I thought it would work out-of-the-box.
Is your function running at all? If you go in the KUDU, do you see any log that your function actually ran?
If your function is not running at all, Azure functions 2 (using the .NET Standard 2 framework) is still in preview (beta). So when you deploy your function through, make sure to go in the Application Settings of your function app and set the FUNCTIONS_EXTENSION_VERSION value to beta
这篇关于本地实现的 Azure 功能在云中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!