Clarionlive Webinar#400 - Clarion Cloud Functions
“Serverless Computing” doesn’t really mean there’s no server. Serverless means there’s no server you need to worry about. That might sound like PaaS, but it’s higher level that than."
– SCOTT HANSELMAN
First: DEMO LINK!
Let’s run some Clarion Code in the cloud!
Notice the Clarion code in the “expression” parameter of this URL?
Go on, click on it and see!
HOW THE MAGIC?!
- What is an Azure Function?
- How does this know about Clarion?
- Where to from here?
- Clarion console app
- Command() in and StandardOutput back.
- Github project
- .NET Process
Obvious reason is cost. Instead of having a dedicated server to run a Clarion web service, just have a function and pay per use.
e.g. $0.000016/GB-s (Gigabyte Seconds) and $0.20 per million executions
$20 per month for a dedicated server?
Tweak your individual functions as needed, deploy is stupid simple, etc.
Mixture of possile programming languages with all the rich libraries that they provide.
Combined with the Clarion code we all know and love!
Azure ecosystem and more
Sure you can now get easy access to the full Azure eco system but yuo also can combine that with all the API goodness out there!
If you really wanted to take this further, I wonder if you could create a function that calls ClarionCL to compile some code and execute the result… might be fun though in that case you may want to have a dedicated server as the resource usage might spike.
Also, remember that this is just one possible binding for a function, HttpTrigger. There are others like WebHook, BlobTrigger, EventHubTrigger, WebHook, TimerTrigger, etc!
How about a simple function that executes your Clarion code in the cloud on a specified schedule?
Heck, it doesn’t even need to be C# code. You can have a BAT file that runs on an HttpTrigger
Perhaps it could be a convenient way to test or prototype something without having to worry about server infrastructure?
Webinar Project - Clarion API
Primary Goal: API Endpoint for Evaluate()
- Deploying additional Clarion code that can be used in Evaluate, via Bind() and/or specific “routes” that can be triggered from functions.
- Looking at other Azure Function bindings e.g. TimerTrigger, BlobTrigger, etc and how these could be useful with Clarion code
- Developing functions locally or in the Web IDE
- Deploying changes, VSTS/GitHub integration and CI
- Static file, SPA (Single Page App) that can consume the API.
- Performance testing
- Instrumenting with Application Insights
Some good links
- Lots of good responses from the azure apps team in the comments of the Hanselman Serverless Computing blog post.
- Good detail on the App Sandbox.
- Checkout this comment on hosting static files via functions.
- This could also be handy.
Develop locally or online?
- faster change/test cycle
- better once production is implemented, test locally before deploy
- good fun to see the deploy/CI process
- More direct
- Kinda fun
My initial local dev testing:
Ok, so the https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local seems to be a bit special but it just might work well enough for starters.
npm i -g azure-functions-cli
cd c:\Dev\Projects mkdir ClarionApi cd ClarionApi
Init func app:
func ClarionApi init
func function create -l C# -n evaluate -t HttpTrigger
Run Function (server):
func function run evaluate
Now, develop and test.
Commit/Push to VC
Let CI take it from there to deploy.
After talking with Arnold and John here were some other ideas:
Good talk, thanks guys.
So what I will look at doing, as well as the above, is:
- Find a way to be transparent about costs and what this can save
- Why use functions at all when I have to run a database server anyway?
- How much does Azure cost anyway?
- How can I keep track of costs in the cloud?
- How to access a data/database(s) from azure functions?
- Demo - function accesses a database on premises
- Graphs are good, dashboards even better!
- Function that pulls something from the Clarionhub API?
- Need to engage people on “how can this help me”?
- Analytics and how they can help to know what users want before the users do!
- If there is any “hard stuff” that I am going to gloss over here then make sure to mention I am available for consulting work if anyone wants help!
Edit: More ideas
- A function might be a super easy way to do a “license check”.
- Monitor a location for file changes, e.g. someone uploads a TPS file, and then a function “does something” with that file.
- Serverless OCR Service
- Monitor a location containing images and make thumbnails?
General Use Cases for Functions
(ideas from http://blog.contino.io/5-killer-use-cases-for-aws-lambda )
- Operating serverless websites - host static content on a CDN, api is functions
- Automated backups and everyday tasks - e.g. preparing reports in the background
- Watermarking images/reports in the background
- alarms, notifications
- IoT endpoint?
- Async batch processing. Client makes a request to a function that triggers a bunch of different actions.
- Nice post and good look at pricing - https://www.troyhunt.com/azure-functions-in-practice
I will update the original topic here as I develop the presentation. When we are ready to go I will move the topic to a public location for people to reference.