Azure-webjobs-sdk: Functions V2: host.json "extensions" not loading, autoRenewTimeout lock issue

Created on 27 Sep 2018  路  8Comments  路  Source: Azure/azure-webjobs-sdk

Hi,
I am having troubles with my host.json-file, in particular, by loading the contents under the "extensions" tag in the file when having a Azure Function (AF) V2: Service Bus Trigger.

I have cross checked by creating a simple AF V1 and used the following input in my host.json-file:

{
  "serviceBus": {
    "maxConcurrentCalls": 1,
    "autoRenewTimeout": "00:25:00"
  }
}

When spinning up my AF, I am seeing the following image:
image

Giving me an indication that it is loaded. I can see that it behaves like I want by handling concurrent calls and locks.

Moving on to V2:

When setting the following text in my host.json-file (Source: :

{
    "version": "2.0",
    "extensions": {
      "eventHubs": {
        "maxBatchSize": 64,
        "prefetchCount": 256,
        "batchCheckpointFrequency": 1
      },
        "http": {
            "routePrefix": "api",
            "maxConcurrentRequests": 5,
            "maxOutstandingRequests": 30
        },
        "queues": {
            "visibilityTimeout": "00:00:10",
            "maxDequeueCount": 3
        },
        "sendGrid": {
            "from": "Azure Functions <[email protected]>"
        },
        "serviceBus": {
          "maxConcurrentCalls": 1,
          "autoRenewTimeout": "00:25:00"
        }
    },
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "id": "9f4ea53c5136457d883d685e57164f08",
    "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
          "Function.MyFunction": "Information",
          "default": "None"
        },
        "applicationInsights": {
            "sampling": {
              "isEnabled": true,
              "maxTelemetryItemsPerSecond" : 5
            }
        }
    },
    "watchDirectories": [ "Shared", "Test" ]
}

I see:
image

Giving me an indication that everything is loaded _BUT_ the children of "extensions". Ofcourse, I understand that this might be loaded some how but the AF V2 does not behave how I want, not with concurrent queue, nor with autoRenewTimeout.

So I am looking for assistance on how to handle host.json-files with AF V2, especially autoRenewTimeout is what I am looking for. I have read several threads about this being an issue, but I have set a higher value than the lock of my topic/subscription, but yet it does not renew, leading to a lock exception.

Repro steps

Provide the steps required to reproduce the problem

1. Create a AF V1:

I use the following code:

[FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("%CpamTopicName%", "%CpamSubscription%", Connection = "CpamServiceBusConnection")]BrokeredMessage mySbMsg, TraceWriter log)
        {
            log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}");

            try
            {
                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(3000);
                    log.Info("number of i: " + i.ToString());
                }
                log.Info("Happy days!");
                mySbMsg.Complete();
            }
            catch (Exception e)
            {
                ;
            }
        }

2. Create AF V2 with the following code:

[FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("%CpamTopicName%", "%CpamSubscription%", Connection = "CpamServiceBusConnection")]string mySbMsg, ILogger log)
        {
            log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");

            try
            {
                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(3000);
                    log.LogInformation("number of i: " + i.ToString());
                }
                log.LogInformation("Happy days!");
            }
            catch (Exception e)
            {
                ;
            }
        }

Expected behavior

In AF V2: Output logs, on a single handled run, incrementing for a long time, as well as not throwing lock exception.

Actual behavior

image

It is processing 3 messages at the same time, indicating that it ignores the "extensions" declared in the host.json-file.

And eventually ends up throwing lock exceptions, due to no renewals:
LockException

Known workarounds

I don't know any, possibly rollbacking to AF V1(?).

Related information

I have researched this issue for a few days, regarding the autoRenewalTimeout and have read several clever responses from sources, especially from @SeanFeldman, regarding this and hopefully he can provide insights here.

A few Related links on issue regarding autoRenewalTimeout:
SO regarding expiring lock
GitHub issue regarding locks

  • Package version

AF V1:
Microsoft.Azure.WebJobs.ServiceBus (2.2.0)
Microsoft.NET.Sdk.Functions (1.0.14)

AF V2:
Azure Functions Core Tools (2.0.3)
Functions Runtime Version (2.0.12115.0)
Microsoft.Azure.WebJobs.Extensions.ServiceBus (3.0.0)
Microsoft.NET.Sdk.Functions (1.0.22)
NETStandardLibrary (2.0.3)

