The Azure Blob Storage configuration correctly injects the connection string, but fails to resolve the container name. Instead of retrieving the expected value from the environment variable (e.g., mdfinfra-ms-container
), it prints the literal string $(AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME)
.
2025-03-11 19:41:16 [main] INFO c.s.m.c.c.AzureBlobStorageConfig - SUCCESS: Azure Storage container name loaded: $(AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME)
This indicates that the placeholder $(AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME)
is not being replaced with its actual value.
${AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME}
is not being resolved correctly.$()
) Instead of Spring Property Syntax (${}
)
The application configuration (application-dev.properties
) uses:
azure.storage.container-name=$(AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME)
However, in Spring Boot properties files, the correct syntax should be:
azure.storage.container-name=${AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME}
The $(...)
syntax is used in shell scripts, not in property files.
If the environment variable is not set at runtime, Spring will not replace the placeholder and will keep it as a raw string.
You can check whether the environment variable is set properly by running:
echo $AZURE_STORAGE_TIME_REGISTRATION_CONTAINER_NAME
If this command does not output mdfinfra-ms-container
, then the environment variable is not correctly set.
**Solution:
As can be seen, this was really the solution:**
${}
syntax tells Spring to resolve the value from environment variables or system properties.$(...)
syntax is incorrect for Spring and is used for shell variable expansion.So, was this a troubleshoot case worthy?
Not really, but always good to also document human errors that can occur 😎