Alternative to trigger Azure Functions or AppService based on a table row insert into Azure SQL MI - azure

Is it possible to trigger Azure Functions or AppService webapp whenever an insert operation is performed against a table on Azure SQL MI?
if not, is there a way to trigger applications outside Azure SQL rather than using LogicApp? I want to avoid LogicApp because it requries using one more application, and it is still using polling.
Link below said it is not for Azure functions
https://feedback.azure.com/forums/355860-azure-functions/suggestions/16711846-sql-azure-trigger-support
Link below suggests using LogicApp.
Trigger Azure Function by inserting (adding) new row into table, SQL Server Database

Today, in Azure SQL, there is no such possibility. The closest option is to create a Timer Trigger Azure Function that checks if there has been any changes in the table you want to monitor (using Change Tracking, for example).
If you are using Azure SQL MI instead, you could create a SQLCLR procedure that calls an Azure Function via an HTTP request or, another option, via Azure Event Hubs or Azure Event Grid

There have been several feature requests for triggering Azure functions based on changes to at Azure SQL database. For example:
https://github.com/Azure/azure-functions-python-worker/issues/365
It seems that they are not prioritizing it, since it is possible to implement this functionality using logic apps.

Related

Is there a way to get sensor data from IoT central a MySQL database?

I created simulated sensors that send the data heartrate, blood pressure and temperature. However, I am not sure how to send this data to a MySQL database. I believe that one of the ways I can do it is use Azure functions to send the data, but I am not sure how to go about it. Can anyone help?
Welcome to the community! You can achieve your use case with the following steps.
Push data from Azure IoT Central to an Azure cloud end point such as Event Hub or Service Bus. Here are the supported cloud destinations.
Note If this is a mockup project and you are using MySQL database for testing, I would recommend going with Azure Data Explorer instead. It will eliminate the need for next two steps if you decide to go with Export to Azure Data Explorer. If you still would like to use MySQL database, go with either of the following options-- a) Export to Service Bus b) Export to Event Hubs
Create an Azure Trigger function based on your cloud end point.
a) Azure Event Hubs trigger for Azure Functions
b) Azure Service Bus trigger for Azure Functions
Within this function, you can write custom code based on the coding language you choose to push data to MySQL database. Here is a reference tutorial that pushes data from Azure Functions to Azure SQL DB -- Azure SQL output binding for Azure Functions

Cross Database Insert in Azure?

Is it possible for me to insert some data from one database to another in Azure sql?
Let's say I have a trigger in db1 that updates some values in db2.
I read about elastic queries but it seems like they are read-only so they don't solve my problem.
You can't use cross-database in Azure Sql Server because databases can't see eachother physically , you could use elastic pools but they are Read Only.
A solution is to use SQL Managed Instance to upload your instance . This supports cross-database queries but it was expensive.
There was some previous discussion here about doing similar:
C# Azure Function trigger when SQL Database has a new row added without polling
There is also the Azure SQL Bindings for Azure Functions but they are input bindings and not triggers and they're still in preview and limited to C#, JavaScript and Python.
Azure SQL bindings for Azure Functions overview (preview)
There was a new announcement last week after MS Build however for Azure SQL Database External REST Endpoints Integration (hopefully they don't refer to it as ASDEREI) but this is currently in preview under Early Adoption Program (EAP).
Announcing the “Azure SQL Database External REST Endpoints Integration” Early Adoption Program

Add Message to Azure Queue when Azure Table Storage is updated

Currently, I have an Azure Function App which runs every hour (timer trigger) that pulls data from Azure table storage and updates a NSG. I only did it this way because Function Apps currently DON'T support Azure Table triggers; however Function Apps DO support Azure queue triggers.
With that said, i'd like a message be sent to the queue every time my Azure Table is updated. That way, the Azure Table updates can happen immediately compared to every hour. Haven't figured out how to send messages to Azure Queue from Azure Tables though.
Any help?
There is no change feed, update triggers etc. on Azure Table storage. You could achieve this by switching to Tables API on Cosmos DB - which does have a Change Feed.

Workaround for xp_cmdshell in Azure SQL Database

Stored procedure in on-premises SQL Server is used to call another app through 'xp_cmdshell'.
Now I am trying to do the same on Azure SQL Database. Of course 'xp_cmdshell' is not supported there, so I need workaround.
I was thinking of using Azure Functions as a bridge between Azure SQL Database and app on VM.
Is it possible to call Azure Function from Azure SQL Database using
stored procedure?
Is it possible to call app on Azure VM from Azure
Function?
Not at the moment. The workaround is to create a Timer-based Azure Function that polls the data every "x" minutes or seconds.
As long the app on Azure VM expose an HTTP endpoint, and you configure the network and the firewall correctly, yes.
The best practice is to use Azure Automate to run tasks on the VM then using a pipeline in Azure Data Factory you can invoke the runbook using a webhook

Azure Functions - Table Storage Trigger with Azure Functions

I need a way to trigger the Azure functions when an entity is added to the Azure Table storage. Is there a way to do this ? When I tried to add a new Azure function, I did not see any Azure Table storage trigger. I see there is Queue and Blob triggers available.
If there is no support for the Azure table storage trigger, then should I need to have a Http trigger and have the Azure Table storage as input binding ?
Thanks
There is no trigger binding for Table Storage.
Here's a detailed view on what is supported by the different bindings available today:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#overview
If there is no support for the Azure table storage trigger, then should I need to have a Http trigger and have the Azure Table storage as input binding ?
Yes, this approach would work and would allow you to pass the table data as an input while relying on a separate trigger. Depending on the type of clients you are working with, and your requirements, using a queue trigger is also another good option.
#venki What the Fabio Cavalcante said to you is really true. Azure Function doesn't have a trigger option for Storage Table. But, whether your business needs store the data into the Storage Table and you as a Developer decide to use Azure Function into your architecture, you're able to configure you Function to use data that will come from Storage Table as a Input to your Function! This works really well.
But, There is another way to configure your Function to have "automagically" trigger, using Storage Queue (for small business) or Service Bus (for a business that needs a mechanism more robust)

Resources