Monitor new coming files and start a new VM - azure

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.

Related

Azure event hub data capture for blob addition in Azure Storage

I was trying to attain the following:
Different applications are writing to their corresponding storage accounts, say Storage A, Storage B, Storage C, etc.
I want an Event Hubs to have data from all these storage accounts working as publishers.
A single logic app would be subscribing to the event hub and doing the processing.
What I have done:
I have the storage accounts.
I created an Event Hubs namespace and an Event hub instance inside it.
Under the Event Hubs namespace -> Events, I have created a Logic App as the subscriber.
Where I am stuck:
I cannot find a way to subscribe to the events in the blob storage.
Preferably I will like to for a no-code way but am open to suggestions regarding the code approach.
I tried the Events under Storage but then I could add the logic app but it won't be a scalable solution.

how to push a message onto azure service bus and trigger an azure function to log it sees the message

I'm experimenting with Azure and Azure Service Bus. I just want to push messages onto a queue and then have my C# azure function log that is sees the message. I'm struggling to get it working. I've created an azure account, created a resource group, created a service bus, downloaded storage explorer. I have the shared access policy 'RootManageSharedAccessKey' which has the 'managed' option checked in the portal.
So guessing what I do next? I've gone to azure functions and created a function, shown below, in the azure portal. When I open up storage explorer I'm not sure what option to use to connect to my azure instance with?
Any help? Thank you!
azure function
using System;
using System.Threading.Tasks;
public static void Run(string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
Using Service Bus Explorer you can connect to Azure Service Bus and administer messaging entities. You can download the tool here.
Once you download the tool you run “ServiceBusExplorer.exe” In the Service Bus Explorer go to File Connect
Enter Connection string which you can find on in
Azure portal Dashboard --> Service Bus --> Shared access policies
After connected Successfully you will be able to see all the topics/queues in the connected servicebus select the Queue that you wanted Access
and then click on Send Messages as follows it will populate message box then you have to write the content of your message in required format(json, xml etc) and send it.
Don't confuse Azure Service Bus Queues with Azure Storage Queues. You can use Azure Storage Explorer to see Azure Storage Queues, but not Azure Service Bus Queues. To access Azure Service Bus Queues, download Azure Service Bus Explorer here To my knowledge, there is no binary distribution and you're going to need to build it yourself after cloning the repo. Once you run it and connect to your Service Bus Namespace, you can create a queue and insert messages into it.
Next, you'll need to define a ServiceBusTrigger on your Azure Function. This is an attribute that will monitor the specified Service Bus Queue and poll for new messages. When it finds one, it'll call your function. Assuming you're using Azure Functions v2, here's a Microsoft tutorial to do this.

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.

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

How to get Azure Webapp start/stop events to Azure Functions

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.

Resources