Home > other >  How to make Azure Function fire on queue change when using containers?
How to make Azure Function fire on queue change when using containers?

Time:12-15

I've created an Azure Functions app and dockerized it. The container is running and doesn't give me any errors. Now I want this function app to be triggered by a storage queue insertion. I've read the microsoft docs and added the trigger in my function.json file.

{
      "name": "myQueueItem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "searches",
      "connection": "StorageAccountConnectionString"
    }

The StorageAccountConnectionString is an app setting which I added to the functions app in the azure portal under configuration.

I verified the existence of the searches queue as well.

Now nothing seems to be happening when I insert a message into the searches queue. The dequeue counts doesn't increment, and the function execution counter also doesn't change.

Does anyone know how I can make this work?

CodePudding user response:

  • If you are deploying the docker image to the function app then you can setup the environment variable in the docker file itself.

  • just add the following command in your dockerfile.

ENV StorageAccountConnectionString = <Your Connection String>
  • This way there will be a reference to the variable in the docker container. Here my storage queue trigger was working after I add the command.

enter image description here

You can also refer to this article by Kevin lee

CodePudding user response:

I have no idea, but it was fixed by generating a function from VS Code Azure Functions extension. Then the function picked up the queue change.

  • Related