Skip to content

Commit

Permalink
Merge branch 'fix-config' of github.com:leonard520/Azure-Spring-Cloud…
Browse files Browse the repository at this point in the history
…-Samples into fix-config
  • Loading branch information
Xiaoyun Ding committed Dec 15, 2023
2 parents 997ca39 + 25d9e13 commit 71978bf
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 86 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: build

on:
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build java-8-sample
run: mvn -B package -D skipTests -f java-8-sample/pom.xml
- name: Build java-11-sample
run: mvn -B package -D skipTests -f java-11-sample/pom.xml
- name: Build hystrix-turbine-sample
run: mvn -B package -D skipTests -f hystrix-turbine-sample/user-service/pom.xml
16 changes: 16 additions & 0 deletions .github/workflows/markdown-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Markdown Links Check

on:
pull_request:
branches: [ "main" ]

jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@1.0.15
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.github/workflows/mlc_config.json'
20 changes: 20 additions & 0 deletions .github/workflows/mlc_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ignorePatterns": [
{
"pattern": "^http://127.0.0.1"
},
{
"pattern": "^https://127.0.0.1"
},
{
"pattern": "^http://localhost"
},
{
"pattern": "^https://localhost"
},
{
"pattern": "^http://proxyserver"
}
],
"aliveStatusCodes": [200]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ publish/

# VS Code
.vscode/

setup-env-variables.sh
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ urlFragment: "azure-spring-cloud-samples"
---

# Azure Spring Apps Samples
![Build](https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples/actions/workflows/build.yml/badge.svg) ![Check Markdown Links](https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples/actions/workflows/markdown-link-check.yml/badge.svg)

<!--
Guidelines on README format: https://review.docs.microsoft.com/help/onboard/admin/samples/concepts/readme-template?branch=master
Guidance on onboarding samples to docs.microsoft.com/samples: https://review.docs.microsoft.com/help/onboard/admin/samples/process/onboarding?branch=master
Taxonomies for products and languages: https://review.docs.microsoft.com/new-hope/information-architecture/metadata/taxonomies?branch=master
-->

## Overview

Expand Down
16 changes: 8 additions & 8 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.2 BLOCK -->
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->

## Security

Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [many more](https://opensource.microsoft.com/).
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).

If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [definition](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below.
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).

If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

Expand All @@ -28,14 +28,14 @@ Please include the requested information listed below (as much as you can provid

This information will help us triage your report more quickly.

If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.

## Preferred Languages

We prefer all communications to be in English.

## Policy

Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).

