In this post, i am going to deploy simple GO in Azure using VS Code extension Docker . These are my steps.
First, i need :
- Install Dockerin my machine and Docker Extension for VS Code.
- Using Azure account to create Container Registry.
My helpful screenshot
Then, i create simple GO program in GOPATH (main.go and Dockerfile):
In main.go:

  
package main

import (
	"fmt"
	"log"
	"net/http"
)

func main() {
	http.HandleFunc("/", handler)
	log.Fatal(http.ListenAndServe(":8080", nil))
}

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}

Nothing special here. In Dockerfile:

# Dockerfile References: https://docs.docker.com/engine/reference/builder/

# Start from golang v1.11 base image
FROM golang:1.11

# Add Maintainer Info
LABEL maintainer="Bao Dinh <baodinhthe@gmail.com>"

# Set the Current Working Directory inside the container
WORKDIR $GOPATH/src/example/docker // this is where i place my go solution

# Copy everything from the current directory to the PWD(Present Working Directory) inside the container
COPY . .

# Download all the dependencies
# https://stackoverflow.com/questions/28031603/what-do-three-dots-mean-in-go-command-line-invocations
RUN go get -d -v ./...

# Install the package
RUN go install -v ./...

# This container exposes port 8080 to the outside world
EXPOSE 8080

# Run the executable
CMD ["myapi"]

More information about the config, it can be referenced the above links.
Now, i am going to using Docker extension to build and push image into Azure Container Registry. Inside the solution, using command docker login to login to server:

docker login myapi.azurecr.io

After that, use Command + Shift + P, select Docker Images: Build Image...: My helpful screenshot Here i input : myapi.azurecr.io/api:latest.You have to add the repository name api in the server path. If not, when you push the image it will display the err.

denied: requested access to the resource is denied

After done, you will see the image display in docker tag like this: My helpful screenshot At this point, image is ready to push in Azure Container Registry. Use Command + Shift + P, select Docker Images: Push -> select the image you have built. Done. To make sure it is complete. Go to Azure Container Registry it will be there: My helpful screenshot