How I use Azure Logic App, API App and Function App in my life
How I use Azure Logic App, API App and Function App in my life
Why should we do things over and over? I know I don't want to lose my time doing so. Every time I see myself doing something I already did, I look for optimization. Sometimes, it's just little things like trying adifferent path to get from the train station to the office, and the other time, it's like drinking the rainbow juice directly from the source.
In this post, I will share with you how I optimized a three hours process into a two... minutes automated customizable solution using Azure Logic App and API App.Quick Context
For the past two hundred fifty something weeks every Monday I share my reading notes. Those are articles that I read during the previous week with a little comment; my 2 cents about it. I read all those books, articles and posts on my e-book reader; In this case a Kindle whitepaper. I use an online service call Readability that can easily clean (remove everything except the text and useful images) the article and send it to my e-book reader. All the articles are kept as a bookmark list.
When I have time I read what's on my list. Each time I'm done, I add a note ended by tags between square brackets, those will be use later for research and filter.
Every Sunday, I extract the notes, then search in Readability to find back the URL and build with all this my post for the next morning. A few years ago, I did a first optimization using a Ruby script and I blogged about it here . While it's been working very well all those years, I wanted to change it so I do not have to install Ruby and the Gems on every machine I use.Optimization Goals
Here is the list of things I wanted for this new brew of the Reading notes post generator:No install required not device or service couple. generate json verrsion for future purpuse cheap Optimization Plan
Azure Logic App is the perfect candidate for this optimization because it doesn't require any local installation. Since it a flow between connectors any of them can be changed to please the user. In fact, that was the primary factor that made me picked Azure Logic App. For example, i the current solution, I'm using OneDrive as aninitial drop zone. If you your environment you would prefer using DropBox instead of OneDrive, you just need to switch connectors, and nothing else will be affected. Another great advantage is that Azure Logic App is part of the App service ecosystem so all those components are compatible.
Here is the full process plan, at the high level.
Drop the My Clippings.txt file in an OneDrive folder. Make a copy of the file In Azure Blob Storage, using the Blob Storage built-in connector. Parse the My Clippings.txt file to extract all the clippings (notes) since last extraction, using my custom My Clippings API App . For each note, Get the URL where that post is coming from, using my custom Readability Api App . Extract the tags and category (first tag is used as a category), using my custom Azure Function. Serialize the note with all the information in json. Save to Azure Blob Storage the json file in a temporary container. Generate a summary of all json files using my last custom ReadingNotes API App . It also saved a json and Markdon files of the summary.
Note: The summary could be published directly, but I decided to keep that last step manual, so I can check for typos and Grammar.Let's see more in details
Many great tutorials are already available about how to create Azure Logic App or Azure API App, so in this post, I won't explain how to create them, but mostly share with you some interesting snippetsor gotchas I encounter during my journey.
In the next screen capture, you can see all the steps contained in my two Logic App. I decided to slip the process because many tasks needed to be done for every note. The main loop (on the left) fetches the notes collection and generates the output. For every note, it will call the Child Logic App (on the right).
The ReadingNotes Builder contains:Initial Trigger when a file is created in an OneDrive folder. Create a copy of the file in an Azure Blob storage. Delete the file in OneDrive. Get the configuration file from Azure blob storage. Call the API App responsible for parsing the file and extract the recent clippings. Call the child Logic App for every clipping returned in the previous steps (foreach loop). A. Trigger of the Child Logic App. B. Call the API App responsible for searching in the online bookmark collection and return the URL of the article/ post. C. Call Azure Function App responsible for extracting tags from the note. D. Call Azure Function App responsible forconverting the object in json. E. Saves the json object in a file in Azure blob storage. F. Gets the updated configuration file. G. Call Azure Function App responsible for keeping the latest note date. H. Update the configuration with the latest date. I. Return an HTTP 200 code, so the parent Logic App knows the work is done. Call the API App responsible for building the final markdown file. Save the markdown file to an Azure blob storage that was returned at the previous step. Update the config final.
As an initial trigger, I decided to useOneDrive because it's available from any devices, from anywhere. I just need to drop the MyClippings.txt file in the folder, and the Logic App will start. Here, how I configured it in the editor:
MyClippings API App Kindle's notes and highlights are saved in a local file named My Clippings.txt . To be able to manipulate my notes, I needed a parser. Ed Ryan created the excellent [KindleClippings][KindleClippings], an open-source project available on github. In the actual project, I only wrapped that .Net Parser in an Azure API App. Wrapping the API in an API App will help me later to manage security, metrics, and it will simplify the connection in all other Azure solutions app.
I won't go into the detail on how to create an Azure API App, a lot of great documentation is available online. However, you will need at least the Azure .Net SDK 2.8.1 to create an API App project.
Swagger API metadata and UI are a must so don't forget to un-comment that section in the SwaggerConfig file.
I needed an array of notes taken after a specific date. All the heavy work is done in [KindleClippings][KindleClippings] library. The ArrayKindleClippingsAfter method gets the content of the My Clippings.txt file (previously saved in Azure blob storage), and pass it to th
本文系统（windows）相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术
本文标题：How I use Azure Logic App, API App and Function App in my life