yokawasa / azure-functions-python-samples

Azure Functions Python Sample Codes. NOTE: The project, hosted in a repository, is no longer actively maintained by its creators or contributors. There won't be any further updates, bug fixes, or support from the original developers in the project.
MIT License
392 stars 181 forks source link

How to use Timer output #17

Closed Chenguoqing2008 closed 5 years ago

Chenguoqing2008 commented 5 years ago

Thank you for sharing these code samples of using azure functions. I am learning how to use it now it is helpful. I have one concern today of how to add input and output in Timer function. From the official document function reference I read that "Input" and "Output" bindings seem to be not allowed in Timer functions.

Bindings Type | 1.x | 2.x1 | Trigger | Input | Output| Timer | ✔ | ✔ | ✔ |  -- | -- |

I also spent some time to research the material on the web and think a workaround to reloved this. This is because my project manager ask me to move the VM script to azure functions.

When i saw your code example of Timer i think maybe this is what i want. But, can you explain this to me?

{
      "type": "documentDB",
      "name": "outputDocument",
      "databaseName": "functions2docdb",
      "collectionName": "indexstats",
      "createIfNotExists": true,
      "connection": "<Connection string for your documentdb account>",
      "direction": "out"
    }

How can you use the "direction": "out"? This usage seems contrdict to the Microsoft azure functions document usage.

Thanks.

yokawasa commented 5 years ago

@Chenguoqing2008 You can configure output binding with Timer Trigger without any tricks. Here are references:

By the way, which version are you going to use- V1 or V2?

yokawasa commented 5 years ago

@Chenguoqing2008 FYI

I added V2 Function Timer Tigger sample: https://github.com/yokawasa/azure-functions-python-samples/tree/master/v2functions/timer-trigger-cosmosdb-output-binding

Hope it would help

Chenguoqing2008 commented 5 years ago

@yokawasa I am using Azure functions V2. Since your code is workable. Why MicroSoft did document the Timer trigger as this?

Bindings Type | 1.x | 2.x1 | Trigger | Input | Output| Timer | ✔ | ✔ | ✔ | -- | -- |

This bring me a lot of confusing.

yokawasa commented 5 years ago

@Chenguoqing2008 I've submit PR to fix the document. https://github.com/MicrosoftDocs/azure-docs/pull/24041

Chenguoqing2008 commented 5 years ago

That's great. Thanks.