Azure function implemented locally won't work in the cloud

天涯浪子 提交于 2019-12-12 14:23:27

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/48952452/azure-function-implemented-locally-wont-work-in-the-cloud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!