How to get Azure Webapp start/stop events to Azure Functions - azure-web-app-service

I have a requirement when webapp is started or stoped my azure function should be called. I have gone through Azure Grid Events, using Subscription as Resource Group but it does not capture any event on WebApp. So Azure Function is not called.
Is it possible to achieve this using Event Grid? I dont want to create use Custom Events.

Is it possible to achieve this using Event Grid? I dont want to create use Custom Events.
In short answer, it is not possbile to do that currenctly. We could get more information about Event grid from this tutorial.
Currently, the following Azure services support sending events to Event Grid:
Azure Subscriptions (management operations)
Custom Topics
Event Hubs
IoT Hub
Resource Groups (management operations)
Service Bus
Storage Blob
Storage General-purpose v2 (GPv2)
Note: It supports part of the region currently.
As Thomas mentioned that you could try to application insights paired with availability monitoring alert.

Related

How to monitor for newly created Azure Subscriptions?

I want to monitor for newly created Azure Subscriptions. Ideally, I would like to subscribe to events at the management group level and ingest them on event grid. What would be the best way to accomplish this?
On my research there is no native way for event grid to subscribe to events on the Management Group or Tenant Level.
As you mentioned, there is no native way to add an event grid at management group level.
However, you can use a polling technique (Azure TimerTrigger Function) with a REST GET request to obtain a list of all subscriptions, comparing to previously state and publishing its diference to the AEG custom topic.

Send Azure Blob Storage event notifications to Event Hubs on another account

In Azure, I'm trying to send event notifications from a Storage Account in one Active Directory to an Event Hub in another Active Directory.
I'm having trouble figuring out how to share/link the resource.
In AWS, I was able to accomplish this by creating a role in the receiver account, adding the source account by ID, adding the SQS Writer resource permission, and adding the SQS Queue ARN as the bucket notification destination. I'm guessing something similar is possible in Azure..
At the moment, I am looking at Active Directory IAM, which appears to have the EventGrid EventSubscription Contributor property. In the destination account I have added the source account as a contributor, and I received a notification in the source account that I had permissions in the destination account, but when I try to create an event subscription in the source account, the Event Hubs in the destination account don't show as an option.
How can I write event notifications to Event Hubs in one account from a Storage Account in another?
Absolutely yes. I think there are many ways to do that across different subscriptions, such as the two below.
Solution 1 to use Azure Functions. You can use Azure Function with Blob Trigger to get the event notifications of blob changes, and then to request the other Azure Function with HttpTrigger via PUT/POST method to transfer the event message of blob information like blob url with SAS token for accessing in other subscriptions.
Solution 2 to use Azure Logic Apps. You can use the logic flow below to get the blob change events to send the notification message to EventHub in other subscriptions, because Azure Logic Apps allows to configure their connection information manually as below.
Fig 1. The logic flow to get events from Blob Storage and send to EventHub
Fig 2. Click the Manually enter connection information to configure for a service in other subscriptions.
Fig 2-A.
Fig 2-B.
Basically, there are supported two ways in the Azure Event Grid Pub/Sub model for delivery events across the multi-tenants environment, such as:
Tightly coupled delivery of the event messages to the subscriber resource based on the RBAC. At the subscriber (destination) resource, you can
add a built-in role assignment such as EventGrid EventSubscription Contributor for Azure AD user, etc.
or add co-administrator at the Azure subscription level
The following screen snippet shows an example of the case when I am a co-administrator two Azure subscriptions such as the Stage and Development.
Creating an Event Subscription for event driven blob storage topic in the AEG provider at the Stage azure account and delivery its notification events across the azure account boundary to the Subscriber such as an Event Hub located in the Development azure account is straightforward:
Loosely decoupled delivery of the event messages to the Subscribers across the multi-tenants boundary based on the WebHook event handler endpoint. For Pub/Sub integration across the tenant boundary can be used an EventGridTrigger function with an output binding to the Event Hub resource. The following screen snippet shows this example:
The above solution is very straightforward with capability to mediate (pre-processing) an event message to the Event Hub resource.
In the case for distributing the events to another subscribers, etc. in the Fan-Out pattern manner, the Azure Event Grids can be cascaded like is shown in the following screen snippet:
In the above solution, each tenant has own Azure Event Grid provider and there are cascaded via the "plumbing" WebHook event handler endpoint and custom topic endpoint.
More details about the AEG cascading implementation can be found here.

Monitor new coming files and start a new VM

I would like to build a trigger like thing that can monitor my Azure File Storage for new coming files. If there are new files then create a VM.
What should I look at? Monitor + Alert or Logic Apps Designer?
Any one done anything similar before? Thanks!
What should I look at? Monitor + Alert or Logic Apps Designer?
I recommand that you could use Azure function+ Event Grid.
You could use the Event Grid to listen the change of the storage and implement the creating VM in the Azure function. About how to handle Event Grid events in Azure Function, please refer to this document.
Note: Currently, the following Azure services support sending events to Event Grid:
Azure Subscriptions (management operations)
Container Registry
Custom Topics
Event Hubs
IoT Hub
Media Services
Resource Groups (management operations)
Service Bus
Storage Blob
Storage General-purpose v2 (GPv2)
If Azure blob storage is possible, you could use the Azure function with blob trigger.

Is it possible to receive an event when a new resource is created

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

Can Azure Event Grid listen to changes in Azure File Shares?

I'd like to trigger an Azure Function when a file is added to an Azure File share. I've not seen any documentation on this. Is it supported?
How would I get that done?
Event grid does not support File share but there is an open GitHub issue which says it is likely to be implemented when Azure Functions V2 goes GA (General Availability).
Currently, the following Azure services support sending events to Event Grid:
Azure Subscriptions (management operations)
Custom Topics
Event Hubs
IoT Hub
Media Services
Resource Groups (management operations)
Service Bus
Storage Blob
Storage General-purpose v2 (GPv2)
Reference Docs: https://learn.microsoft.com/en-us/azure/event-grid/overview

Resources