Mimicking Heroku in Azure (1) – Create an App

Inspired by the simplicity of Heroku (See a comparative study between Azure and Heroku) I wrote a script to create everything a DevOps engineer needs in Azure to turn her / his code into apps. The script is so easy to use that any developers can run it in a command line.

I decided to write the script in Powershell, a scripting language I wasn’t too familiar with mainly because of PowershellForGitHub and Azure CLI, the two modules I can use to deliver the script really quickly. If you haven’t already installed them you could easily do that in Powershell:

Install-Module -Name PowerShellForGitHub -RequiredVersion 0.9.2
Install-Module -Name Az

Azure CLI is a powerful beast. We can automate pretty much everything in Azure using Azure CLI. PowershellForGitHub is another beast. I don’t think I need to explain what it does. Its name says it all :-).

In a logical order, the script creates

  • a new GitHub repository
  • a resource group in azure
  • a storage account (needed by the function app)
  • a function app and
  • an auto integration from the GitHub repository to function app

The table below summarises what and it does.

StepPowershell
Create GitHub RepoNew-GitHubRepository -RepositoryName $solutionName -AccessToken $token -AutoInit
Greate resource groupaz group create –location $region –name $solutionName
Create storage accountaz storage account create –name $storageName –location $region –resource-group $solutionName –sku Standard_LRS
Create function appaz functionapp create –name $functionAppName –storage-account $storageName –consumption-plan-location $region –resource-group $solutionName –runtime $Runtime –functions-version 2
Set up Github integrationaz functionapp deployment source config –branch master –name $functionAppName –repo-url $repoUrl –resource-group $solutionName

The full source code can be found in my GitHub: https://github.com/gaogang/windermere.

Worth noting that I created an auto integration from GitHub to function app in the last step. It means the changes will go live in the Function app automatically as soon as the code was checked in to the GitHub repo. How cool is that! The scripts gets out of the way where it matters, letting developers get on with what they do best – developing apps. En…have we seen it somewhere?

One thought on “Mimicking Heroku in Azure (1) – Create an App

Leave a comment