A guide to quickly setup an Azure function to draw chemical structures from SMILES strings.
This uses the docker image provided by the CDK project to generate image files of a molecular structure based on a SMILES string. Not only is this potentially useful as a component in a larger application, but it also demonstrates using a docker image within an Azure Function. Running this as a function allows it to be run from just pennies a day, but could also be quickly scaled for more demanding solutions.
PowerShell deployment
This should work from a local PowerShell session after using
The script builds out an Azure Function within a new App Service Plan- plus an associated Storage Account and Application Insights. The Azure function pulls the Docker Image from the Docker Hub.
#Parameters
#Set these variables
$appName= "cdkdepict01" #Short Name for Application used in Naming Convention
$tags= @{"tag-service"="SMILES"} #Tags to apply to the Resource Group and Resources.
$subscriptionName= "Pay-As-You-Go" #The Subscription to deploy to
$location= "Central US" #The Azure Region to deploy to.
#Determine the resource names using a naming convention
$resourceGroupName= $AppName+"-rsg"
$functionName= $AppName+"-fun"
$appServicePlanName = $AppName+"-asp"
$storageAccountName = $AppName+"sto"
#Switch to the correct subscription
$context = Set-AzContext -SubscriptionName $subscriptionName
"-- Creating Resource Group "+$resourceGroupName +" in " + $location
$resourceGroup = New-AzResourceGroup -Location $location -Name $resourceGroupName -tag $Tags
"-- Creating App Service Plan "+$appServicePlanName
$appServicePlan = New-AzAppServicePlan -Location $location -Tag $tags -ResourceGroupName $resourceGroupName `
-Name $appServicePlanName -Tier "Basic" -WorkerSize "Small" -NumberofWorkers 1 -Linux
"-- Creating Storage Account "+$storageAccountName
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName `
-SkuName "Standard_LRS" -Location $location -Kind Storage -Tag $tags
"-- Creating Function "+$functionName+" from Docker Hub image"
$newFunction = New-AzFunctionApp -Name $functionName -ResourceGroupName $resourceGroupName -DockerImageName "simolecule/cdkdepict" `
-PlanName $appServicePlanName -StorageAccountName $storageAccountName -Tag $tags
"-- Finished"
Once executed the resulting web page, with examples, should be available at