0
votes

Azure function created from visual studio is not listening the queue but when I create azure function from portal It listens the queue.

Following are the steps which I did while creating function in visual studio 2017

  • I implemented azure queue and passing json string to that queue from my .net core application.

    I am able to see entry in queue whenever my .net core code exectued.

    For this created queue, I wrote the azure function in visual studio(Queue triggered function).

    I put the connectionstring & queue name while adding the azure function.I used entity framework here to do some database operation(this is entity framework hence I used 1.0 trigger version while creating queue function.I choosed entity framework intentionally as I want to do some spatial operations here,Ef core just have partial support for this).

    After this,I deploy my visual studio code to Azure app using existing publish profile.

Now this created function is not listening to my azure queue.As I am new to azure, there might be chance I am doing some silly mistake here.Any help or suggestion is much appericiated.

1)Crerating function from Portal works fine.

Edit: Added code image Azure function image

1
Is there any error you can see? or do you set the .json file "copy to output directory" to "copy if newer"? - Ivan Yang
@IvanYang No error - Dnyaneshwar Shivbhakta
For testing purpose, can you please just create a very simple queue trigger azure function, the publish to azure to see if it works? And if it does not work either, please show me the code. - Ivan Yang
@IvanYang Yeah I will add..and let you know on this - Dnyaneshwar Shivbhakta
@IvanYang Can you please check it now - Dnyaneshwar Shivbhakta

1 Answers

0
votes

I just created a v1 azure function, code like below(please use AzureWebJobsStorage for connection):

    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")]string myQueueItem, TraceWriter log)
        {
            log.Info($"C# Queue trigger function processed: {myQueueItem}");
        }
    }

in local.settings.json(replace with your own storage connection string):

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=xx;xxxx",
        "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=xxx;xxx"
    }
}

and for the local.settings.json and host.json, right click -> select properties -> then change "copy to output directory" to "copy if newer":

enter image description here

enter image description here