使用Maven部署Azure Spring Apps时遇DeploymentSettings缺失错误
问题场景
严格按照官方流程部署无特殊依赖的HelloSpring示例应用到Azure Spring Apps,仅将azure-spring-apps-maven-plugin从1.10.0升级至1.17.0,执行mvn com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:config完成配置后,运行mvn azure-spring-apps:deploy时触发以下错误:
[ERROR] Operator called default onErrorDropped
reactor.core.Exceptions$StaticThrowable: Operator has been terminated
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.680 s
[INFO] Finished at: 2023-05-02T19:06:23+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:deploy (default-cli) on project hellospring: create or update Spring app(hellospring) from config: AzureToolkitRuntimeException: create Azure Spring App deployment (default): Status code 400, "{"error":{"code":"BadArgument","message":"Invalid arguments: DeploymentSettings must be provided.","details":[{"code":"BadArgument","message":"DeploymentSettings must be provided.","target":"Properties.DeploymentSettings"}]}}" -> [Help 1]
排查解决步骤
- 检查并补全pom.xml插件配置
1.17.0版本的插件要求显式指定部署基础配置,即使是默认值。打开项目的pom.xml,找到azure-spring-apps-maven-plugin配置块,添加deployment节点,示例如下:<plugin> <groupId>com.microsoft.azure</groupId> <artifactId>azure-spring-apps-maven-plugin</artifactId> <version>1.17.0</version> <configuration> <subscriptionId>你的订阅ID</subscriptionId> <resourceGroup>你的资源组名称</resourceGroup> <serviceName>你的Azure Spring Apps服务名称</serviceName> <appName>hellospring</appName> <!-- 显式声明部署配置 --> <deployment> <name>default</name> <runtimeVersion>Java 17</runtimeVersion> <!-- 匹配你的应用JDK版本 --> <instanceCount>1</instanceCount> <cpu>1</cpu> <memoryInGB>1</memoryInGB> </deployment> </configuration> </plugin> - 重新生成配置(可选)
若手动修改怕出错,可重新执行配置命令,在交互流程中完整确认所有部署相关选项(运行时版本、实例数等),插件会自动写入配置:mvn com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:config - 清理缓存后重新部署
修改配置后,清理本地构建缓存再执行部署:mvn clean package azure-spring-apps:deploy
原因说明
插件1.17.0版本强化了部署配置的校验规则,不再自动填充默认的DeploymentSettings参数,必须显式指定运行时版本、实例规格等基础信息,否则Azure API会返回400参数错误。
内容的提问来源于stack exchange,提问作者Nicolas Riousset

