未加星标

How I use Azure Logic App, API App and Function App in my life

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

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.


How I use Azure Logic App, API App and Function App in my life

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.


How I use Azure Logic App, API App and Function App in my life

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.


How I use Azure Logic App, API App and Function App in my life
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).


How I use Azure Logic App, API App and Function App in my life

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:


How I use Azure Logic App, API App and Function App in my life
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.


How I use Azure Logic App, API App and Function App in my life

Swagger API metadata and UI are a must so don't forget to un-comment that section in the SwaggerConfig file.


How I use Azure Logic App, API App and Function App in my life
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)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: Kindle.NetRuby
分页:12
转载请注明
本文标题:How I use Azure Logic App, API App and Function App in my life
本站链接:http://www.codesec.net/view/480750.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(38)