Skip to content

radon-h2020/demo-tosca-blueprint-azure-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xOpera deploy of simple thumbnail generator to Azure with Ansible

Table of Contents

Purpose

The repository implements image resize functionality deployment with xOpera for Azure Platform.

Functionality

The main functionality of image-resize is to create thumbnails from the source image. Source image must be uploaded into source bucket and then three thumbnails will be created and saved to another bucket.

Quick test and deploy

If you want to test this solution immediately run the following commands:

📝 I you face any problems consider reading the whole manual!

# install Azure CLI and try to login in your account
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az login

# install prerequisites
cd azure
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install ansible
pip install opera

# setup azure function tools
wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install azure-functions-core-tools
rm packages-microsoft-prod.deb

# run xOpera service (make sure to setup the env vars in yml file)
opera deploy -i inputs.yml resize_service_opera_v1_3.yml

Deployment instructions

The next part explains the deployment of this solution in detail.

Prerequisites

This topic explains prerequisites to run xOpera deploy via Azure. If you want to test it immediately go to quick test

To be able to run these roles you should use virtual environment, install the latest Ansible version.

python3 -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install ansible

Next, you can install opera orchestrator to your virtual environment from here. Basically you need to install it using pip install opera.

You should also install and sign in with Azure CLI using az login command. This is important because user gets authenticated via cli right now.

The next thing is to set up the Azure function tools using the commands below:

wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install azure-functions-core-tools
rm packages-microsoft-prod.deb

Roles and deployment

There are 3 playbooks separated into folders. Usage is explained in the table below:

Role Purpose
container-create Creates storage account and necessary container on specified Azure storage account
function-deploy Creates FunctionApp and deploys a new function to Azure portal using Azure CLI
container-notification Creates an event subscription trigger for function

Container deploy

This part is used to create two containers (buckets) - original and resized on Azure Storage Account. Original container is used to upload images and then resized images get stored into resized container. This part also includes creating a whole new storage account.

Function deploy

Azure functions first need Azure Function App. Here we create a new Function App and then we deploy our Azure function by calling funct functionapp publish which deploys all functions stored in functionApp folder (these are visible in playbooks/function-deploy/functions). Currently there is a function called image-resize-function which is used for creating thumbnails.

Container notification

This part sets container notification for incoming container so that when a new image is uploaded that would trigger specified function from the functionApp. So here we use Azure EventGrid by creating event subscription.

Setting inputs

You can modify values of variables stored in inputs.yml to set the suitable parameters like IPs, auth params, container names, paths etc. Currently the following values can be modified:

Inout (variable) Purpose Example
host_ip IP address of your target machine for execution localhost
location Location for the created resources westeurope
resource_group_name Name of the resource group Resource-Group
storage_account_name The name of the new storage account mystorageaccount
container_in_name The name of the incoming Azure blob storage container original
container_out_name The name of the container with results resized
function_app_name Name of the new Function App MyFunctionApp
function_name Name of the new Azure function - should be the same as folder name of the function image-resize-function
event_subscription_name Name of event subscription trigger that will be created thumbnail-function-trigger

The file with inputs is later passed to xOpera at the beginning of the orchestration.

Running with xOpera

You can run xOpera resize service with opera deploy -i inputs.yml resize_service_opera_v1_3.yml

About

An example of deploying thumbnail generator on Azure Function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages