本地实施的Azure功能在云中不起作用 [英] Azure function implemented locally won't work in the cloud

查看:89
本文介绍了本地实施的Azure功能在云中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下函数,这些函数是我在本地定义的,并且可以正常调试。

  [FunctionName( QueueTrigger )] 
公共静态无效值DUMMYFUNCTION(
[QueueTrigger( myqueue,Connection = AzureWebJobsStorage)] string myQueueItem,TraceWriter log)
{
log.Info($ 已处理C#函数:{myQueueItem});
}

在本地, AzureWebJobsStorage在local.settings.json文件中定义为使用具有 myqueue的存储帐户。在Azure上的功能设置中, AzureWebJobsStorage也设置为正确的连接字符串(与本地设置相同)。这意味着,我没有与



部署后,将生成文件function.json,其内容如下:

  {
generationBy: Microsoft.NET.Sdk.Functions.Generator-1.0.8,
configurationSource:属性 ,
bindings:[
{
type: queueTrigger,
connection: AzureWebJobsStorage,
queueName: myqueue ,
name: myQueueItem
}],
disabled:false,
scriptFile: ../bin/myAssembly.dll,
entryPoint: myAssembly.MyClass.DUMMYFUNCTION
}

问题是当我在本地调试项目时将项目添加到队列时ly,该函数已执行,但是当该函数在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功能在云中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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