azure-maven-plugins
azure-maven-plugins copied to clipboard
Subfolders are not populated and app.jar is overriden by other jar files
Plugin name and version
- azure-webapp-maven-plugin
- 2.6.0
Plugin configuration in your pom.xml
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>2.6.0</version>
<configuration>
<schemaVersion>v2</schemaVersion>
<subscriptionId>...</subscriptionId>
<resourceGroup>...</resourceGroup>
<appName>...</appName>
<pricingTier>F1</pricingTier>
<region>westeurope</region>
<runtime>
<os>Linux</os>
<javaVersion>Java 11</javaVersion>
<webContainer>Java SE</webContainer>
</runtime>
<deployment>
<resources>
<!-- Upload executable jar -->
<resource>
<directory>${project.basedir}/target/production</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
<!-- Upload resource folder with additional content -->
<resource>
<directory>${project.basedir}/target/production/resources</directory>
<targetPath>resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<!-- Upload all dependencies (libraries) -->
<resource>
<directory>${project.basedir}/target/production/lib</directory>
<targetPath>lib</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
Expected behavior
2 folders "lib" and "resources" under wwwroot and one app.jar. the "lib" folder contains the dependencies (.jar files) that are needed for the application
Actual behavior
Libraries under "lib" replace the app.jar directly in wwwroot and the server does not start, no "lib" and "resources" folder is created
Steps to reproduce the problem
Use maven to deploy the target
cd ..\..\AppServer
rmdir /s /q target
rmdir /s /q lib
call mvn clean package
call mvn package
call mvn package azure-webapp:deploy
Update: it works as expected with version 1.14.0
@dsteindo Thanks for your report, we have migrated to kudu deployment which need to specify the deployment type for each resource, or we will deploy it as a jar file by default. Could you please try deploy with following configuration? You may find more details about kudu deployment here
<resources>
<!-- Upload executable jar -->
<resource>
<directory>${project.basedir}/target/production</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
<!-- Upload resource folder with additional content -->
<resource>
<type>static</type>
<directory>${project.basedir}/target/production/resources</directory>
<targetPath>resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<!-- Upload all dependencies (libraries) -->
<resource>
<type>static</type>
<directory>${project.basedir}/target/production/lib</directory>
<targetPath>lib</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
Hi @Flanker32 Thank you for your suggestion, it worked as expected and the structure was considered, however I have an question regarding the deployment logs now. Before with 1.14.0 the deployment logs looked like this in azure
2022-07-11T17:56:56 Fetching changes.
2022-07-11T17:56:56 Cleaning up temp folders from previous zip deployments and extracting pushed zip file /tmp/zipdeploy/[some hash].zip (17.67 MB) to /tmp/zipdeploy/extracted
2022-07-11T17:57:02 Updating submodules.
2022-07-11T17:57:02 Preparing deployment for commit id '[some hash]'.
2022-07-11T17:57:02 PreDeployment: context.CleanOutputPath False
2022-07-11T17:57:02 PreDeployment: context.OutputPath /home/site/wwwroot
2022-07-11T17:57:02 Running build. Project type: OneDeploy
2022-07-11T17:57:03 Copying the manifest
2022-07-11T17:57:03 Clean deploying to /home/site/wwwroot
2022-07-11T17:57:03 Generating deployment script.
2022-07-11T17:57:03 Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "/tmp/zipdeploy/extracted" -o "/home/site/deployments/tools" --basic --sitePath "/tmp/zipdeploy/extracted"').
2022-07-11T17:57:03 Running deployment command...
2022-07-11T17:57:03 Command: "/home/site/deployments/tools/deploy.sh"
2022-07-11T17:57:03 Handling Basic Web Site deployment.
2022-07-11T17:57:04 Kudu sync from: '/tmp/zipdeploy/extracted' to: '/home/site/wwwroot'
2022-07-11T17:57:04 Copying file: 'app.jar'
2022-07-11T17:57:04 Copying file: 'lib/commons-csv-1.9.0.jar'
2022-07-11T17:57:04 Copying file: 'lib/jackson-annotations-2.13.3.jar'
2022-07-11T17:57:05 Copying file: 'lib/jackson-core-2.13.3.jar'
2022-07-11T17:57:05 Copying file: 'lib/jackson-databind-2.13.3.jar'
2022-07-11T17:57:05 Copying file: 'lib/javax.annotation-api-1.3.2.jar'
2022-07-11T17:57:05 Copying file: 'lib/javax.servlet-api-4.0.1.jar'
2022-07-11T17:57:05 Copying file: 'lib/mysql-connector-java-8.0.29.jar'
2022-07-11T17:57:05 Copying file: 'lib/protobuf-java-3.19.4.jar'
2022-07-11T17:57:05 Copying file: 'lib/slf4j-api-1.7.36.jar'
2022-07-11T17:57:05 Copying file: 'lib/slf4j-simple-1.7.36.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-aop-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-beans-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-boot-2.7.1.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-boot-autoconfigure-2.7.1.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-context-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-core-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-expression-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-jcl-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-security-core-5.7.2.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-security-crypto-5.7.2.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-web-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/spring-webmvc-5.3.21.jar'
2022-07-11T17:57:05 Copying file: 'lib/tomcat-annotations-api-9.0.64.jar'
2022-07-11T17:57:05 Copying file: 'lib/tomcat-embed-core-9.0.64.jar'
2022-07-11T17:57:05 Copying file: 'resources/dummy.txt'
2022-07-11T17:57:05 Finished successfully.
2022-07-11T17:57:06 Build completed succesfully.
2022-07-11T17:57:06 Running post deployment command(s)...
2022-07-11T17:57:06 Requesting site restart
2022-07-11T17:57:06 Requesting site restart. Attempt #1
2022-07-11T17:57:07 Successfully requested a restart. Attempt #1
2022-07-11T17:57:07 Deployment successful.
And it seems that the whole "wwwroot" directory was cleaned up before the files were uploaded
Now with 2.6.0 I get a dozen deployment logs in this format
2022-07-12T15:37:43 Fetching changes.
2022-07-12T15:37:47 Updating submodules.
2022-07-12T15:37:47 Preparing deployment for commit id '[some hash]'.
2022-07-12T15:37:48 PreDeployment: context.CleanOutputPath False
2022-07-12T15:37:48 PreDeployment: context.OutputPath /home/site/wwwroot
2022-07-12T15:37:48 Running build. Project type: OneDeploy
2022-07-12T15:37:48 Copying the manifest
2022-07-12T15:37:48 Incrementally deploying to /home/site/wwwroot
2022-07-12T15:37:48 Build completed succesfully.
2022-07-12T15:37:48 Running post deployment command(s)...
2022-07-12T15:37:48 Requesting site restart
2022-07-12T15:37:48 Requesting site restart. Attempt #1
2022-07-12T15:37:49 Successfully requested a restart. Attempt #1
2022-07-12T15:37:49 Deployment successful.
There is no info which files were uploaded and it seems to replace existing files and leaving old ones behind.
I tried to set this clean
attribute but it was not considered and the build failed, so I am not sure where it should be positioned.
Is this wanted behavior and is there a possibility to restart the application only once the final file is uploaded?
(same here, I do not know where this restart
attribute needs to be positioned, as it complains when I add it to the resource
)
@dsteindo Sorry for the late response, currently maven toolkit did not support deploy options like clean
and restart
in one deploy. We are working on the support and will update here once there are updates.
If you want to restart the application after deployment, you may set <stopAppDuringDeployment>
to true
in configuration, we will stop the app before deployment and restart it after deploy done.
Thank you for the support so far @Flanker32 and I am looking forward to future improvements. In the meanwhile I can work with the latest version as of now :)