I want to react to my Function App Events, specifically when a slot is swapped. I have hundreds of Function Apps which I want to Monitor but I want all the events to be handled by a single Event Handler (probably a Logic App).
I have multiple Logic Apps and Function Apps stored in a Subscription. I want to be able to use Event Grid to monitor them and react to changes. For the Logic Apps, I wanted to know every time a Logic App is saved which was fairly easy to do - I created an Event Grid which looks at Resources across a subscription and is triggered when any Resources are written successfully. And then I added some filtering so that it only reacts to Logic Apps (Microsoft.Logic/workflows) which works very well.
Where I am struggling is with the Function Apps. I want to monitor all the Function Apps and look out for any slots being swapped. I can do this by creating an event grid for each Function App but this seems wasteful to do for every singe one, whereas for the Logic App I can just have a single Event Grid which monitors everything.
What's the best way to go about this?
You can use Azure Event Grid to monitor the events from multiple Function Apps and have a single Event handler as a Logic App to process the events.
Created event grid as shown in below image by taking Endpoint type as Azure function and Endpoint as EventGridTrigger1.
After that In Event Grid Enable Subject Filtering in Filters and then take Microsoft. Web/sites/*/slots/swapped in Subject begins with field to allow the Event Grid to subscribe to all slot swapped events across all your Function Apps in the subscription.
In function app we are taking Azure Event Grid Trigger as function.
Then Create a logic App in the same subscription ,resource group and same region as function App and EventGrid taken .
When a resource event occurs Event grid trigger and Filter array action taken.
In the When a resource event occurs trigger configuration, select the Resource Type as Microsoft.EventGrid.Topics and Resource Name as you created EventGridName.
Then add an "Filter array" action to filter the events to only include events from Function Apps.
AFAIK currently the wildcard for all azure function apps is not supported so you can create as mentioned in above process or else raise a Microsoft support for this.
Related
I want to design azure functions in Python language to read events from more than one event hub . The number of event hubs are not constant , it can increase or decrease (for example one event hub publishes logs from one azure AD tenant and in future AD tenants can be added). Each function will have same business logic ,only the even hub connection string will differ .
Event hub triggered function can use only one event hub , not more than more .
So, What is the best approach for this problem statement :
Creating 1 Event hub triggered function for each event hub and keep all functions under one azure function APP and to have shared code which can be used by all functions .
Cons : If a new event hub added , need to create a new function and deploy function standalone with Zero downtime of function APP ,which is not possible .As per azure doc ,the deployment unit should be Function APP, not individual functions .
Creating 1 function APP with single Event hub triggered function
subscribing to one event hub .
Pros As new function app is different for each event hub, if a
new event hub added other function apps won't be impacted and zero
downtime for them
Challenge Assuming we have one Github repo with function
logic, function.json , Is it possible to create a function app each
time a new event hub added and create a deployment integrating with
git repo. In future I want to use azure pipelines or Github actions
for CI/CD , will this approach create any issue.
If the business logic is exactly the same, then you can extract the core logic and put it in an http trigger function. You only need to create multiple Azure logic apps to trigger and pass the content of the event hub to the function for processing.
This way you don't have to worry about the downtime caused by multiple deployments, and I think it is easier to create multiple Azure logic apps than to create multiple Azure functions.
You can refer to my logic app design:
I am designing Http trigger function. This function will be used to authenticate and to call an external API. Then get the response and pass it on to the caller(~in this case web application).
This function can be called thousand time/min(~during peak load).
I am going through event grids and having hard time deciding why to use it.
Microsoft says to safeguard your events so that it's not lost due to any reason I should use it along with my http trigger azure function.
I can very well design a queue trigger function which will process these requests in queue.
I am referring to this article of MS which says to use Event grid to gain more control on your serverless function for example:
MS Event Grid
I am going through event grids and having hard time deciding why to
use it.
I can very well design a queue trigger function which will process
these requests in queue.
I think this needs to be based on your needs. The event grid is discrete based on event triggers. And event grid has higher scalability.
If you use a queue trigger, it is not triggered based on an event, is it? All in all, it is not necessary to use event grid. Please refer to your use case for specific use.
If you want a comparison study of the messaging services you may refer to : https://tsuyoshiushio.medium.com/azure-messaging-service-in-a-picture-f8113cec54cd
https://hackernoon.com/azure-functions-choosing-between-queues-and-event-hubs-dac4157eee1c
For event grid, Azure Event Grid is an eventing service for the cloud. Azure Functions is one of the supported event handlers.
Azure Event Grid allows you to easily build applications with event-based architectures. First, select the Azure resource you would like to subscribe to, and then give the event handler or WebHook endpoint to send the event to. Event Grid has built-in support for events coming from Azure services, like storage blobs and resource groups. Event Grid also has support for your own events, using custom topics. reference
I'm working on an Azure Logic app that should trigger when a new resource is created.
However, if I trigger the app based on a webhook using monitor alerts or an event subscription, I run into the problem of each creation event will have 2 identical events with all the output being identical which means I can't filter it out and therefore triggers the logic app twice.
If there a different route around to just get the app to trigger once?
I believe the multiple events are because the event type for both create or update is the same as documented.
One way to workaround this would be to keep track of resourceIds touched by your Logic App, OR add a tag to your resource which signals that it has been touched. This way you wouldn't need an extra store for this metadata.
I have scenario that I want to read all messages from all topics a and a specific subscription using azure logic app connector.
Example: topic ATopic, BTopic has a same name "TestSubscription" subscription
Using azure logic app I want to read all topics messages on above "TestSubscription"
I have mark in read in below image at particular place I want a dynamic topic name
The common pattern for scenarios like this is to have a Logic App for each Trigger/Topic/Subscription.
Then these Logic Apps, two in your case, call a third work Logic App which does any real message processing.
You can use the Event Grid trigger if you have Service Bus premium, to subscribe to Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners event. Once the Logic App is triggered, you can then use the Service Bus action to retrieve the actual message and process it.
I would like to run some automation to take some actions whenever a new resource is created in One of my subscriptions in Azure. Is this possible?
You can use Azure Event grid for this, a solution that is built for exactly this purpose. Taken from https://learn.microsoft.com/en-us/azure/event-grid/overview
Azure Event Grid allows you to easily build applications with event-based architectures. You select the Azure resource you would like to subscribe to, and give the event handler or WebHook endpoint to send the event to. Event Grid has built-in support for events coming from Azure services, like storage blobs and resource groups.
You basically create a subscription to a certain event (such as specific resources being created) that can then be picked up by a webhook, or processed by Azure Automation or Azure Functions