복붙노트

[SPRING] Azure App 서비스에 스프링 부트 jar 배포

SPRING

Azure App 서비스에 스프링 부트 jar 배포

Azure 앱 서비스에서 작동하도록 Spring Boot API를 가져 오는 데 문제가 있습니다. Microsoft 가이드 (https://docs.microsoft.com/en-us/java/azure/spring-framework/deploy-spring-boot-java-web-app-on-azure)를 따랐지만 행운이 없었습니다. 멀리.

응용 프로그램이 시작됩니다 (로그 파일에서 응용 프로그램 부팅을 볼 수 있음). 그러나 응용 프로그램 서비스 URL에 대한 HTTP 요청은 항상 시간 초과로 끝납니다.

필자는 Azure 앱 서비스가 포트 80 또는 8080에서 실행되는 임베디드 tomcat 서버를 선택하지만 그뿐 아니라 운이 없었 음을 읽었습니다.

응용 프로그램은 www 루트에 배포되고 적절한 web.config도 배포됩니다.

응용 프로그램 서버 (Tomcat 및 Jetty, 응용 프로그램에 서버가 포함되어 있기 때문에 필요하지 않음)를 사용하거나 사용하지 않고 응용 프로그램 서비스를 실행하려고 시도했지만 두 방법 모두 실패했습니다.

다른 구성 부분이 누락 되었습니까? 또는 이것이 하늘빛에서 사용하고있는 계획의 유형과 관련 될 수 있습니까? 자원에 문제가있을 수 있습니까?

어떤 포인터?

고마워,

버트

해결법

  1. ==============================

    1.푸른 하늘에 스프링 부트 응용 프로그램을 배포하려면 봄과 푸른 지역 사회가 제공 한 다음 단계를 따르십시오.

    푸른 하늘에 스프링 부트 응용 프로그램을 배포하려면 봄과 푸른 지역 사회가 제공 한 다음 단계를 따르십시오.

    1) POM 파일이있는 응용 프로그램 폴더로 이동하여 실행하십시오.

    다음 플러그인이 pom 파일에 있어야합니다.

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>org.springframework</groupId>
        <artifactId>gs-spring-boot</artifactId>
        <version>0.1.0</version>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.6.RELEASE</version>
        </parent>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <!-- tag::actuator[] -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <!-- end::actuator[] -->
            <!-- tag::tests[] -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
            <!-- end::tests[] -->
        </dependencies>
    
        <properties>
            <java.version>1.8</java.version>
            <maven.build.timestamp.format>yyyyMMddHHmmssSSS</maven.build.timestamp.format>
        </properties>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.microsoft.azure</groupId>
                    <artifactId>azure-webapp-maven-plugin</artifactId>
                    <version>0.1.5</version>
                    <configuration>
                        <authentication>
                            <serverId>azure-auth</serverId>
                        </authentication>
                        <resourceGroup>maven-plugin</resourceGroup>
                        <appName>maven-web-app-${maven.build.timestamp}</appName>
                        <region>westus</region>
                        <javaVersion>1.8</javaVersion>
                        <deploymentType>ftp</deploymentType>
                        <stopAppDuringDeployment>true</stopAppDuringDeployment>
                        <resources>
                            <resource>
                                <directory>${project.basedir}/target</directory>
                                <targetPath>/</targetPath>
                                <includes>
                                    <include>*.jar</include>
                                </includes>
                            </resource>
                            <resource>
                                <directory>${project.basedir}</directory>
                                <targetPath>/</targetPath>
                                <includes>
                                    <include>web.config</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>
    

    이제 이름이 "web.config"인 루트에 파일을 만들고 web.comfig에 jar 파일을 추가하십시오.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <handlers>
                <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
            </handlers>
            <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
                          arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\azure-rest-example-app-0.1.0.jar&quot;">
            </httpPlatform>
        </system.webServer>
    </configuration>
    

    이제 azure CLI를 열고 다음 명령을 실행하십시오.

    앱이 로컬에서 제대로 작동하는지 확인합니다.

    이제 ID와 연결된 계정이 여러 개인 경우 다음 명령을 사용하십시오.

    이제 "Microsoft Azure의 서비스 주체"를 만들어야합니다.

    1) 터미널 창을 엽니 다.

    2) az login을 입력하여 Azure CLI로 Azure 계정에 로그인하십시오

    3) az 광고 sp create-for-rbac --name "vaquarkhan"--password "yourpassword"(vaquarkhan은 사용자 이름이고 yourpassword는 서비스 사용자의 암호 임)를 입력하여 Azure 서비스 사용자를 작성하십시오.

    참고 : 오류가 발생하면 설정을 변경해야합니다. ---> 여기

    성공하면

    Azure는 다음과 같은 JSON 응답을 인쇄해야합니다.

    {
       "appId": "XXX-XXXX-XXX-XXX-XXXX",
       "displayName": "vaquarkhan",
       "name": "http://vaquarkhan",
       "password": "yourpassword",
       "tenant": "YYY-YYYY-YYY-YYY-YYYY"
    }
    

    Azure 서비스 사용자를 사용하도록 Maven 구성

    1) 텍스트 편집기 (일반적으로 /etc/maven/settings.xml 또는 $ HOME / .m2 / settings.xml에 있음)에서 Maven settings.xml 파일을 엽니 다.

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">
      <localRepository/>
      <interactiveMode/>
      <usePluginRegistry/>
      <offline/>
      <pluginGroups/>
    
      <servers>
       <server>
         <id>azure-auth</id>
          <configuration>
             <client>ur key</client>
             <tenant>ur tenant</tenant>
             <key>YOUR PASSWORD</key>
             <environment>AZURE</environment>
          </configuration>
       </server>
    </servers>
    
    
      <proxies/>
    
      <profiles>
        <profile>
          <id>hwx</id>
          <repositories>
            <repository>
              <id>hwx</id>
              <name>hwx</name>
              <url>http://nexus-private.hortonworks.com/nexus/content/groups/public/</url>
            </repository>
          </repositories>
        </profile>
      </profiles>
    
    
      <mirrors>
        <mirror>
          <id>public</id>
          <mirrorOf>*</mirrorOf>
          <url>http://nexus-private.hortonworks.com/nexus/content/groups/public/</url>
        </mirror>
      </mirrors>
    
      <activeProfiles/>
    </settings>
    

    2) Azure 서비스 주체 설정을이 튜토리얼의 이전 섹션에서 아래와 같이 settings.xml 파일의 컬렉션에 추가하십시오.

    <servers>
       <server>
         <id>azure-auth</id>
          <configuration>
             <client>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</client>
             <tenant>tttttttt-tttt-tttt-tttt-tttttttttttt</tenant>
             <key>pppppppp</key>
             <environment>AZURE</environment>
          </configuration>
       </server>
    </servers>
    

    3) settings.xml 파일을 저장하고 닫습니다.

    Azure에 앱 구축 및 배포

    1) 다음 명령을 실행하십시오.

    Azure maven plugin doc

  2. ==============================

    2.공식 자습서의 단계와 실제 상황을 결합하여 다음과 같은 체크 포인트를 제공합니다.

    공식 자습서의 단계와 실제 상황을 결합하여 다음과 같은 체크 포인트를 제공합니다.

    포인트 1 : mvn 패키지를 사용하여 pom.xml 파일이있는 디렉토리에 JAR 패키지를 빌드하십시오.

    ]

    포인트 2 : web.config에 구성된 jar 패키지 이름이 업로드 된 jar 패키지 이름과 동일한 지 확인하십시오.

    web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
        </handlers>
        <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
            arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\<your project name>&quot;">
        </httpPlatform>
      </system.webServer>
    </configuration>
    

    포인트 3 : KUDU의 D : \ home \ site \ wwwroot \ 디렉토리에 jar 파일과 web.config를 게시하려면 FTP를 사용하십시오.

    요점 4 : ApplicationSettings가 jdk version, tomcat version과 같은 프로젝트와 일치하는지 확인하십시오.

    war 파일을 배포하려면 Azure 포털에서 응용 프로그램 서비스의 ApplicationSettings를 구성한 다음 D : \ home \ site \ wwwroot \ webapps 경로에 war 파일을 업로드해야합니다.

    또한 KUDU의 로그 파일 (https : // <프로젝트 이름> .scm.azurewebsites.net / DebugConsole)을 확인할 수 있습니다.

    참고 문헌으로 아래의 문서 및 스레드를 참조하십시오.

    1. Azure App Service에서 웹 응용 프로그램 구성

    Azure App Service에서 Java 웹 앱 만들기

    3. Azure App 서비스에 Spring 부트를 배포하십시오.

    희망이 당신을 돕는다.

  3. ==============================

    3.스프링 부트 애플리케이션을 실행하려면 JAR 파일을 업로드하고 web.config 파일을 추가해야합니다.

    스프링 부트 애플리케이션을 실행하려면 JAR 파일을 업로드하고 web.config 파일을 추가해야합니다.

    실행하려는 서비스와 통신하려면 web.config 파일을 app 서비스의 site \ wwwroot 폴더에 추가해야합니다. web.config 파일을 이미 만들었으므로 Maven을 사용하여 다음을 추가하고 패키지에 동적으로 포함 된 프로젝트 / 릴리스를 가져옵니다.

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/wwwroot</directory>
                <filtering>true</filtering>
                <targetPath>${basedir}/target</targetPath>
            </resource>
        </resources>
    </build> 
    

    이제 jar 파일과 web.config를 Azure App Service 내에 배치하십시오.

    아래와 같이 web.config 파일을 만들었는지 한번 확인하면됩니다.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <handlers>
                <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
            </handlers>
            <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
            arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\@project.artifactId@-@project.version@.jar&quot;">
            </httpPlatform>
        </system.webServer>
    </configuration>
    
  4. ==============================

    4.하늘 자원에 관한 문제인 것에 대한 나의 직감이 옳았다는 것이 밝혀졌습니다. 자원 메모리와 CPU를 확장하면 문제가 해결되었습니다.

    하늘 자원에 관한 문제인 것에 대한 나의 직감이 옳았다는 것이 밝혀졌습니다. 자원 메모리와 CPU를 확장하면 문제가 해결되었습니다.

  5. from https://stackoverflow.com/questions/47700526/deploy-spring-boot-jar-on-azure-app-service by cc-by-sa and MIT license