Introducing Buffalo-Azure

Martin Strobel
Jul 12, 2018 · 3 min read

The word ‘buffalo’ means a lot of things

For Go developers, Buffalo is a Ruby-on-Rails style rapid web development framework. e.g. There’s a lot of boiler plate code associated with writing a web application, and while it’s a super useful and fun exercise to run through writing all of that once, this will get your project started a lot faster. Anybody who’s written a console application in Go that takes flags knows that using the `flags` standard library package is fine, and a lot better than parsing the os.Args slice yourself. However, anybody who’s tried spf13’s Cobra knows it’s a lot better and a lot faster to get started with. Buffalo offers the same improvement over the standard library’s `http` package that Cobra provides over the `flag` package.

Stairway to Heaven

While Buffalo without plugins offers a tremendous amount of value for generating a website and developing on it locally (and fast) you still need a way to get it into the cloud. Depending on your experience level, setting up a website can be a relatively heavy lift. If you’re thinking of creating your own VMs, networking, and load balancing infrastructure, it could be quite time consuming. There are a lot of benefits to leaning on your cloud provider to handle the infrastructure for you.

Running a managed Kubernetes cluseter (i.e. Microsoft’s AKS, Amazon’s EKS, Google’s GKE, etc.) is a pretty awesome and flexible way to get your website running. You can run a whole host of containerized microservices and amortize the performance hit across a lot nodes. However, if you are running a self-contained website, using a Kubernetes cluster is a little excessive.

Another option is to take advantage of an Azure product called “App Services” or “Azure Web Applications”. This service is a tremendous fit for running a single Buffalo application because they are specifically targeted at running monolithic web applications with all of the trimmings you’d expect: auto-scaling, loading balancing, CPU usage metrics, and response time metrics to name a few.

That’s where Buffalo-Azure comes in.

Using the command `buffalo azure provision`, an Azure App Service will be created to host your site. In addition, Buffalo-Azure reflects over the site defined in your working directory to provision a managed instance of the database you’re using (if it’s Postgres or MySQL). Once you’ve provisioned once, it will add two files to your project, `azuredeploy.json` and `azuredeploy.parameters.json`. These will allow you to use Buffalo-Azure, the Azure CLI 2.0 or the Azure Portal to deploy your site again with all of the same settings.

Stop polling, start reacting

Azure Event Grid is an HTTP based messaging service. If you have microservices talking to each other directly, restructuring your application to take advantage of Event Grid Topics for message distribution can dramatically simplify the retry logic in your code. Not to mention, introducing an intermediary can reduce how tightly coupled your services are by allowing services to declare what they’re interested in, instead of putting the onus on the producer of the event.

The Azure SDK for Go already has several packages that make it easier for you to publish and deserialize Event Grid events. That’s great, but there can be a lot of work that goes into setting up an endpoint that receives and dispatches on a string in your payload. Again, this is an opportunity for the Buffalo-Azure plugin to help you out. Run the command `buffalo generate eventgrid`, and a new Buffalo action will be created in your application that already knows how to dispatch and deserialize your Event Grid Events, even if they’re custom types that you defined.

Bottom Line

Rapid web development has arrived in Go, and there’s no better time to build and play with your web application. No matter who you are, and how much web-dev experience you have, there’s nothing stopping you from getting your website hosted in Microsoft Azure right now. Go try Buffalo-Azure

Azure Developers

Technical articles for developers building, automating and deploying cloud applications on Azure with a focus on DevOps written and curated by Azure engineers.

Martin Strobel

Written by

Software Developer @ Microsoft

Azure Developers

Technical articles for developers building, automating and deploying cloud applications on Azure with a focus on DevOps written and curated by Azure engineers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade