-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Basic App Configuration Refresh Sample (#48)
- Loading branch information
Showing
6 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
appconfiguration/azure-appconfiguration-refresh-sample/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Azure App Configuration Refresh Sample | ||
|
||
## Prerequisite | ||
|
||
* A [Java Development Kit (JDK)](https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable), version 8. | ||
* [Apache Maven](http://maven.apache.org/), version 3.0 or later. | ||
|
||
## How to run | ||
|
||
### Run the application | ||
|
||
1. Build the application | ||
|
||
```console | ||
mvn clean package | ||
``` | ||
|
||
1. Run the application | ||
|
||
```console | ||
mvn spring-boot:run | ||
``` |
63 changes: 63 additions & 0 deletions
63
appconfiguration/azure-appconfiguration-refresh-sample/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.5.2</version> | ||
<relativePath /> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.azure.spring</groupId> | ||
<artifactId>azure-appconfiguration-refresh-sample</artifactId> | ||
<version>0.1.0</version> | ||
<packaging>jar</packaging> | ||
<name>Azure App Configuration Refresh Sample</name> | ||
|
||
|
||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>2020.0.3</version> <!-- {x-version-update;org.springframework.cloud:spring-cloud-dependencies;external_dependency} --> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.azure</groupId> | ||
<artifactId>azure-core</artifactId> | ||
<version>1.20.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} --> | ||
</dependency> | ||
|
||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.azure.spring</groupId> | ||
<artifactId>azure-spring-cloud-starter-appconfiguration-config</artifactId> | ||
<version>2.1.0</version> | ||
</dependency> | ||
|
||
<!-- Adds the Ability to Push Refresh --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
14 changes: 14 additions & 0 deletions
14
...onfiguration/azure-appconfiguration-refresh-sample/src/main/java/example/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package example; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
|
||
@SpringBootApplication | ||
@EnableConfigurationProperties | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...guration/azure-appconfiguration-refresh-sample/src/main/java/example/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE in the project root for | ||
* license information. | ||
*/ | ||
package example; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
|
||
@RestController | ||
public class HelloController { | ||
|
||
@Autowired | ||
private MessageProperties properties; | ||
|
||
@GetMapping("") | ||
public String getMessage() throws JsonProcessingException { | ||
return properties.getMessage(); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...ration/azure-appconfiguration-refresh-sample/src/main/java/example/MessageProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE in the project root for | ||
* license information. | ||
*/ | ||
package example; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "config") | ||
public class MessageProperties { | ||
|
||
private String message; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...nfiguration/azure-appconfiguration-refresh-sample/src/main/resources/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
spring.cloud.azure.appconfiguration.stores[0].connection-string=${CONFIG_STORE_CONNECTION_STRING} | ||
|
||
spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filter=,${spring.profiles.active} | ||
spring.cloud.azure.appconfiguration.stores[0].monitoring.enabled=true | ||
spring.cloud.azure.appconfiguration.stores[0].monitoring.refresh-interval=5s | ||
spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key=sentinel |