Azure Logic App - Twitter and MS SQL Connector issues
I created an Azure Logic app that looks for tweets containing ChinarTrading and then stores them in a SQL database. Below are the questions I am running into:
- The Twitter connector only looks for tweets on the twitter account that I used to authenticate. If ChinarTrading tweets are added from another Twitter account, it will not be returned in search results.
- Twitter connector returns the same tweets again as skipping old tweets.
- In SQL Connector I use Insert operation how to add a condition like insert if it was not already there (tweet text not found).
Use a stored procedure instead of using an insert operation. In the stored procedure, execute IF EXISTS UPDATE ELSE INSERT.
IF EXISTS (SELECT * FROM Tweets WHERE [TweetId] = 'SomeId')
BEGIN
--UPDATE HERE
END
ELSE
BEGIN
-- INSERT HERE
END
There is no direct way to add a condition like insert if it doesn't already exist. You can try to do this using "Add Condition" from deisgner.
So maybe you can use "SQL Azure-Get Rows" and then add "Condition" and then based on the result of the condition you add to the "SQL Azure - Insert Row" action
The Insert Row API query POST: /datasets/default/tables/{table}/items
only has 2 parameters table
and item
(row to insert into the specified table in SQL) while the Get Rows call allows you to query ( $skip, $top, $filter, $orderby
)
As with tweets, there is currently no way to skip old tweets as the API call only takes parameters searchQuery
and maxResults
according to Twitter API Documentation