Call external API on change to Azure SQL database table - sql-server

We have a table called Guest in an Azure SQL database. We also have a campaign management tool sitting behind an API on the providers cloud.
When a record is created, updated or deleted in the Guest table, we would like to call the API in order to update the campaign management tool with the latest information about the Guest.
Our initial idea was to hook up a database trigger to a C# .NET Azure Function, however, it looks like this is only supported in Cosmos DB.
We would prefer not to have an application running on a scheduled task that periodically checks for changes in the database and sends these changes to the API.
We have also been reading about creating CLR stored procedures but it looks like these are not supported in Azure SQL databases.
Looking forward to hearing ideas & suggestions.

I can think of a few ways to accomplish this.
[Unfortunately CLR is no longer supported in SQL Azure.]
One way is:
Turn Change Data Capture on, on your Guest table.
Create a server-less Azure Function that has a timer trigger. This function would use the CDC to determine what had changed in your table, and call your vendor API accordingly.
The server-less function is relatively lightweight compared to "an application running on a scheduled task".

You can also use Azure Logic Apps for this case.
There are some predefined trigger which helps to trigger
When an item is created
When an item is modified
Then using the Action to call your API
Refer here
This will be the simplest way that you can achieve your usecase.

You will have to migrate to Azure SQL Managed instances which supports CLR and Broker.
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance-transact-sql-information#clr

Related

Best way to get Azure and local SQL Server development databases to sync on request

I'm looking for a one click system that doesn't require one to delete the Azure database, publish from the local server, and re-create the user info onto the deployment.
What currently works:
Drop existing Azure database.
MSDeploy the database to azure.
Move the database to the app pool
Configure Azure database user/access
I briefly looked into the Azure sync, but that doesn't seem like something one can use "on request". Do correct me with example if I'm wrong on this assumption.
The ideal solution would be a one button click from Azure Data Studio to push any and all changes from the (localdb) database to the live one.
Azure Data Studio doesn't provide any readymade Single Click data transmission feature from local to cloud or vice-versa.
Azure Data Studio offers a modern editor experience with IntelliSense,
code snippets, source control integration, and an integrated terminal.
It's engineered with the data platform user in mind, with the built-in
charting of query result sets and customizable dashboards.
It doesn't provide in-built data push feature. Either you should use any programming language to build a dashboard as per your requirement, or you need to use Store Procedure for it.

Azure SQL database table - archiving to different Azure SQL database

I want to move all data from one Azure SQL Server to different Azure SQL Server which more than 90 days old, and after moving need to delete moved data from first Azure SQL Server.
I want to run these steps on daily basis.
I am new to Azure and able to do same with Azure Data Factory. Can you please suggest any other best suited approach?
You are already using the best approach.
Azure Data Factory is an easy to use when it comes to extract and copy the data between the services. It also provide scheduling the triggers, i.e., triggering the copy pipeline after specific interval of time or any event. Refer Create a trigger that runs a pipeline on a schedule.
If the volume of data is large, you can re-configure the Integration Runtime (IR) resources (Compute type and Core count) to overcome the performance issue, if required. Refer below image.

How to get notification from Azure Sql database on insert

I need to get a notification or call a webservice whenever a row is inserted into a specific table in my Azure Sql Database. I have been searching the web for a good solution, but i haven't found any.
I tried to call a web app service in Azure - but this is not allowed from Azure Sql Databases.
I looked at the Azure logic apps, but the SQL Server Connector has been removed.
How do I get notificated when a row is put in?
Although this is not natively supported in SQL Azure, there are a few different options you can consider.
1) Modify the calling code to insert a row into the table and write a message to Azure storage queue. You can have a separate process which drains the message from the queue and invokes the web service so that these actions are loosely coupled.
2) Enable change tracking on the specific table so that your app can discover the latest changes (i.e. inserts) to the table. This feature is well documented if you search the Azure SQL docs.

SQL Azure data replication between two Azure subscriptions

Since I initially created an Azure SQL Server database while building an app for a client, they have changed Azure subscriptions. The client wants the database migrated to a new account and eventually deprecate use on the old account when we are done with the new version of the app. In the meantime, they want any updates from the old database duplicated into the new database.
My question is, is there a way to update two databases, one a copy of the other, at the same time on separate Azure accounts?
I've read into active geo-replication but that looks like it can only be done between two databases in the same Azure subscription.
Thanks for the help.
Active geo-replication indeed is only possible inside a subscription, if you are using Azure SQL that wouldn't be possible with it. You could possibly use some kind of replication using on Premise SQL, but that would be pretty hacky. You would want to work with Azure SQL Data Sync.
If you are using a VM with the SQL Server you could create AlwaysOn databases for that purpose.
But if the question is: My question is, is there a way to update two databases, one a copy of the other, at the same time on separate Azure accounts?. You could probably code your application in such a way to write to 2 databases, but again, you would also need to keep track of operations

Sync Offline Database with External Database Windows Phone 7

I have a wp7 app that uses the local database implemented with linq. I have an external MS-SQL (2008 R2) server. Both databases have the same schema.
I would like to know how to do the following:
Download information from the MS-SQL to the Database into the local DB of the phone. (Can I use some data-binding technique - I have found no links that do this)
If Changes made on the phone (add new record, edit existing record) how can I push changes back to server.
If changes are made to server then push to phone (I know I can use an observer pattern here)
I should also note that the client app is not used always-on access to the internet.
Thanks
There's no magic here.
You will need to create functionality to get updates from the server (probably meaning you need some kind of timestamp on each record, saying when it was last changed so you can query it).
You will need to create the functionality to upload data and update the database on the server (and potentially handle conflicts).
I would either use ODATA to communicate with the server, or plain old WCF/JSON service.
have a look at the Sync Framework Toolkit

Resources