Azure Function Trigger from Event Hub in another account - azure

I am working with multiple Azure accounts, for example account A is my account, and B is another separate account.
In the other account (B), logs are being sent into Azure Event Hub, and i have access the primary/secondary keys etc. to access.
What I want to do is have that Event Hub (B) trigger a Azure function in my account (A) to do some processing on those logs. Is it possible to have an Event Hub from another account trigger a function from another account? Right now when i look at the connections possible, i can only see my personal namespace(s), IOT Hub, and Custom. Is there a key/value pair i should be generating from the other account (B) so i can access via the "custom" connection?
Thanks

The Function created using your Azure subscription A can create a trigger that is listening on the Event Hub created using Azure subscription B. All you have to do is provide the correct and valid connection string from the Event Hub created using subscription B.

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.

Getting Azure Blob Store Eventgrid Notifications from another Azure Account

we work with an other company who just proposed us to privide us with an azure blob store SAS token. But we would like to use the events triggered by the Blob store and provided by the Azure Eventgrid system.
Is this possible ?
Why we have to this on our azure account is for billing purposes, we need the Events they don't we will have to pay for through our account
I hope someone can lead me in the right direction.
Azure Blob Storage as an Event Grid source works for Microsoft.Storage.BlobCreated and Microsoft.Storage.BlobDeleted and when an event is triggered, the Event Grid service sends data about that event to the subscribing endpoint. Those event grid subscriptions exist in the same Azure Subscription as the resources.
Webhook Event delivery is one of the many ways to receive events from Azure Event Grid and this is something you can host in your Azure Subscription (or even outside of Azure).
Given the Price per million operations is only $0.60 per the Event Grid Basic tier, the Webhook notification will allow you to pay for all but a negligible amount of the costs.

Azure Event Grid topic subscription with Service Bus queue handler

I'd like to set up an Event Grid Subscription for a topic with a Service Bus queue as the handler. The Service Bus queue lives in a separate subscription from the Event Grid topic; user accounts do not have standing access to both subscriptions. Therefore, I'm wondering if there is a way to configure the handler with the Service Bus connection string. Is this currently possible? Are there any work-arounds?
Today, the only way to directly do this is the user creating the Event Subscription must have permissions to write to the Service Bus queue, so you would have to grant at least that level of access.
Once Managed Service Identities lands in Event Grid for publishing, you'll be able to assign write access to the MSI and then direct Event Grid to use that MSI with the Event Subscription for publish.
As Roman said, for such resources belonging to different subscriptions, you can use the Event Grid Trigger in Azure Function. You can configure the endpoint of the Event Grid topic subscription to an Azure Function, and then use this Azure Function to pass information to the Service Bus queue in another subscription.

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.

IOT hub to Email Notification

I am developing a Azure IOTHUB use case.
Multiple Load cells are sending continuously (every 1/2 sec) sending data to IOTHUB. (DeviceID, weight).
SQL Table with User Data .
I want to make a system that that sends an email notification on certain weight to the device owner.
What is the right approach to achieve that.
I have seen Logic apps is an option but how to implement it with multiple user account and devices.
I would use IoT Hub routing to push the messages that meet the weight criteria to a service bus queue. From there you can use an Azure Function with a Service Bus Trigger. I assume the user account information (e-mail address?) is available via a query in the SQL table. Azure Functions have a SendGrid binding that you'd then use to send out the e-mail.
Note that routing IoT Hub directly to a function is on the backlog.
Basically, there are two solutions for your scenario, when each device has own criteria on the weight:
The device twin desired property contains a weight value used for publishing a non-telemetry alert message by a real device to the Azure IoT Hub. This alert message can be routed in the Azure IoT Hub Routes to the custom endpoint the same way like is described in Jim's answer (ServiceBus->AzureFuction->SendGrid)
The second solution is more complex, generic, very flexible and it doesn't require any special coding on the device side or device twin. It's based on the standard telemetry stream pipeline with Azure Stream Analytics (ASA) job for analyzing events and generating a notification message for output to the Azure Function with SendGrid. The ASA job used a reference data (user data, weight, etc.) from the blob file generated and refreshed by SQL Database.
The following screen snippet shows this solution:
I would like to present one another approach which I think is correct too (I tested this flow):
Data is sent to the Azure IoT Hub from device
Azure Stream Analytics filters this data basing on weight and deviceID
Once data is analyzed there is a call to the Azure Function which triggers Azure Logic App with data collected from the Stream Analytics
Azure Logic App receives data (HTTP trigger) from Azure Function App
Then Logic App uses "Get row" action step to get user data from SQL Database
Last step is up to you - you can use either "SendGrid - send e-mail" action or integrate Logic App with Outlook or even Office365, Gmail and other services.
Here are the links to the documentation:
Connect to SQL Server or Azure SQL Database from Azure Logic Apps
Send emails and manage mailing lists in SendGrid by using Azure Logic Apps

Resources