There is no AzureKeyVaultTemplate class in the maintained Spring Cloud Azure library. The older posts and snippets that mention it describe an API that you will not find in the official starters. In a Spring Boot application you read Azure Key Vault secrets in one of two ways: as a Spring PropertySource loaded at startup, or programmatically through the Azure SDK SecretClient bean.
Both approaches come from the spring-cloud-azure-starter-keyvault-secrets dependency, which is how Microsoft documents Key Vault support for Spring.
Spring projects for other clouds ship template classes, for example SecretManagerTemplate in Spring Cloud GCP or VaultTemplate in Spring Vault. Spring Cloud Azure took a different route: it exposes the Azure SDK clients as beans and adds a property source on top. The Microsoft documentation for Key Vault Secrets support lists the starter, the spring.cloud.azure.keyvault.secret properties and the SecretClient types, with no template class.
The package com.azure.spring.cloud.autoconfigure.keyvault.AzureKeyVaultTemplate that appears in some copied examples does not match the current library. If your code imports it, it will not compile against a current Spring Cloud Azure release.
Use the Spring Cloud Azure BOM so every Azure module gets a compatible version.
Choose the Spring Cloud Azure version that matches your Spring Boot line, as listed in the project's compatibility table. The old com.microsoft.azure group id and the azure.keyvault.uri property belong to the discontinued 3.x generation.
Enable the property source and give it the vault endpoint.
Every secret in the vault becomes a property. Azure secret names allow only letters, digits and hyphens, so a secret named db-password is available as db-password and can be bound normally.
The property source can refresh secrets on an interval set with refresh-interval; check the configuration properties page for the default of your version. Refreshing does not rebuild beans that already copied the value, so beans that must see rotated secrets need @RefreshScope or should read the secret on demand.
For dynamic names, use the auto-configured SecretClient.
This bean is created when the vault endpoint is set with spring.cloud.azure.keyvault.secret.endpoint. Keys and certificates use their own clients, KeyClient and CertificateClient, from the matching starters.
Do not store a client secret to reach the vault. Spring Cloud Azure uses DefaultAzureCredential by default, which tries environment settings, workload identity, managed identity and developer logins such as the Azure CLI in order.
az login; the same code picks up your developer identity.| Environment | Credential used |
|---|---|
| Azure App Service, Container Apps, VM | Managed identity |
| AKS | Workload identity |
| Local development | Azure CLI or IDE login |
Use the SecretClient bean for programmatic access, or the Key Vault property source for configuration values.
Yes, with KeyClient and CertificateClient. The property source itself loads secrets.
No. Use a managed identity in Azure and your CLI login locally.
Set the endpoint in a profile-specific file or an environment variable, such as SPRING_CLOUD_AZURE_KEYVAULT_SECRET_PROPERTY_SOURCES_0_ENDPOINT.
AzureKeyVaultTemplate is not part of Spring Cloud Azure. Add spring-cloud-azure-starter-keyvault-secrets, load secrets through the property source, inject SecretClient for runtime lookups, and authenticate with a managed identity so no credential lives in your configuration.