[NEWS] Azure News of the week
5. Juli 2024Also this week there were many news around Microsoft Azure! Here as always the overview for you: Have fun reading and trying it out…
As described in part 1 and part 2, my Schedule Tweets solution doesn’t look that bad. But one important component is still missing: sending the tweets…
At first I thought about sending the tweets via Microsoft Flow. But then I had to find out some things:
So we had to find another solution…and because Flow in the background is only based on Logic Apps…then we take the…
Thanks to the Consumption Model I can do what I want in the Logic App…it is regularly charged against my Azure Subscription…and there are no limits anymore.
So here we go. First create a Logic App and then start the Logic App Designer.
The basic structure was clear quite quickly…I periodically check the list elements and receive the info and then process the elements accordingly:
Now some conditions had to be queried and branches had to be established:
All in all, it looks like this.
And the tweets are already working… To be on the safe side here again the code of my Logic App
{
"$connections": {
"value": {
"sharepointonline": {
HAVEYOUROWNCONNECTIONHERE },
"twitter": {
HAVEYOUROWNCONNECTIONHERE }
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Apply_to_each": {
"actions": {
"Condition": {
"actions": {
"Condition_2": {
"actions": {
"Apply_to_each_2": {
"actions": {
"Get_attachment_content": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('YOUR URL'))}/tables/@{encodeURIComponent(encodeURIComponent('YOUR UID'))}/items/@{encodeURIComponent(encodeURIComponent(items('Apply_to_each')?['ID']))}/attachments/@{encodeURIComponent(items('Apply_to_each_2')?['Id'])}/$value"
},
"metadata": {
"flowSystemMetadata": {
"swaggerOperationId": "GetAttachmentContent"
}
},
"runAfter": {},
"type": "ApiConnection"
},
"Post_a_tweet": {
"inputs": {
"body": "@body('Get_attachment_content')",
"host": {
"connection": {
"name": "@parameters('$connections')['twitter']['connectionId']"
}
},
"method": "post",
"path": "/posttweet",
"queries": {
"tweetText": "@{items('Apply_to_each')?['TweetText']} @{items('Apply_to_each')?['Hashtags']}"
}
},
"metadata": {
"flowSystemMetadata": {
"swaggerOperationId": "Tweet"
}
},
"runAfter": {
"Get_attachment_content": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Update_item": {
"inputs": {
"body": {
"Hashtags": "@items('Apply_to_each')?['Hashtags']",
"Sent": true,
"Title": "@items('Apply_to_each')?['Title']",
"TweetText": "@items('Apply_to_each')?['TweetText']",
"When": "@items('Apply_to_each')?['When']"
},
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "patch",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('YOUR URL'))}/tables/@{encodeURIComponent(encodeURIComponent('YOUR UID'))}/items/@{encodeURIComponent(items('Apply_to_each')?['ID'])}"
},
"metadata": {
"flowSystemMetadata": {
"swaggerOperationId": "PatchItem"
}
},
"runAfter": {
"Post_a_tweet": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"foreach": "@body('Get_attachments')",
"runAfter": {
"Get_attachments": [
"Succeeded"
]
},
"type": "Foreach"
},
"Get_attachments": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('YOUR URL'))}/tables/@{encodeURIComponent(encodeURIComponent('YOUR UID'))}/items/@{encodeURIComponent(encodeURIComponent(items('Apply_to_each')?['ID']))}/attachments"
},
"metadata": {
"flowSystemMetadata": {
"swaggerOperationId": "GetItemAttachments"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"expression": "@lessOrEquals(items('Apply_to_each')?['When'], utcNow())",
"runAfter": {},
"type": "If"
}
},
"expression": "@equals(items('Apply_to_each')?['Sent'], bool(false))",
"runAfter": {},
"type": "If"
}
},
"foreach": "@body('Get_items')?['value']",
"runAfter": {
"Get_items": [
"Succeeded"
]
},
"type": "Foreach"
},
"Get_items": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('YOUR URL'))}/tables/@{encodeURIComponent(encodeURIComponent('YOUR UID'))}/items"
},
"metadata": {
"flowSystemMetadata": {
"swaggerOperationId": "GetItems"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Minute",
"interval": 15,
"timeZone": "W. Europe Standard Time"
},
"type": "Recurrence"
}
}
}
}
Leave a comment