Skip to the content.

Overview

This guide will step you through deploying a multi part application which demonstrates using the serverless compute of Azure Functions combined with the pre-built machine learning models of Azure Cognitive Services

With this application users can take photos using their phone, and have these photos analysed using computer vision. The results have a description of the image, people’s faces and also a set of tags. The demo app stores this information and the results are dynamically updated & displayed on a web page

The system consists of four main parts:

Architecture

diagram of architecture

Application Flow

  1. User loads camera web app on mobile device, via public URL of an Azure Function and takes photo
  2. Image is HTTP POSTed from camera app as Base64 string back to same Azure Function
  3. Azure Function decodes Base64 data and stores resulting image in Blob Storage, into photo-in container
  4. Second Azure Function is triggered on a new blob arriving at photo-in
  5. Function sends image to Cognitive Service API (REST call) and gets the JSON result
  6. Result is stored in photo-out container as a blob of JSON
  7. Static HTML/Javascript viewer ‘app’ polls photo-out for new blobs and updates page dynamically by fetching and reading the JSON. Details are shown as overlays on the images, such as the caption, tags and location of faces (using HTML5 Canvas API)

Example (Viewer Results Webapp)

demo

Deployment & Setup

The system requires a single Function App, storage account and Cognitive Services account. Using a consumption plan for the Function App means the costs for deploying the system are extremely small.

Deployment Script

A bash script deploy.sh for fully automated deployment is provided in the etc directory. This script will create everything and deploy all the Functions code. The default resource group is called **Demo.ServerlessVision** and deploys to North Europe, you can modify the script to change these defaults.

To run the script you will need the Azure CLI installed and configured and either run the script locally under WSL bash or simply use the Azure Cloud Shell

Manual Deployment

All these steps use the Azure Portal, and assume you already have an Azure subscription

1. Deploy a new Azure Function App using the Portal

2. Deploy Computer Vision Cognitive Service

3. Deploy & code to Functions & Configure

4. Setup Blob Storage

Usage

Viewer

If you want to host the viewer yourself in Azure, you can:

Design Notes

Being a demo app, certain design choices were made that cut corners in order to simplify things:

Change Log