[BUG] Cosmos Change Feed Application Fails to be Deployed to Azure Spring Cloud
See original GitHub issueDescribe the bug
We would like to have a console application that leverages Cosmos change feed that does not need traffic. The deployment to Azure spring cloud fails and reboots all the time. The application can run on a local machine.
@SpringBootApplication
public class ChangeFeedHandlerApplication implements CommandLineRunner {
@Autowired
private ChangeFeedListener listener;
public static void main(String[] args) {
SpringApplication app = new SpringApplication(ChangeFeedHandlerApplication.class);
app.setWebApplicationType(WebApplicationType.NONE);
app.run(args);
}
}
Initially we thought that is because we do not set up a web server that keeps the server up.
So we added the following to pom file, and it does not help.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Finally, we changed the content in main to
SpringApplication.run(ChangeFeedHandlerApplication.class);
and it works.
Conclusion:
A console application is not a web application which does not need traffic. So maybe we do not need to specify to enable web server in order to deploy it to Azure Spring Cloud especially the application could run in a local machine.
To Reproduce
We put our sample code in the following Github Repo: https://github.com/charleszipp/azure-spring-cloud-cosmos-change-feed
The main branch can be deployed to Azure Spring Cloud,
The following changes would break the deployment. https://github.com/charleszipp/azure-spring-cloud-cosmos-change-feed/pull/1
Code Snippet Add the code snippet that causes the issue.
The application can run both in local env and spring cloud:
@SpringBootApplication
public class ChangeFeedHandlerApplication {
@Autowired
private ChangeFeedListener listener;
public static void main(String[] args) {
SpringApplication.run(ChangeFeedHandlerApplication.class);
}
@PostConstruct
public void run() throws Exception {
try
{
listener.start();
}
catch (Exception ex){
throw ex;
}
}
}
The application can run only in local env but not in spring cloud:
@SpringBootApplication
public class ChangeFeedHandlerApplication implements CommandLineRunner {
@Autowired
private ChangeFeedListener listener;
public static void main(String[] args) {
SpringApplication app = new SpringApplication(ChangeFeedHandlerApplication.class);
app.setWebApplicationType(WebApplicationType.NONE);
app.run(args);
}
@Override
public void run(String... args) throws Exception {
try
{
listener.start();
}
catch (Exception ex){
throw ex;
}
}
}
Expected behavior
The application is a console app, so setting it to be “WebApplicationType.NONE” and the application should still be able to deployed to Azure Spring Cloud.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
This is by design, Azure Spring Cloud will probe the application port to check the health status of the app. So if you set the web type to None, the app will not listen to any port, then Azure Spring Cloud will consider the app does not start successfully.
Yes, please, thanks a lot.