microsoft / azure-maven-plugins

Maven plugins for Azure
MIT License
274 stars 148 forks source link

[FEATURE_REQ] Use Spring Apps plugin to configure a more accurate app name #2295

Open moarychan opened 1 year ago

moarychan commented 1 year ago

Plugin name and version

azure-spring-apps-maven-plugin, 1.17.0

Plugin configuration in your pom.xml

<plugin>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-spring-apps-maven-plugin</artifactId>
    <version>1.17.0</version>
    <configuration>
        <subscriptionId>xx</subscriptionId>
        <resourceGroup>rg-xxx</resourceGroup>
        <clusterName>moary15-xxx</clusterName>
        <appName>spring-petclinic-customers-service</appName>
        <isPublic>false</isPublic>
        <deployment>
            <cpu>1</cpu>
            <memoryInGB>1</memoryInGB>
            <instanceCount>1</instanceCount>
            <runtimeVersion>Java 17</runtimeVersion>
            <resources>
                <resource>
                    <filtering/>
                    <mergeId/>
                    <targetPath/>
                    <directory>${project.basedir}/target</directory>
                    <includes>
                        <include>*.jar</include>
                    </includes>
                </resource>
            </resources>
        </deployment>
    </configuration>
</plugin>

the application yml file of the module spring-petclinic-customers-service:

spring:
  application:
    name: customers-service

Expected behavior

The node appName under maven plugin azure-spring-apps-maven-plugin is <appName>customers-service</appName>.

Since Azure Spring Apps uses the name of the app as the service name of the built-in eureka service, the Maven plugin for Azure Spring Apps extracts the artifact ID in the POM file as the app name by default, so it needs to be consistent with the spring.application.name of each module. So the plugin should take the name from spring.application.name first, then take the name from the artifact ID if not the definition application name property. If the final app name exceeds the max length, it should require the user to rename it, and also providing a normal name by default will be better.

Actual behavior

It's <appName>spring-petclinic-customers-service</appName>, and will encounter an exception when executing xx:deploy, this is because the app name exceeds the max length.

Steps to reproduce the problem