@Maciej Bąk Thank you for reaching out to Microsoft Q&A. I assume you are using Azure Spring Apps and looking to get instance name, you can follow the below docs:
REST API: [Services - List]: Get list of service instances under resource group. [Apps - List]: Get list of app instances under service name including app instance name.
For Java SDK, you can use azure-resourcemanager library and
Manage Spring Cloud sample listed here would help with few other scenarios. To list all spring apps under a spring service, use the below code snippet:
List<SpringApp> springApps = springService.apps().list().stream().toList();
I hope this helps with your question, and feel free to add a comment for questions. Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community.