Hot questions for Using Azure in azure web sites

Top Java Programmings / Azure / azure web sites


I have a web app I want to deploy on Azure. I followed the recommended instructions and deployed my app, and according to the Azure portal, everything is working just fine. However, when I visit the base URL my app should reside in, I see a page that says the following:

This Java based web application has been successfully created

There's nothing here yet, but Microsoft Azure makes it simple to publish content with GIT and FTP

Also when I visit any one of the endpoints (in this case, the /live endpoint) my app should have, I always see a page with the following message:


Problem accessing /live. Reason:

Not Found

Powered by Jetty:// 9.3.13.v20161014

When I look at the directories on the machine, everything seems to be in place. All my files are inside wwwroot. However, there's another directory named webapp under wwwroot and inside it is another directory named ROOT with two files: index.jsp and background.png. index.jsp is the page that shows the aforementioned "There's nothing here yet" message.

I'm using Bitbucket as my source control provider and I use jetty to run my web app. I'm also using javalite as the library to manage my server and different endpoints.


You'll need to put your stuff under wwwroot/webapps/ROOT/, or package as ROOT.war and drop that under wwwroot/webapps - it will get picked up and extracted automagically:

 └── webapps
        └── ROOT
            ├── about.jsp
            ├── Content
            │   ├── favicon.ico
            │   └── Site.css
            ├── Images
            │   ├── banner_coffee.png
            ├── index.jsp
            ├── META-INF
            │   ├── context.xml
            │   └── MANIFEST.MF
            ├── orderconfirmation.jsp
            ├── placeorder.jsp
            ├── Scripts
            │   ├── jquery-1.7.1.min.js
            └── WEB-INF
                ├── classes
                ├── lib
                └── web.xml


The main thing in the repo is a webapps folder with ROOT.war. The Tomcat/Jetty server in App Service will look inside this folder for web apps to host.

ROOT.war represents the default web app (at the site root). Any WAR file that's otherwise named represents a web app accessbile at ~/<WARfilename>.

Clearing things up
  • If your application sits in wwwroot/webapps/CoffeeShop/, then you'll access it at http://{site}

  • If your application sits in wwwroot/webapps/ROOT/, then you'll access it at http://{site}


I'm unable to get solr (6.3.0) to run on Azure websites. Specifically, it seems to be failing to detect the java version when doing the following

"D:\Program Files\Java\zulu8.17.0.3-jdk8.0.102-win_x64\bin\java" -version   2>&1  | findstr /i "version"  1>javavers
type javavers
set /p JAVAVEROUT=<javavers
@REM app_data\bin\solr.cmd start -f -V -p %HTTP_PLATFORM_PORT%

When run from the kudu console, this code runs without error and JAVAVEROUT is set as expected. However when run through the http platform handler, it fails on the last line as shown below

D:\home\site\wwwroot>"D:\Program Files\Java\zulu8.17.0.3-jdk8.0.102-win_x64\bin\java" -version      2>&1  | findstr /i "version"   1>javavers 

D:\home\site\wwwroot>type javavers 
openjdk version "1.8.0_102"

D:\home\site\wwwroot>set /p JAVAVEROUT= 0<javavers 
The handle could not be opened
during redirection of handle 0.

Any ideas why this fails in the platform handler, but works through the kudu console?

For reference, below is the web.config I'm using. (Start.cmd is the batch script at the begining of this post.)

<?xml version="1.0" encoding="UTF-8"?>
            <clear />
            <add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
        <httpPlatform processPath="d:\home\site\wwwroot\start.cmd" 


Still not sure what the root cause as to why solr.cmd fails in azure websites, but applying works around the issue as it removes the code that was causing solr.cmd to fail on startup


I have made a simple Java web app that runs on tomcat to explore azure environment.

I can read files (deployed via FTP to web app's root) from the web app, in a path denoted by HOME environment variable (azure's own env variable, resolves to D:\home):

String home = env.getProperty("HOME");

FileInputStream fis;
try {
    fis = new FileInputStream(home + "/" + "input.txt");


} catch (IOException e) {

But I can't write files to the same path:

String home = env.getProperty("HOME");
File file = new File(home + "/output.txt");

try {
    FileOutputStream fos = new FileOutputStream(file, true);


} catch (IOException e) { //ACCESS DENIED
    return "ERROR :" + e.getMessage();

above code fails with access denied error.

Can I write persistent files to some path in azure, or do I need a cloud native storage for this?


You cannot create files directly under %HOME%, but you can created directories. And in there, you can create files. It's only files at the very root that it disallowed.


I have a tomcat site running on Azure WebSite using the httpPlatform setting on the web.config file.

I have already created a file called "app_offline.htm" which is supposed to be shown when I stop and start my app, but it is never shown.

Is there a way in this scenario to provide a static page while the httpPlatform handler is loading?


The answer is absolutely not. While you did the stop or restart operation for your website in Azure portal, the IIS and/or its httpPlatform handler will really stop working, so there is not a HTTP service can help responsing any pages in your website.

When an Azure Website stoped, only one page will be responsed by Azure which is Error 403 - This web app is stopped. as below.

But it can not be customised, due to the reason #2 which has been answered by Azure Team member at the SO thread How to customise Azure Web App 403, 503 error pages?.

Per my experience, a workaround way is that to use a reverse proxy to check your website whether be alive and response your app_offline page, such as Nginx module ngx_http_upstream_check_module and to define error_page 403=301 /your-403-app_offline.html;.