Azure App Service not working

Hello,

I have been trying to deploy a Go app to Azure for several days without success. So I created a test one:

test-go-api.azurewebsites.net/test

Release Pipeline config:

  • App Service for Go
  • Agent Pool Ubuntu

Code

func main() {
router := mux.NewRouter()
router.HandleFunc("/test", GetTest).Methods(“GET”)
log.Fatal(http.ListenAndServe(":8008", router))
}

func GetTest(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(“Hello”)
}

Build Pipeline

# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

# trigger:
# - master

pool:
vmImage: ‘Ubuntu-16.04’

variables:
GOBIN: ‘$(GOPATH)/bin’ # Go binaries path
GOROOT: ‘/usr/local/go1.11’ # Go installation path
GOPATH: ‘$(system.defaultWorkingDirectory)/gopath’ # Go workspace path
modulePath: ‘$(GOPATH)/src/github.com/$(build.repository.name)’ # Path to the module’s code

steps:

  • script: |
    mkdir -p ‘$(GOBIN)’
    mkdir -p ‘$(GOPATH)/pkg’
    mkdir -p ‘$(modulePath)’
    shopt -s extglob
    shopt -s dotglob
    mv !(gopath) ‘$(modulePath)’
    echo ‘##vso[task.prependpath]$(GOBIN)’
    echo ‘##vso[task.prependpath]$(GOROOT)/bin’
    displayName: ‘Set up the Go workspace’

  • script: |
    go version
    go get -v -t -d ./…
    if [ -f Gopkg.toml ]; then
    curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
    dep ensure
    fi
    go build -v .
    workingDirectory: ‘$(modulePath)’
    displayName: ‘Get dependencies, then build’

  • task: CopyFiles@2
    inputs:
    SourceFolder: ‘$(modulePath)’
    Contents: |
    web.config
    test
    TargetFolder: ‘$(Build.ArtifactStagingDirectory)’

  • task: PublishBuildArtifacts@1
    inputs:
    PathtoPublish: ‘$(Build.ArtifactStagingDirectory)’

I see the 2 files with ls from Azure Console AppService, but the URLs returns ‘The specified CGI application encountered an error and the server terminated the process.’ and nothing respectively.

Any help please?

Thanks.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.