Grafana azure webapp

Hi,

Is it possible to run grafana in azure webapp ?

I’m not sure. Have you tried?

Looks like Azure Web Apps support Go so Grafana might work:

EDIT: SEE MY LATER POST WITH THE COMPLETE PROCEDURE

I am new to Grafana but also would like to install as a web app. I have done the steps below which seems to work reasonably well but I am unable to get sqlite3 to compile i.e:

github.com/grafana/grafana/vendor/github.com/mattn/go-sqlite3
In file included from ./sqlite3-binding.h:35:0,
from vendor\github.com\mattn\go-sqlite3\backup.go:10:
D:/home/site/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/stdarg.h:1:25: fatal error: stdarg.h: No such file or directory
compilation terminated.

STEPS:

  • In Azure, create a new “Node JS Empty Web App”.

  • To set environment variables, using Debug Console (e.g. https://yoursite.scm.azurewebsites.net/DebugConsole), create a file in Azure Web App called applicationHost.xdt in D:\home\site with the following contents:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
  <system.webServer>  
    <runtime xdt:Transform="InsertIfMissing"> 
      <environmentVariables xdt:Transform="InsertIfMissing"> 
     <add name="GOPATH" value="D:\home\site\wwwroot" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />     
        <add name="GOROOT" value="D:\home\site\go" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />     
        <add name="PATH" value="%PATH%;D:\home\site\go\bin;D:\home\site\mingw64\bin" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />     
      </environmentVariables> 
    </runtime>  
  </system.webServer>  
</configuration> 
  • Get at least v1.8.1 of Go for 64 bit Windows. Extract the contents of the following file and copy files (drag & drop with Debug Console) to D:\home\site\go in Azure Web App:

https://storage.googleapis.com/golang/go1.8.3.windows-amd64.zip

  • Extract the contents of the following file and copy files (drag & drop with Debug Console) to the mingw64 directory under D:\home\site:

http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-core.zip/download

In the docs for building from source, it mentions that you will need GCC (TDM-GCC) to build sqlite on Windows.

Alright. Let me try and update you the status. Thank you.

  • In Azure, create a new “Web App”.

  • To set environment variables create a new file D:\home\site\applicationHost.xdt in Azure Web App with the following contents (e.g. by using Debug Console https://yoursite.scm.azurewebsites.net/DebugConsole):

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">    
  <system.webServer>    
    <runtime xdt:Transform="InsertIfMissing">   
      <environmentVariables xdt:Transform="InsertIfMissing">   
        <add name="GOPATH" value="D:\home\site\wwwroot" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />       
        <add name="GOROOT" value="D:\home\site\go" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />       
        <add name="PATH" value="D:\home\site\tdmgcc\bin;D:\home\site\go\bin;%PATH%" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />       
      </environmentVariables>   
    </runtime> 
  </system.webServer>    
</configuration>
  • Get at least v1.8.1 of Go for 64 bit Windows. Extract the contents of the following file and copy files (drag & drop with Debug Console) to D:\home\site (to create “go” folder underneath) in Azure Web App:

https://storage.googleapis.com/golang/go1.8.3.windows-amd64.zip

  • Create a new folder D:\home\site\tdmgcc and extract the contents of the following file (drag & drop with Debug Console) to it:

http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-core.zip/download

https://sourceforge.net/projects/tdm-gcc/files/GNU%20binutils/binutils-2.25-tdm64-1.zip/download

http://sourceforge.net/projects/tdm-gcc/files/MinGW-w64%20runtime/GCC%205%20series/mingw64runtime-v4-git20150618-gcc5-tdm64-1.zip/download

  • Restart web app.

  • Go to D:\home\site\wwwroot and run: go get github.com/grafana/grafana

  • Update the grunt dependency by editing D:\home\site\wwwroot\src\github.com\grafana\grafana\package.json as follows:

    “grunt”: “**>=**0.4.5”,

The above step is required to prevent grunt from failing due to bug that manifests itself in Azure environment, fixed in grunt v1.0.

  • Go to D:\home\site\wwwroot\src\github.com\grafana\grafana and run:

go run build.go setup
go run build.go build
npm install -g yarn
npm install node-sass
yarn install --pure-lockfile

  • Go to D:\home\site\wwwroot\src\github.com\grafana\grafana\node_modules\phantomjs-prebuilt and run: npm install

The above step is required to prevent grunt failing due to lack of location.js file.

  • Go to D:\home\site\wwwroot\src\github.com\grafana\grafana and run:

npm install -g grunt-cli
npm update grunt
grunt

  • Create a new file D:\home\site\wwwroot\grafana.bat with the following contents:

set GF_SERVER_HTTP_ADDR=127.0.0.1
set GF_SERVER_HTTP_PORT=%1
.\src\github.com\grafana\grafana\bin\grafana-server.exe -homepath=.\src\github.com\grafana\grafana

  • Create a new file D:\home\site\wwwroot\web.config with the following contents (remove the asterisks - had to add those to stop this form thinking it was markup) :
<?xml version="1.0" encoding="UTF-8"?>

<configuration >
<system.webServer>
<handlers>
<remove name=“httpplatformhandler” />
<add name=“httpplatformhandler” path="" verb="
" modules=“httpPlatformHandler” resourceType=“Unspecified”/>
<
/handlers>

<environmentVariables>
<
/environmentVariables>
<
/httpPlatform>
<
/system.webServer>
<*/configuration>

1 Like

Thanks for the great step by step doku.
But I have no success to bring it on the street.
I run into an server 500 error.

I have some questions.
Do you create a WebApp or a Node JS Empty Web App?

in the web.config are you sure that the path is “” without * ?

I do also a restart from webapp, try to run the grafana.bat via cloudshell and so :frowning:
is it possible that you have a double check on the doku
Thank you

You will be able to run grafana as azure web app using linux app service plan and container.

Below is my reference implementation of the same. You can customize the ARM template accoring to your need.