microsoft / azure-maven-plugins

Maven plugins for Azure
MIT License
276 stars 150 forks source link

Redeploy Fails - Maven Plugin for Java SE in App Service Linux #250

Closed selvasingh closed 6 years ago

selvasingh commented 6 years ago

Plugin name and version

<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.2.0</version>

Plugin configuration in your pom.xml

See below

Expected behavior

Redeploy should succeed

Actual behavior

Redeploy fails

Steps to reproduce the problem

Start with bash-3.2$ git clone https://github.com/spring-projects/spring-petclinic.git

Add Maven plugin for Azure Web Apps to the Spring PetClinic POM file and set server port to 80.

 <build>
    <plugins>
       <plugin>
          <groupId>com.microsoft.azure</groupId>
          <artifactId>azure-webapp-maven-plugin</artifactId>
          <version>1.2.0</version>
          <configuration>

            <!-- Web App information -->
             <resourceGroup>${RESOURCE_GROUP}</resourceGroup>
             <appName>${WEBAPP_NAME}</appName>
             <region>${REGION}</region>
             <pricingTier>S1</pricingTier>

             <!-- Java Runtime Stack for Web App on Linux -->
             <linuxRuntime>jre8</linuxRuntime>
             <!-- This is to make sure the jar file can be released at the server side -->
             <stopAppDuringDeployment>true</stopAppDuringDeployment>
             <deploymentType>ftp</deploymentType>
             <!-- Resources to be deployed to your Web App -->
             <resources>
                <resource>
                   <directory>${project.basedir}/target</directory>
                   <targetPath>/</targetPath>
                   <includes>
                      <include>app.jar</include>
                   </includes>
                </resource>
             </resources>
             <appSettings>
                <property>
                   <name>JAVA_OPTS</name><value>-Djava.security.egd=file:/dev/./urandom</value>
                </property>
             </appSettings>
          </configuration>
      </plugin>
    </plugins>
    <finalName>app</finalName> 
</build> 

Then, deploy

bash-3.2$ mvn package azure-webapp:deploy
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building petclinic 2.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
...
[INFO] --- azure-webapp-maven-plugin:1.2.0:deploy (default-cli) @ spring-petclinic ---
[INFO] Start deploying to Web App myjavase-07262018aa...
[INFO] Authenticate with Azure CLI 2.0
[INFO] Target Web App doesn't exist. Creating a new one...
[INFO] Creating App Service Plan 'ServicePlan1af9c8f0-3f71-43a8'...
[INFO] Successfully created App Service Plan.
[INFO] Successfully created Web App.
...
[INFO] Finished uploading directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] Successfully uploaded files to FTP server: waws-prod-bay-081.ftp.azurewebsites.windows.net
[INFO] Starting Web App after deploying artifacts...
[INFO] Successfully started Web App.
[INFO] Successfully deployed Web App at https://myjavase-07262018aa.azurewebsites.net
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:06 min
[INFO] Finished at: 2018-07-13T18:03:22-07:00
[INFO] Final Memory: 139M/987M
[INFO] ------------------------------------------------------------------------

Then try to redeploy ...

[INFO] --- azure-webapp-maven-plugin:1.2.0:deploy (default-cli) @ spring-petclinic ---
[INFO] Start deploying to Web App myjavase-07262018aa...
[INFO] Authenticate with Azure CLI 2.0
[INFO] Updating target Web App...
[INFO] Successfully updated Web App.
[INFO] Stopping Web App before deploying artifacts...
[INFO] Successfully stopped Web App.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa
[INFO] Starting uploading files to FTP server: waws-prod-bay-081.ftp.azurewebsites.windows.net
[INFO] Starting uploading directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] [DIR] /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] ..[FILE] /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa/app.jar --> /site/wwwroot
[ERROR] .........Reply Message : 550 The process cannot access the file because it is being used by another process. 

[ERROR] Failed to upload directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[WARNING] Failed to upload files to FTP server, retrying immediately (1/3)
[INFO] Starting uploading files to FTP server: waws-prod-bay-081.ftp.azurewebsites.windows.net
[INFO] Starting uploading directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] [DIR] /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] ..[FILE] /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa/app.jar --> /site/wwwroot
[ERROR] .........Reply Message : 550 The process cannot access the file because it is being used by another process. 

[ERROR] Failed to upload directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[WARNING] Failed to upload files to FTP server, retrying immediately (2/3)
[INFO] Starting uploading files to FTP server: waws-prod-bay-081.ftp.azurewebsites.windows.net
[INFO] Starting uploading directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] [DIR] /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] ..[FILE] /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa/app.jar --> /site/wwwroot
[ERROR] .........Reply Message : 550 The process cannot access the file because it is being used by another process. 

[ERROR] Failed to upload directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[WARNING] Failed to upload files to FTP server, retrying immediately (3/3)
[INFO] Starting Web App after deploying artifacts...
[INFO] Successfully started Web App.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 50.155 s
[INFO] Finished at: 2018-07-13T18:18:06-07:00
[INFO] Final Memory: 57M/511M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.microsoft.azure:azure-webapp-maven-plugin:1.2.0:deploy (default-cli) on project spring-petclinic: Failed to upload files to FTP server after 3 retries... -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
jdneo commented 6 years ago

This issue can be addressed by using the zipDeploy, which is supported after web app plugin 1.4.0

Here is a sample plugin configuration:

<plugin>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-webapp-maven-plugin</artifactId>
    <version>1.4.0</version>
    <configuration>
        <resourceGroup>${azure.resource.group}</resourceGroup>
        <appName>${azure.app.name}</appName>
        <linuxRuntime>jre8</linuxRuntime>
    </configuration>
</plugin>