Azure function implemented locally won#39;t work in the cloud(本地实现的 Azure 功能在云中不起作用)
问题描述
我有以下函数,我在本地定义,可以正常调试.
[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 功能在云中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:本地实现的 Azure 功能在云中不起作用
基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01