In azure spring boot app while having multiple instances I need to get somehow its app instance name, or would be perfect to configure nodeId generation ( int/long type , but if now I can live with name ). Anyone knows how to access this data from code ?
To get app instances name list from application code, you may try to use the following REST API:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments?api-version=2022-12-01
You should be able to find all the instances name in the response json file.
{
"value": [
{
"properties": {
...,
"instances": [
{
"name": "<app name>-<deployment name>-x-xxxxxxxx-xxxx",
"status": "Running",
"discoveryStatus": "UP",
"startTime": "2023-xx-xxTxx:xx:xxZ"
},
...
],
Reference doc: https://learn.microsoft.com/en-us/rest/api/azurespringapps/deployments/list?tabs=HTTP
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments?api-version=2022-12-01
You can find the instance list in the 'properies' -> 'instances' of the request response.
Reference doc: https://learn.microsoft.com/en-us/rest/api/azurespringapps/deployments/list-for-cluster?tabs=HTTP
Reference doc: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/resourcemanager/azure-resourcemanager-appplatform