Azure / Azure/Azure-Spring-Apps

New Spring Boot (blue/green) deployment with database access fails to start

Open
#52 4 comments 0 reactions 1 assignee Claimed by @LGDoor View on GitHub
Tracking
Dominant language
No language data
Stars
9
Forks
11
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Initial (blue) deployment of a Spring Boot 3.1.x app accessing an existing MySQL db in Azure using a Service Connector works. Creating a second (green) deployment and Service Connector results in a failed application start, complaining that it can't find the database.

**To Reproduce**
Steps to reproduce the behavior:

1. Clone the repo at https://github.com/mkheck/azure-spring-apps-training
2. Complete the code in chapter 7 for weather-service and build it with ./mvnw clean package -DskipTests
3. Deploy it per chapter 7
4. Follow these steps to get the required MySQL details for use in creating the Service Connector for the new (green) deployment:

export AZ_RESOURCE_GROUP=
export AZ_SPRING_APPS_NAME=
export MYSQL_TARGET_ID="$(az mysql server list --query '[0].id' -g $AZ_RESOURCE_GROUP)"
export MYSQL_SERVERNAME=$(az mysql server list -g $AZ_RESOURCE_GROUP --query '[0].name' -o tsv)
export MYSQL_USERNAME="$(az mysql server list -g $AZ_RESOURCE_GROUP --query '[0].administratorLogin' -o tsv)@${MYSQL_SERVERNAME}"
export MYSQL_HOST="$(az mysql server list -g $AZ_RESOURCE_GROUP --query '[0].fullyQualifiedDomainName' -o tsv)"
env | grep MYSQL

The last command above just verifies the env vars were successfully populated, of course.

Configure the Service Connector for the green deployment:

az spring connection create mysql --app weather-service --deployment green --client-type springBoot --database $MYSQL_SERVERNAME --server $MYSQL_HOST --tg $AZ_RESOURCE_GROUP -g $AZ_RESOURCE_GROUP --service $AZ_SPRING_APPS_NAME

az spring connection create mysql --app weather-service --deployment green --client-type springBoot --database $MYSQL_SERVERNAME --server $MYSQL_HOST --tg $AZ_RESOURCE_GROUP -g $AZ_RESOURCE_GROUP --service $AZ_SPRING_APPS_NAME

az spring app deploy -n weather-service -d green --artifact-path target/demo-0.0.1-SNAPSHOT.jar -s $AZ_SPRING_APPS_NAME -g $AZ_RESOURCE_GROUP

**Expected behavior**
Preferably, a Service Connector should work for _all_ deployments unless a particular deployment is specified. That would have eliminated the need to define a second Service Connector and should have avoided this issue entirely. That seems to have been the case in earlier versions of ASC/ASA.

Failing that, performing the above steps should result in successful startup of the new (green) deployment.

**Screenshots**
Please contact if you need any screenshots, but visually there isn't much to see: only a failed startup in the Azure Portal.

**Additional context**

**Can we contact you for additional details?** Y/N

Absolutely, always happy to help.

If yes, please send us your contact information to AzureSpringCloud-Talk@service.microsoft.com and include the issue number in the email title.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.