Th3B0Y
Th3B0Y

Reputation: 1004

Azure function implemented locally won't work in the cloud

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:

Queue function on azure

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.

Upvotes: 3

Views: 3685

Answers (1)

DOMZE
DOMZE

Reputation: 1369

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

Upvotes: 6

Related Questions