Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Azure Function Not Triggering by Event Hub in Consumption plan

Open navilwayne opened this issue 9 years ago • 33 comments

Hi Folks

  • I have a Event Hub Trigger function app with consumption plan. It was working, when I open the portal in UI & continue to run for 3-4 hours , after that it automatically sleeps, when no request coming to event hub.
  • Next day when request come again , it is not triggering, until I open portal. I am facing the same issue for last 2 weeks
  • In last, I have to swap @from Consumption Plan to App Service Plan to run this.

When we can expect fix for Consumption Plan ???? @cgillum & @davidebbo Thanks.

navilwayne avatar Jan 03 '17 06:01 navilwayne

@navilwayne Does your connection string have an EntityPath? If so can you try removing it? We have a bug in our scale infrastructure that prevents us from reading the state of the event hub if there is an entity path present.

paulbatum avatar Jan 03 '17 21:01 paulbatum

Hi @paulbatum Yes, I have EntityPath in my connection string(EntityPath contains name of Event Hub) Sample Endpoint=sb://xxxxxxxxx.servicebus.windows.net/;SharedAccessKeyName=xxxxxxx;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=;EntityPath=xxxxxxxxxxxx

I am getting below error if I removed entity path from connection string as suggested by you. Microsoft.ServiceBus: The messaging entity 'Management operation failed. status-code: 404, status-description: The messaging entity 'sb://xxxxxxxxxxx.servicebus.windows.net/samples-workitems' could not be found..' could not be found.

Session Id: c1c36cf02ce54fd89d26704d9cb57f22

Please suggest. Thanks.

navilwayne avatar Jan 04 '17 17:01 navilwayne

@navilwayne Did you enter the correct name of your event hub in the integrate section of the UI?

image

Alternatively if you are working from within VS or using the "advanced editor" the input binding in your function.json should have the correct "path" property that corresponds to your event hub name:

{
  "type": "eventHubTrigger",
  "name": "sensorEvent",
  "direction": "in",
  "connection": "EventHubsConnectionString",
  "path": "hub1",
  "consumerGroup": "$Default"
},

paulbatum avatar Jan 04 '17 17:01 paulbatum

@paulbatum Yes It is working now. But is this finalised now that always we have to remove the entity path from connection string in event hub scenario or it is temporary fix.

In what another scenario's we have to do modification in connection string. For example in Blob or etc.

navilwayne avatar Jan 09 '17 06:01 navilwayne

@navilwayne glad to hear its working. Removing the entity path from the connection string is a temporary workaround until we fix a bug on our side. You shouldn't need to do this any other scenarios (that I'm aware of).

paulbatum avatar Jan 12 '17 18:01 paulbatum

I have the same problem - as soon as I close portal blade for function app, it stops receiving events. My connection string does not contain EntityPath. I have two Azure Functions in two different resource groups. One works and the other does not. Frustrating.

sergsalo avatar Feb 01 '17 22:02 sergsalo

@sergsalo Can you share your function app name (that's the app name, not function name!), either directly or indirectly? This will help us investigate. Thanks!

davidebbo avatar Feb 02 '17 00:02 davidebbo

@davidebbo let me recreate it, because I started to use app service plan instead of consumption plan.

sergsalo avatar Feb 02 '17 00:02 sergsalo

Thanks. If it's a test site, then you may as well share the App Name directly, which is a bit easier.

davidebbo avatar Feb 02 '17 00:02 davidebbo

it seems like it is working after redeployment. I will leave it overnight, and report back if it stops working.

sergsalo avatar Feb 02 '17 01:02 sergsalo

Odd. Oh well, if you or anyone else run into this again, please give us the Function app name and we'll dig into it from our end. But as far as we know, the issue is now fixed.

davidebbo avatar Feb 02 '17 01:02 davidebbo

Hi @davidebbo, I've got similar problem, but on App Service Plan (Standard S1). We've got function with Event Hub trigger, Always On is turned on in Application Settings. Everything worked fine for a couple of days, and then it stopped processing any event hub messages. After opening Function editor in portal and manually triggering the Function using Run button, it processed events and started working, but after a few hours it stopped again. The function app name is cx-in-functions.

xelossan avatar Feb 17 '17 09:02 xelossan

@xelossan the issue discussed here was very specific the the Consumption plan (I just clarified the title). Closing this one since we believe it is fully fixed.

Please open a separate one if you see thing in a Standard plan. Make sure to include the details we need for investigation, as discussed above (site name, function name, timeframe of incident, ...).

davidebbo avatar Feb 17 '17 16:02 davidebbo

@davidebbo It happens again. Consumption plan. Function name: ampbrokerhxc23nhsty2jk, appName: http://ampbrokerhxc23nhsty2jk.azurewebsites.net.

The interval between data arrival is 5 minutes. Trigger: TriggerAzureMetrics. If I watch it - it works fine. If I leave portal - it stops working. consistent.

sergsalo avatar Mar 08 '17 07:03 sergsalo

@sergsalo I have a suspicion as to what might be going on: how are you editing your function files, and in particular function.json (which contains the triggers)? If you're doing it via App Service Editor, then it doesn't properly sync the triggers, which would explain this.

Try going to the Functions UI and clicking the Refresh button in the bottom left corner. That should get you fixed up.

davidebbo avatar Mar 08 '17 20:03 davidebbo

@davidebbo apparently it is working now after refresh. We deploy function using ARM Template and powershell scripts to push code. Is there API we can call to "refresh" after deploy?

sergsalo avatar Mar 08 '17 22:03 sergsalo

See here for PowerShell / API example.

How exactly is your script pushing the code?

davidebbo avatar Mar 08 '17 23:03 davidebbo

We are pushing using Kudu API: $apiUrl = "https://" + $functionName + ".scm.azurewebsites.net/api/zip/site/wwwroot" Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method PUT -InFile $fileName -ContentType "multipart/form-data".

sergsalo avatar Mar 08 '17 23:03 sergsalo

Ah yes, that would do it. Currently, the only deployment techniques that automatically do a sync are:

  • Function Portal
  • Git deployment via Kudu
  • WebDeploy (e.g. VS publishing or VSTS)

I think if you integrate the PowerShell I gave you into your script, it will work reliably.

davidebbo avatar Mar 08 '17 23:03 davidebbo

cool, thank you so much for quick update!

sergsalo avatar Mar 09 '17 00:03 sergsalo