question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Cosmos Change Feed Application Fails to be Deployed to Azure Spring Cloud

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
zmsspcommented, Feb 7, 2021

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.

0reactions
04diiguyicommented, Feb 9, 2021

Yes, please, thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting guide for Azure Spring Apps | Microsoft Learn
My application crashes or throws an unexpected error. When you're debugging application crashes, start by checking the running status and ...
Read more >
Spring Boot - Azure Cosmos DB Change Feed process failing ...
Spring Boot - Azure Cosmos DB Change Feed process failing if primary key is regenerated. Save this question. Show activity on this post....
Read more >
How to use Azure Cosmos DB from your Spring Boot App
In this episode, Mark Brown welcomes Principal Cloud Advocate Mark Heckler to the show to discuss using Azure Cosmos DB as a data...
Read more >
Working with the Azure Cosmos DB Change Feed Processor ...
This is where we process our changes that the Change Feed will read. What if an error happens in my delegate? How are...
Read more >
Introduction to Azure Cosmos DB | Microsoft Docs
Social media apps. How To Guides. Develop. DocumentDB API. MongoDB API. Graph API. Table API. Change feed. Geospatial. Indexing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found