How much effort does it take to run a Piranha Nano application as an Azure Function using a Custom Handler?
Follow the steps mentioned below.
To deploy the Piranha Nano application we need an Azure Function App. So we are are going to create the necessary Azure resources first. Please execute the script below. Please make sure to change the values where appropriate.
#!/bin/bash resourceGroup=myResourceGroup region=westus2 premiumplan=myPremiumPlan # Function app and storage account names must be unique. storageName=mystorageaccount$RANDOM functionAppName=myappsvcpfunc$RANDOM # Create a Resource group az group create \ --name $resourceGroup \ --location $region # Create a Storage account az storage account create \ --name $storageName \ --location $region \ --resource-group $resourceGroup \ --sku Standard_LRS # Create a Premium plan az functionapp plan create \ --name $premiumplan \ --resource-group $resourceGroup \ --location $region \ --is-linux true \ --sku EP1 # Create a Function app az functionapp create \ --name $functionAppName \ --storage-account $storageName \ --plan $$premiumplan \ --resource-group $resourceGroup \ --functions-version 3
This example uses the Piranha CLI so we need to download it and install it. Go to https://github.com/piranhacloud/piranha/releases/latest and download the zip / tar.gz bundle for your OS. Unzip it in a directory of your choice and add the bin directory to your PATH.
The Piranha CLI is capable of generating the project skeleton that you can use to develop a Piranha Nano application. In an empty directory execute the command below:
pi nano generate
The skeleton that was generated also generated the Dockerfile that is used by the Piranha CLI to build the azure.zip file needed for cloud deployment. To build the application execute the following command in the base directory of the generated project:
pi nano cloud build
To deploy the application use the command line below. Make sure you substitute the <application-name> with the application name you used to create the Azure Function App (which is the value of functionAppName in the bash script).
pi nano cloud deploy --name <application-name>
Open your browser to https://<application-name>.azurewebsites.net/api/helloworld and you will see 'Hello World'.
As you can see it is easy to get up and running with Piranha Nano on Azure Functions.
Posted December 13th, 2020