<!-- END MICROSOFT SECURITY.MD BLOCK -->
4 changes: 2 additions & 2 deletions config-server-yaml-samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The http basic authentication [config-server-http-basic-auth.yml](./config-serve

### SSH Authentication

The ssh authentication [config-server-ssh-auth.yml](./config-server-ssh-auth.yml) file for `Config Server` focus on access private git repository with [SSH](./https://en.wikipedia.org/wiki/Secure_Shell). Almost the same as `Http Basic Authentication`, at least the `private key` of `SSH` should be provided.
The ssh authentication [config-server-ssh-auth.yml](./config-server-ssh-auth.yml) file for `Config Server` focus on access private git repository with [SSH](https://en.wikipedia.org/wiki/Secure_Shell). Almost the same as `Http Basic Authentication`, at least the `private key` of `SSH` should be provided.

### Pattern

Expand All @@ -23,4 +23,4 @@ The more complex like pattern matching on the application and profile name is al
1. https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.4.RELEASE/single/spring-cloud-config.html#_git_backend
2. https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.4.RELEASE/single/spring-cloud-config.html#_authentication
3. https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.4.RELEASE/single/spring-cloud-config.html#_git_ssh_configuration_using_properties
4. https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.4.RELEASE/single/spring-cloud-config.html#_pattern_matching_and_multiple_repositories
4. https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.4.RELEASE/single/spring-cloud-config.html#_pattern_matching_and_multiple_repositories
73 changes: 55 additions & 18 deletions hystrix-turbine-sample/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Clone the sample repository to your develop environment. It is forked from [this repository](https://github.com/StackAbuse/spring-cloud/tree/master/spring-turbine), check out the original [blog](https://stackabuse.com/spring-cloud-turbine/) if you want to learn more.

```azurecli
```bash
git clone https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples.git
cd Azure-Spring-Cloud-Samples/hystrix-turbine-sample
```
Expand All @@ -18,35 +18,59 @@ Build the 3 applications that will be used in this tutorial.
* recommendation-service: A simple REST service that has a single endpoint of `/recommendations`, which will be called by user-service.
* hystrix-turbine: A Hystrix dashboard service to display Hystrix streams and a Turbine service aggregating Hystrix metrics stream from other services.

```azurecli
```bash
mvn clean package -D skipTests -f user-service/pom.xml
mvn clean package -D skipTests -f recommendation-service/pom.xml
mvn clean package -D skipTests -f hystrix-turbine/pom.xml
```

## Provision your Azure Spring Apps instance

See: https://docs.microsoft.com/azure/spring-cloud/spring-cloud-quickstart-launch-app-cli#provision-a-service-instance-on-the-azure-cli
Please reference doc to provision Azure Spring Apps instance: https://learn.microsoft.com/azure/spring-apps/quickstart?pivots=sc-standard

Create environment variables file `setup-env-variables.sh` based on template.
```bash
cp .\setup-env-variables-template.sh setup-env-variables.sh
```

Update below resource information in `setup-env-variables.sh`.
```bash
export SUBSCRIPTION='subscription-id' # replace it with your subscription-id
export RESOURCE_GROUP='resource-group-name' # existing resource group or one that will be created in next steps
export SPRING_APPS_SERVICE='azure-spring-apps-name' # name of the service that will be created in the next steps
```

Source setting.
```bash
source ./setup-env-variables.sh
```

Update default subscription.
```bash
az account set --subscription ${SUBSCRIPTION}
```

## Deploy your applications to Azure Spring Apps

Be aware that our apps are not using Config Server, thus no need to config Config Server for Azure Spring Apps before deployment.

```azurecli
az spring-cloud app create -n user-service --is-public
az spring-cloud app create -n recommendation-service
az spring-cloud app create -n hystrix-turbine --is-public
```bash
az spring app create -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n user-service --is-public
az spring app create -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n recommendation-service
az spring app create -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n hystrix-turbine --is-public

az spring-cloud app deploy -n user-service --jar-path user-service/target/user-service.jar
az spring-cloud app deploy -n recommendation-service --jar-path recommendation-service/target/recommendation-service.jar
az spring-cloud app deploy -n hystrix-turbine --jar-path hystrix-turbine/target/hystrix-turbine.jar
az spring app deploy -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n user-service --artifact-path user-service/target/user-service.jar
az spring app deploy -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n recommendation-service --artifact-path recommendation-service/target/recommendation-service.jar
az spring app deploy -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n hystrix-turbine --artifact-path hystrix-turbine/target/hystrix-turbine.jar
```

## Verify your apps
Get endpoint of app `user-service` and append test path.
```bash
echo $(az spring app show -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n user-service --query "properties.url" -o tsv)"/personalized/1"
```

After all the apps are running and discovered, access `user-service` with the path `https://yuchensp-user-service.azuremicroservices.io/personalized/1` from your browser.

You should get the following output if `user-service` can access `recommendation-service`. Otherwise please try refreshing the web page a few times.
Then you access `user-service` with the test path above via your browser. You should get the following output if `user-service` can access `recommendation-service`. Otherwise please try refreshing the web page again later.

```json
[{"name":"Product1","description":"Description1","detailsLink":"link1"},{"name":"Product2","description":"Description2","detailsLink":"link3"},{"name":"Product3","description":"Description3","detailsLink":"link3"}]
Expand All @@ -55,11 +79,17 @@ You should get the following output if `user-service` can access `recommendation
## Access your Hystrix dashboard and metrics stream

### Using public endpoints
Get the endpoint of app `hystrix-turbine` and append app path.
```bash
echo $(az spring app show -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n hystrix-turbine --query "properties.url" -o tsv)/hystrix
```

You can access `hystrix-turbine` with the path `https://<SERVICE-NAME>-hystrix-turbine.azuremicroservices.io/hystrix` from your browser, which shows the Hystrix dashboard running in this app.

Paste the Turbine stream url `https://<SERVICE-NAME>-hystrix-turbine.azuremicroservices.io/turbine.stream?cluster=default` and click Monitor Stream, and you will see the dashboard working. If you are not viewing anything, just hit the `user-service` endpoints to generate the streams.
Then you access `hystrix-turbine` through the path above in your browser. It shows the Hystrix dashboard running in this app.

Get Turbine stream URL below. Paste the URL and click Monitor Stream, and you will see the dashboard working. If you are not viewing anything, just hit the `user-service` endpoints to generate the streams.
```bash
echo $(az spring app show -g ${RESOURCE_GROUP} -s ${SPRING_APPS_SERVICE} -n hystrix-turbine --query "properties.url" -o tsv)/turbine.stream?cluster=default
```

You can now play with your Circuit Breaker Dashboard.

Expand All @@ -68,7 +98,14 @@ You can now play with your Circuit Breaker Dashboard.
### Using private test endpoints

Hystrix metrics streams are also accessible from test-endpoint. As a backend service, we didn't assign a public end-point for `recommendation-service`, let's show its metrics with test-endpoint at `https://primary:<KEY>@<SERVICE-NAME>.test.azuremicroservices.io/recommendation-service/default/actuator/hystrix.stream`.
Hystrix metrics streams are also accessible from test-endpoint. As a backend service, `recommendation-service` doesn't need a public end-point. You can get endpoint using command below.
```bash
echo $(az spring test-endpoint list -g ${RESOURCE_GROUP} -n ${SPRING_APPS_SERVICE} --app recommendation-service --query "primaryTestEndpoint" -o tsv)
```

If you need to show its metrics, you need to get full path using command below.
```bash
echo $(az spring test-endpoint list -g ${RESOURCE_GROUP} -n ${SPRING_APPS_SERVICE} --app recommendation-service --query "primaryTestEndpoint" -o tsv)/actuator/hystrix.stream
```

As a web app, Hystrix dashboard should also be working on test endpoint. However, it is not working properly for two reasons: First, using test endpoint will change the base URL from `/` to `/<APP-NAME>/<DEPLOYMENT-NAME>`. Second, the web app is using absolute path for static resource. To get it worked on test endpoint, you might need to manually edit the `<base>`in the front-end files.
As a web app, Hystrix dashboard should also be working on test endpoint. However, it is not working properly for two reasons: First, using test endpoint will change the base URL from `/` to `/<APP-NAME>/<DEPLOYMENT-NAME>`. Second, the web app is using absolute path for static resource. To get it worked on test endpoint, you might need to manually edit the `<base>`in the front-end files.
17 changes: 0 additions & 17 deletions hystrix-turbine-sample/hystrix-turbine/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions hystrix-turbine-sample/recommendation-service/.gitignore

This file was deleted.

7 changes: 7 additions & 0 deletions hystrix-turbine-sample/setup-env-variables-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export SUBSCRIPTION='subscription-id' # replace it with your subscription-id
export RESOURCE_GROUP='resource-group-name' # existing resource group or one that will be created in next steps
export SPRING_APPS_SERVICE='azure-spring-apps-name' # name of the service that will be created in the next steps

echo "SUBSCRIPTION=$SUBSCRIPTION"
echo "RESOURCE_GROUP=$RESOURCE_GROUP"
echo "SPRING_APPS_SERVICE=$SPRING_APPS_SERVICE"
17 changes: 0 additions & 17 deletions hystrix-turbine-sample/user-service/.gitignore

This file was deleted.

4 changes: 4 additions & 0 deletions java-8-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
Expand Down

0 comments on commit 71978bf

Please sign in to comment.