Of course Microsoft provides PowerShell functionality for their Azure cloud. This is pretty handy for several reasons.
For dev ops engineers using PowerShell is going to be faster than doing everything through the portal. PowerShell commands or scripts can be saved and reused easily. Eventually a toolkit of scripts and commands will help built out a solid dev ops infrastructure.
I’ve made use of some of these commands on occasion and found them highly valuable. I’m capturing them in this blog post so I have a quick reference for later.
For your standard commands (creating and manipulating resources) the overview here is good:
Get Started with Azure PowerShell cmdlets
I was setting up deployment slots for automated deployments. I found this article useful for creating, deleting and swapping deployment slots:
Using PowerShell to manage Azure Web App Deployment Slots
The create-react-app boilerplate is pretty good. It’s easy to get up and running in react with this package. It also provides useful tools for compiling the application into a production ready deployment.
Unfortunately this doesn’t fit perfectly into the Azure pipeline because Microsoft wants to build things on the server. The Azure platform is great and they’ve got good support for Node.js apps. But with the create-react-app in particular a few steps need to be completed in order to get this up and running properly. There’s documentation for this out there but I ran into a couple small snags along the way.
- In my case I’m doing “npm install” then “npm run build” and finally using the kudu sync to copy the compiled app to the wwwroot folder.
- Connect your Azure web app to your repository. Microsoft provides support for a variety of source control repos for this. It’s fairly straightforward and well documented at here
- Properly set the node version: I had some problems where my node and npm versions were incorrect. The version can be set in the package.json file or the application settings. This blog post explains both.
- I needed to install the create-react-app and babel packages globally to handle proper transpiling. Log into Kudu from the Azure portal and run the npm install -g commands
If all goes well doing a commit and push to remote will kick off a build on the azure web app. From there the custom script will kick in and build the app using the create-react-app build script. Finally it should copy this to the wwwroot folder leaving you with a clean website.
The nice thing with the custom script is I’ll be able to get my unit tests running in there making it all automatic. The deploy will fail if the tests fail leaving the environment untouched. I’m excited to get this working for a very simple and streamlined CI pipeline.
Another useful post by Jeff Wilcox describing setting up custom builds on an Azure web app
Continuous integration and Continuous deployment have once again changed for the better. Thanks to automation and Git hooks people are now doing deployments triggered directly off commits. This should drastically improve and speed up the overall CI and deployment paths.
I’m looking to implement this in Microsoft Azure which provides support for this
Continuous Deployment to Azure App Service
We are currently using a three environment configuration : CI, QA and Production with a staging slot meant for blue green deployments (ref: Martin Fowler).