A few weeks ago I wrote a GoLang web app and wanted to find a good place to host it. Given I work with the team that builds Azure Websites, it seemed only fitting to host it in Azure Websites. Turns out, it works great! However, there aren’t any resources available that walk you through the steps. Consequently, I wrote the following tutorial.
(Incidentally, if you want to start to use Go Language and run Windows you’ll want to review my post Easy Go Programming Setup for Windows.)
Is this the absolutely authority on running Go Language in Azure Websites? No, but it works. I plan to publish a few more articles on more complex scenarios in the future.
4 Simple Steps
Create your Azure Website in the Azure Portal. Without a doubt the easiest step.
Download and unzip the Go executables. In the Azure Portal select your website blade and scroll down until you see the
In the console to the right, type the following commands:
curl -O https://storage.googleapis.com/golang/go1.4.windows-386.zip
You should see the following:
Be patient with the console as these two operations may take a few moments. It’s purposefully simple.
Note: I’m not sure why it returns
Bad Requestbut so far it doesn’t seem to cause any issues.
server.gofile in the
wwwrootfolder. This is a super simple Go file which will reply for any resource on the website.
As a convenience, feel free to use `curl` and download this directly from [my public gist](https://gist.github.com/wadewegner/52a925a7b1607a48d796). Otherwise, you should consider using Kudu or git to get your files into your Azure Website. `curl -L http://bit.ly/1xtYNRU --output server.go` Once downloaded, type `type server.go` to confirm you grabbed everything correctly.
- Create a
Web.Configfile in the
wwwrootfolder. We will use the
httpPlatformHandlersimpilar to running Tomcat in Azure Websites.
Again, you can use the following curl command to download the `Web.Config` file: `curl -L http://bit.ly/1wx4JFY --output Web.Config`
That is it! You can now browse to your Azure Website and see it in action.
For now, try it out here: http://golang.azurewebsites.net/hello
Is there more we can do here? Absolutely, and I intend to cover some additional topics in future posts. However, for now, it feels good knowing that we can push our Go Language code to Azure Websites.
Special thanks to Ranjith Mukkai Ramachandra for his help and answering all my questions quickly and thoroughly!