Describe 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.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kushagraThapar, @anfeldma-ms
This is more of an Azure Spring Cloud issue, @chenrujun @saragluna can you guys please route it to the correct team ?
@04diiguyi I will look into it.
Could you share your Azure Spring Cloud service name and App name, then we can take a look.
Could you share your Azure Spring Cloud service name and App name, then we can take a look.
@zmssp Maybe you can refer to the following parameters
Service instance name: spr-leo-dev-usea-czp
App name: change-feed-processor
Deployment name: default
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.
@04diiguyi are we okay to close this issue now?
Yes, please, thanks a lot.
Most helpful comment
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.