This starter is based on spring-boot-starter-data-redis. It fetches and auto configures redis properties via Azure Redis Cache Management SDK.
Running this sample will be charged by Azure. You can check the usage and bill at this link.
Maven coordinates:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-starter-azure-cache</artifactId>
</dependency>Gradle coordinates:
dependencies {
compile group: 'com.microsoft.azure', name: 'spring-starter-azure-cache'
}-
Create azure credential file. Please see how to create credential file
$ az login $ az account set --subscription <name or id> $ az ad sp create-for-rbac --sdk-auth > my.azureauth
Make sure
my.azureauthis encoded with UTF-8. -
Put auth file under
src/main/resources/ -
Create an Azure Redis cache instance. Please follow Azure redis cache.
-
Update
src/main/resources/application.propertiesto specify resource group, cache instance name and credential file path:# Enter 'my.azureauth' here if following step 1 and 2 spring.cloud.azure.credential-file-path=[credential-file-path] spring.cloud.azure.resource-group=[resource-group] spring.cloud.azure.region=[region] spring.cloud.azure.redis.name=[azure-redis-instance-name]
-
Run the application using the
$ mvn spring-boot:runcommand. -
Send a GET request to check, where
namecould be any string:$ curl -XGET http://localhost:8080/{name} -
Confirm from Azure Redis Cache console in Azure Portal
$ keys *
-
Delete the resources on Azure Portal to avoid unexpected charges.
Here is a sample application that uses this starter.