I'm migrating my Azure Function App from the v1 to v2 Python Programming Model. The one thing I can't figure out is how to have my HTTP-triggered function to listen only to POST requests. Meaning it should not accept GET requests.
In the v1 model, you would specify the exhaustive list of HTTP "methods"
in function.json:
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["post"]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
What's the equivalent in the v2 model?
You can send a tuple of HTTP methods as a property on the
@app.route
decorator:Documentation for this decorator: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python-v2%2Cisolated-process%2Cnodejs-v4%2Cfunctionsv2&pivots=programming-language-python#decorators