I have created an Azure Service Bus Queue with terraform, it is deployed and working properly. I want to add a retry delay for the queue. I have added following line in Python V2 model but after deployment it breaks and my function disappears from the Azure function tab
@app.retry(strategy="fixed_delay", delay_interval="00:00:10")
@app.service_bus_queue_trigger(arg_name="azservicebus", queue_name="publish-queue", connection="SERVICE_BUS_CONNECTION",
)
def publish_der(azservicebus: func.ServiceBusMessage):
"""Service bus trigger which receives data from API"""
//implementation goes here
What is the proper way to add re try for Python v2?
To use retry option in Azure Function Service bus V2 Model you need to use retry option in host.json
in local:
{
"version": "2.0",
"retry": {
"strategy":"fixedDelay",
"maxRetryCount": 5,
"delayInterval":"00:00:30"
},
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
My functionapp.py
:
import azure.functions as func
import logging
app = func.FunctionApp()
@app.service_bus_queue_trigger(arg_name="azservicebus", queue_name="mysbqueue",
connection="testjkafka_SERVICEBUS")
def servicebus_queue_trigger(azservicebus: func.ServiceBusMessage):
raise Exception("Simulated failure")
logging.info('Python ServiceBus Queue trigger processed a message: %s',
azservicebus.get_body().decode('utf-8'))
Then when I deployed I can see my function: