Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Azure functions and container instances

In this talk we will go through using Microsoft Azure serverless and container technologies to automate a recurring process and reduce costs. In my work I was required to create a system which repetitively performed actions against web pages. I used selenium with the page object model as the model to interact with the pages, the code was executed using an Azure function which instantiated a browser in an Azure container Instance using a standard docker container. A transient container was used to avoid having to have one permanently installed on a VM, the container could be created only for the time it was needed. As serverless and Azure container instances have a usage charging model the costs were negligible compared to running a dedicated VM for the operation. In this talk I will talk briefly about:
*
Selenium and Page Object Model - how it aids re-usability of selenium code
*
Azure Functions - the developer experience
*
Azure container Instances - what they are and how setup and removal can be automated


But mostly how the above fits together to make a great developer experience and deliver a solution at minimal cost.

Demo:
*
Show Selenium webdriver working
*
Show how deployment process works
*
Show how the function looks on azure portal

  • Be the first to comment

  • Be the first to like this

Azure functions and container instances

  1. 1. Azure Functions and Container Instances By John Staveley 02/03/2019 https://uk.linkedin.com/in/johnstaveley/ @johnstaveley
  2. 2. Overview The Problem Selenium and Page Object Model Azure Functions – developer experience Docker SideCar pattern Azure Container Instances Polly for reliability
  3. 3. Who am I? John Staveley Mvc C# Azure Angular developer Organiser at Leeds Sharp, Leeds Data Science meetups Second migration into Azure from OnPrem
  4. 4. The Problem
  5. 5. Problem Requirements No Api Interact with the website – Navigate to the website – Logon – Navigate to target web page – Interact with the page Do this every day at 8pm without fail Try and avoid additional cost (No more Vms!) Framework for solving similar problems
  6. 6. Architectural Diagram of MajorDomo
  7. 7. Azure Functions Used to drive the actions WebJobs bad, Azure functions good Service plan vs Consumption charging Azure SDK in visual studio, uses .Net core 2.2 Precompiled function Triggers: Blob/Table/MongoDb storage, Queue, Timer Local Function and Storage Emulators for debug Deploy as web service
  8. 8. Why Selenium?
  9. 9. Selenium Used to drive a browser to interact with the website Supports Chrome, Firefox, IE, Edge etc Selenium Grid
  10. 10. Page Object Model Example 1 Pattern used to ensure a maintainable representation of the web pages
  11. 11. Page Object Model Example 2
  12. 12. Page Object Model Example 3
  13. 13. MajorDomo Demo See selenium interacting with the web pages Code explanation – Pages using Page Object Model – How Page object model was used
  14. 14. Docker and SideCar pattern Used to contain the browser Why? So I can test selenium grid will work locally Docker – like small Vms SideCar pattern Demo: MajorDomo running locally using docker
  15. 15. Azure Container Instances Used to contain the browser in Azure cloud ACI billing similar to VMs Docker image: selenium/standalone-chrome Startup/Shutdown using Azure libraries:
  16. 16. Azure Container Instances Demo: MajorDomo running container in Azure
  17. 17. Job done - Celebration!
  18. 18. Beer stabilisation
  19. 19. Polly Overview A reliability/resilience framework .Net/.Net Core Resilience Policies: • Retry - ‘Maybe it’s just a blip’ • Circuit Breaker - ‘That system is down / struggling’ • Timeout - ‘Don’t wait forever!’ • Bulkhead Isolation - ‘One fault shouldn’t sink the whole ship’ • Cache - ‘You’ve asked for that one before!’ • Fallback - ‘If all else fails … degrade gracefully’ Custom Policies - All policies can be combined, for multiple protection!
  20. 20. Polly Implementation Applying a reliability policy to MajorDomo:
  21. 21. Summary  Page Object Model for a maintainable model of web pages  Azure Precompiled Function in the cloud, same power as a container without the charging model  Azure Container Instances SideCar on demand  Polly for reliability and resilience  No VM, Pay as you go for azure function = No Cost  Slides on slideshare
  22. 22. Further Resources Selenium: https://app.pluralsight.com/library/courses/selenium/table-of- contents SideCar: https://www.oreilly.com/library/view/designing- distributed-systems/9781491983638/ch02.html Control Azure: https://github.com/Azure/azure-libraries-for- net Resilience: http://www.thepollyproject.org/ Docker images: https://hub.docker.com/
  23. 23. Any Questions? @johnstavele

×