LoginSignup
1
0

More than 3 years have passed since last update.

maven で Java Web アプリを Azure にデプロイする

Last updated at Posted at 2020-10-19

事前に用意しておく情報

image.png

以下の情報をコンソールなどで確認しておく

appName <-- 図の(1)
resourceGroup <-- 図の(2)
subscriptionId <-- 図の(3)

pom.xml

build 部分を以下のようにセットする。
region runtime などについてはサーバー側の環境にあわせて適宜変更する。

<build>
    <!-- https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-java -->
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <!--************************************************* -->
        <!-- Deploy to Tomcat in App Service Windows -->
        <!--************************************************* -->
        <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 -->
                <!-- SUBSCRIPTION_ID アプリをデプロイするサブスクリプションの一意の ID -->
                <subscriptionId>your_subscriptionId</subscriptionId>
                <!-- RESOURCEGROUP_NAME -->
                <resourceGroup>your_resourceGroup</resourceGroup>
                <!-- WEBAPP_NAME -->
                <appName>your_appName</appName>
                <!-- REGION -->
                <region>your_region</region>
                <!-- Java Runtime Stack for App Service on Windows -->
                <runtime>
                    <os>windows</os>
                    <javaVersion>1.8</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>
    </plugins>
</build>

ログイン

コンソールからログインしておく

az login

実行コマンド

pom.xml のディレクトリに移動して、以下のような感じでコマンドを実行する。
オプションはお好みで変更する。

mvn clean package azure-webapp:deploy -Dmaven.test.skip=true

参照

Quickstart: Create a Java app on Azure App Service - Azure App Service | Microsoft Docs
https://docs.microsoft.com/en-us/azure/app-service/quickstart-java?tabs=javase&pivots=platform-linux

以上です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0