skip to Main Content

I’d need to run an Event Hub for a few hours a day.

I’m not sure if it would be possible to schedule a time for it to be turned either on or off. In the Event Hubs portal, I see an option to disable it, but this would be a manual routine every time I’d want to turn it on/off.

I’m assuming there is an alternative, as it wouldn’t be practical to recreate the the event hub every day.

Could anyone assist?

2

Answers


  1. Yes, you can disable an Azure Event Hub, but you need to understand that it is not lowering the costs. Pricing is based on througput units which are shared by all the Event Hubs in a given namespace:

    Throughput units are pre-purchased and are billed per hour. Once purchased, throughput units are billed for a minimum of one hour. Up to 40 throughput units can be purchased for an Event Hubs namespace and are shared across all event hubs in that namespace.
    (source)

    So if that is what you are after you are out of luck as disabling a namespace is impossible and scaling back to 0 througput units is also unsupported.

    The alternative would be to destroy and redeploy the Event Hub namespace. By leveraging Bicep/ARM templates you can automate that process so you won’t have to do it manually. But then keep in mind that connection info like shared access policies changes each new deployment so any client app needs to be able to dynamically get the connection info in an automated manner if you really want to automate everything.

    Personally I would bring the costs to a minimum by scaling down the provisioned througput units to 1.

    Regarding automating the deployment: when connecting using Shared Access Signature tokens (SAS) you can create them and store them in a Key Vault using ARM templates ARM templates (example that shows how to create SAS tokens). Clients could then get the connection info using the sameAzure Key Vault.

    Or (preferable as no key vault is needed) leverage managed identities to enable client application that support managed identities to access the Event Hub. You can assign roles to managed identities using ARM templates as well. (doc showing example of how to assign roles)

    Documentation is a bit scattered and I can’t yet find an example ARM template that does it all together so you probably have to combine some examples to get it right.

    Login or Signup to reply.
  2. I could able to automate the process using Logic apps. In logic Apps you can use Create or update a resource action to disable the eventhubs by changing its status. To schedule it to work at times I have used recurrence trigger. Below is my workflow:-

    enter image description here

    enter image description here

    RESULTS:

    enter image description here

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search