Azure Spring Boot client library for Java
This repo is for Spring Boot Starters of Azure services. It helps Spring Boot developers to adopt Azure services.
Source code | Package (Maven) | API reference documentation | Product documentation | Samples
Getting started
Prerequisites
Include the Package
- [Add azure-spring-boot-bom].
- Add dependency.
<version>can be skipped because we already addazure-spring-boot-bom.
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot</artifactId>
</dependency>
Key concepts
This project provides auto-configuration for the following Azure services:
- Azure Active Directory
- Azure Active Directory B2C
- Cosmos DB SQL API
- Key Vault Secrets
- JMS Service Bus
- [Storage]
This module also provides the ability to automatically inject credentials from Cloud Foundry into your
applications consuming Azure services. It does this by reading the VCAP_SERVICES environment
variable and setting the appropriate properties used by auto-configuration code.
For details, please see sample code in the azure-spring-boot-sample-cloud-foundry
Health indicator
You can use health information to check the status of your running application. It is often used by monitoring software to alert someone when a production system goes down. The information exposed by the health endpoint depends on the management.endpoint.health.show-details and management.endpoint.health.show-components properties which can be configured with one of the following values:
| key | Name | | ---- | ---- | | never | Details are never shown. | | when-authorized | Details are only shown to authorized users. Authorized roles can be configured using management.endpoint.health.roles. | | always |Details are shown to all users. |
The default value is never. A user is considered to be authorized when they are in one or more of the endpoint’s roles. If the endpoint has no configured roles (the default) all authenticated users are considered to be authorized. The roles can be configured using the management.endpoint.health.roles property.
NOTE: If you have secured your application and wish to use always, your security configuration
must permit access to the health endpoint for both authenticated and unauthenticated users.
Auto-configured HealthIndicators
The following HealthIndicators are auto-configured by Azure Spring Boot when appropriate. You can also enable/disable selected indicators by configuring management.health.key.enabled, with the key listed in the table below.
| key | Name | Description | | ---- | ---- | ---- | | azure-cosmos | CosmosHealthIndicator | Checks that a cosmos database is up. | | azure-key-vault | KeyVaultHealthIndicator | Checks that a key vault is up. | | azure-storage | BlobStorageHealthIndicator | Checks that a storage blob is up. | | azure-storage | FileStorageHealthIndicator | Checks that a storage file is up. |
Add the dependent
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
Enabling the Actuator
When you do the following configuration in application.yml , you can access the endpoint to get
the health of the component.
management:
health:
azure-cosmos:
enabled: true
azure-key-vault:
enabled: true
azure-storage:
enabled: true
endpoint:
health:
show-details: always
Access the Health Endpoint:
{
"status": "UP",
"components": {
"blobStorage": {
"status": "UP",
"details": {
"URL": "https://xxxx.blob.core.windows.net"
}
},
"cosmos": {
"status": "UP",
"details": {
"database": "xxx"
}
},
"keyVault": {
"status": "UP"
}
}
}
Examples
The following section provides sample projects illustrating how to use the Azure Spring Boot starters.
More sample code
- Azure Active Directory for Web Application
- Azure Active Directory for Resource Server
- Azure Active Directory for Resource Server with Obo Clients
- Azure Active Directory for Resource Server by Filter(Deprecated)
- Azure Active Directory B2C
- Cosmos DB SQL API
- Key Vault
- JMS Service Bus Queue
- JMS Service Bus Topic
Troubleshooting
Logging setting
Please refer to [spring logging document] to get more information about logging.
Logging setting examples
- Example: Setting logging level of hibernate
logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
Next steps
The following section provides sample projects illustrating how to use the Azure Spring Boot starters.
More sample code
- Azure Active Directory for Web Application
- Azure Active Directory for Resource Server
- Azure Active Directory for Resource Server with Obo Clients
- Azure Active Directory for Resource Server by Filter(Deprecated)
- Azure Active Directory B2C
- Cosmos DB SQL API
- Key Vault
- JMS Service Bus Queue
- JMS Service Bus Topic
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
Please follow instructions here to build from source or contribute.
If you encounter any bug, please file an issue here.
To suggest a new feature or changes that could be made, file an issue the same way you would for a bug.
You can participate community driven
| Package | Description |
|---|---|
| com.azure.spring.aad |
Package com.azure.spring.aad
|
| com.azure.spring.aad.webapi |
Package com.azure.spring.aad.webapi
|
| com.azure.spring.aad.webapi.validator |
Package com.azure.spring.aad.resource.server.validator
|
| com.azure.spring.aad.webapp |
Package com.azure.spring.aad.webapp
|
| com.azure.spring.autoconfigure.aad |
Package com.azure.spring.autoconfigure.aad
|
| com.azure.spring.autoconfigure.b2c |
Package com.azure.spring.autoconfigure.b2c
|
| com.azure.spring.autoconfigure.condition.aad |
Package com.azure.spring.autoconfigure.condition.aad
|
| com.azure.spring.autoconfigure.cosmos |
Package com.azure.spring.autoconfigure.cosmos
|
| com.azure.spring.autoconfigure.jms |
Package com.azure.spring.autoconfigure.jms
|
| com.azure.spring.autoconfigure.storage |
Package com.azure.spring.cloud.autoconfigure.storage;
|
| com.azure.spring.autoconfigure.storage.actuator |
Package com.azure.spring.cloud.autoconfigure.storage.actuator;
|
| com.azure.spring.autoconfigure.storage.resource |
Package com.azure.spring.cloud.storage;
|
| com.azure.spring.cloudfoundry.environment |
Package com.azure.spring.cloudfoundry.environment
|
| com.azure.spring.keyvault |
Package com.azure.keyvault.spring
|
| com.azure.spring.utils |
Package com.azure.spring.utils
|