I am desperately looking for someone to shine any insights on this issue, and I will closely follow this issue and answer any questions anyone might have.

Thanks,
L

Most helpful comment

CASE CLOSED!
Hi again @paulbatum,

I can now update with the information you gave me, I researched the documentation and found the MessageHandlerOptions to have an updated name for the autoRenewTimeout as well. I tried using that and voil谩, it worked!

For anyone running into the same issue the host.json file for AF V2 should be maxAutoRenewDuration instead of autoRenewTimeout.

See example file below:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "maxAutoRenewDuration": "00:55:00"
      }
    }
  }
}

Thanks a lot for the assistance and efforts put into this :) Closing thread!

All 8 comments

So the fact that your extension config is not appearing in the console output is due to this bug https://github.com/Azure/azure-functions-host/issues/3507

However that bug really just impacts the logging. So it does not address your main question of why your autoRenewalTimeout and maxconcurrentcalls settings are not taking effect.

So the fact that your extension config is not appearing in the console output is due to this bug Azure/azure-functions-host#3507

However that bug really just impacts the logging. So it does not address your main question of why your autoRenewalTimeout and maxconcurrentcalls settings are not taking effect.

Hi Paul,
Thanks for your reply. That would be a cause, but yes, as you're mentioning.
This is just me grasping at straws in order to find an issue to this autoRenewalTimeouts. Seeing that no one else is experiencing this issue.

Are you able to reproduce?

I am able to reproduce maxConcurrentCalls not working. I think I know what is going on, and should be able to send you some workaround steps once I've had a chance to confirm.

I am able to reproduce maxConcurrentCalls not working. I think I know what is going on, and should be able to send you some workaround steps once I've had a chance to confirm.

Thanks for the assistance! Looking forward to any work arounds, especially on the autoRenewalTimeout lock.

Hey again,

I've looked at the source code to which https://github.com/Azure/azure-functions-host/issues/3507 refers to. Can it be, that due to the missing keywords under WellKnownHostJsonProperties, makes the host.json parser to miss these settings?

Any thoughts on this? Looping in @fabiocav, to hopefully shed some light regarding this.

So it looks like our documentation needs to be updated. Try this:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "prefetchCount": 10,
        "autoRenewTimeout": "00:25:00"
      }
    }
  }
}

(yes, WellKnownHostJsonProperties needs to be updated but that is only impacting logging)

So it looks like our documentation needs to be updated. Try this:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "prefetchCount": 10,
        "autoRenewTimeout": "00:25:00"
      }
    }
  }
}

(yes, WellKnownHostJsonProperties needs to be updated but that is only impacting logging)

Hi again, Paul!

Thanks for the workaround. I can now confirm that 'maxConccurentCalls' works as intended (Yay!). However, one problem persists, I am not able to get 'autoRenewTimeout' to work properly.

If I set my host.json like this:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "autoRenewTimeout": "00:55:00"
      }
    }
  }
}

and run it with the following code:

    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("%CpamTopicName%", "%CpamSubscription%", Connection = "CpamServiceBusConnection")]string mySbMsg, ILogger log)
        {
            try
            {
                for (int i = 0; i < 300; i++)
                {
                    Thread.Sleep(3000);
                    log.LogInformation("number of i: " + i.ToString());
                }
                log.LogInformation("Happy days!");
            }
            catch (Exception e)
            {
                ;
            }
        }
    }

(
I am still presented with a lock exception error. Do you have any ideas on how to keep the lock? My impression is that 'autoRenewTimeout' is not working, or am I missing something?

Thanks!

CASE CLOSED!
Hi again @paulbatum,

I can now update with the information you gave me, I researched the documentation and found the MessageHandlerOptions to have an updated name for the autoRenewTimeout as well. I tried using that and voil谩, it worked!

For anyone running into the same issue the host.json file for AF V2 should be maxAutoRenewDuration instead of autoRenewTimeout.

See example file below:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "maxAutoRenewDuration": "00:55:00"
      }
    }
  }
}

Thanks a lot for the assistance and efforts put into this :) Closing thread!

Was this page helpful?
0 / 5 - 0 ratings