Azure App Services

Spring REST API App Deployment in Azure App Services 

Within Azure App Services , Spring REST API application is deployed slightly different than a simple J2EE web application.


A Sprint REST application can simply run inside JRE and don't need a container like tomcat. If you are planning to use azure-webapp-maven-plugin , it will need to be configured slightly differently. For a Spring REST API  application  , the plugin  configuration will look like following.

    <plugin>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-webapp-maven-plugin</artifactId>
        <version>1.7.0</version>
        <configuration>
            <!-- Specify v2 schema -->
            <schemaVersion>v2</schemaVersion>
            <!-- App information -->
            <subscriptionId>[azure subscription id]</subscriptionId>
            <resourceGroup>[ existing or new resource group ] </resourceGroup>
            <appName>uiapp</appName>
            <region>Central US</region>
            <!-- Java Runtime Stack for App Service on Linux-->
            <runtime>
                <os>linux</os>
                <javaVersion>jre8</javaVersion>
                <webContainer>jre8</webContainer>            
            </runtime>
        <appSettings>
          <property>
               <name>JAVA_OPTS</name>
               <value>-Dserver.port=80</value>
          </property>
      </appSettings>
         
            <deployment>
                <resources>
                    <resource>
                        <directory>${project.basedir}/target</directory>
                        <includes>
                            <include>*.jar</include>
                        </includes>
                    </resource>
                </resources>
            </deployment>
        </configuration>
    </plugin>

for above configuration to work , the <packaging> element should be set to jar.   For a J2EE Web Application , the plugin configuration will change in following manner.

    <plugin>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-webapp-maven-plugin</artifactId>
        <version>1.7.0</version>
        <configuration>
            <!-- Specify v2 schema -->
            <schemaVersion>v2</schemaVersion>
            <!-- App information -->
            <subscriptionId>[azure subscription id]</subscriptionId>
            <resourceGroup>[ existing or new resource group ] </resourceGroup>
            <appName>uiapp</appName>
            <region>Central US</region>

            <!-- Java Runtime Stack for App Service on Linux-->

            <runtime>
                <os>linux</os>
                <javaVersion>jre8</javaVersion>
                <webContainer>tomcat 9.0</webContainer>            
            </runtime>

            <deployment>
                <resources>
                    <resource>
                        <directory>${project.basedir}/target</directory>
                        <includes>
                            <include>*.war</include>
                        </includes>
                    </resource>
                </resources>
            </deployment>
        </configuration>
    </plugin>

of course the <packaging>  should be set to war also.   

Unsupported values for linux runtime, please refer https://aka.ms/maven_webapp_runtime more information

There are also some specific differences in values you specify for <javaVersion> and <webContainer>  depending upon <os> being linux vs. windows.   You can see these differences at this link. 


like when os is windows the javaVersion should be changed to 1.8 and not jre8 or you will get  following error. Same goes for webContainer. 

Requested feature is not available in resource group myfirst. Please try using a different resource group or create a new one

This happened when I tried to reuse an existing resource group . If you have used a resource group for one purpose ( like windows servers )  and tried to use for something else ( linux servers )  it appears to throw that error.  When you create new group it goes away.








Comments

Popular posts from this blog

SQL

Analytics

HIVE