Azure App Service now includes experimental support for running Go with web apps. If you would like to run Go for your web app on Azure App Service and share feedback, see this article on how you can get started. Feedback can be submitted via our MSDN forum.
Source control deployment with your Azure subscription
The Go binary is installed with the Azure App Service platform. Versions currently supported are 64bit Go 1.4.2 and Go 1.5.1. The following are prerequisites for source control deployment:
· A valid Azure subscription. If you don`t already have a subscription, sign-up for a free trial.
· Source control deployment enabled for local Git. Find detailed instructions here.
Running a sample Go web app is just three simple steps away.
1) Clone content from public GitHub repo to a local Git repo.
2) Get source control URL from your web app and update local repo to point to web app repo.
For this example the command to point local repo to your web app repo is:
git remote set-url origin https://$kudutry@ kudutry.scm.azurewebsites.net/kudutry.git
3) Push content from local repo to remote Azure repo.
Go web app configuration
There are a few aspects of web app configuration for Go web apps running on Azure App Service to be aware of.
1) Version selection
At the time of writing this blog post the Azure App Service platform supports Go 1.5.1 as the default version and Go 1.4.2 as a selectable version. To select a non-default version, define an app setting for your web app with key “GOROOT” and value: “D:Program Filesgo1.4.2.”
2) Build artifacts
The App Service deployment script creates a temp Go workspace and places the source code under “$(GOPATH)srcazureapp.” The final build artifact is always an “azureapp.exe” with other non-*.go file. A simple way to inspect these files would be using the Kudu console https://{sitename}.scm.azurewebsites.net/DebugConsole. From the Kudu console navigate to wwwroot for the web app.
You can create a web.config file as part of the source code before deployment or Azure App Service will generate a web.config file at deployment time in order to enable the HttpPlatformHandler IIS module to run your Go web app. Learn more about the HttpPlatformHandler here.
If you include a web.config file with your content make sure the configuration elements described in this section are available:
3) Port number
Go application needs to read the port number from an environment variable: “HTTP_PLATFORM_PORT”. At runtime, HttpPlatformHandler will generate a random port number for the process running the Go web app.
4) Content layout
The content layout requirement for Azure App Service is to place your main Go package at the root of your project. This layout enables the App Service build system to resolve dependencies and build the right executable solution.
Trial deployment without an Azure subscription
Try a Go sample even without an Azure subscription via the Azure App Service trial page.
Click “Create” for the Go sample and sign-in with a supported social account. The Go web app will be created for you, then click on the URL to experience the sample app and select options to manage the app from the set of options displayed.
The sample Go web app features a home page leveraging the “net/http” Go module, and displays the log of visits to the “Try Gin” and “Try Martini” links which showcase the Gin and Martini web frameworks.