├── .gitignore
├── .gitmodules
├── .prep
└── piggymetrics
│ ├── .scripts
│ ├── 02-deploy-apps-to-spring-cloud.sh
│ ├── 04-blue-green-deployment.sh
│ ├── setup-env-variables-azure.sh
│ └── setup-env-variables-development.sh
│ ├── account-service
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── resources
│ │ ├── application.yml
│ │ └── bootstrap.yml
│ ├── application.yml
│ ├── auth-service
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── resources
│ │ └── bootstrap.yml
│ ├── config
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── resources
│ │ ├── application.yml
│ │ └── shared
│ │ ├── account-service.yml
│ │ ├── application.yml
│ │ ├── auth-service.yml
│ │ ├── gateway.yml
│ │ ├── notification-service.yml
│ │ └── statistics-service.yml
│ ├── gateway
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── resources
│ │ ├── bootstrap.yml
│ │ └── static
│ │ └── images
│ │ └── userpic-new.jpg
│ ├── monitoring
│ └── src
│ │ └── main
│ │ └── resources
│ │ └── bootstrap.yml
│ ├── notification-service
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── resources
│ │ ├── application.yml
│ │ └── bootstrap.yml
│ ├── pom.xml
│ ├── registry
│ └── src
│ │ └── main
│ │ └── resources
│ │ └── bootstrap.yml
│ ├── statistics-service
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── resources
│ │ ├── application.yml
│ │ └── bootstrap.yml
│ └── turbine-stream-service
│ └── src
│ └── main
│ └── resources
│ └── bootstrap.yml
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── SECURITY.md
├── docs
├── create-application-insights.md
├── create-log-analytics.md
├── create-mongodb-and-rabbitmq.md
└── run-piggymetrics-locally.md
└── media
├── azure-spring-cloud-large.png
├── blue-green-deployment.jpg
├── create-application-insights-01.jpg
├── create-application-insights-02.jpg
├── create-application-insights-03.jpg
├── create-diagnostic-settings-01.jpg
├── create-diagnostic-settings-02.jpg
├── create-diagnostic-settings-03.jpg
├── create-diagnostic-settings-04.jpg
├── create-log-analytics-workspace-01.jpg
├── create-log-analytics-workspace-02.jpg
├── create-log-analytics-workspace-03.jpg
├── create-log-analytics-workspace-04.jpg
├── create-log-analytics-workspace-05.jpg
├── create-rabbitmq-on-azure-0.jpg
├── create-rabbitmq-on-azure-1-b.jpg
├── create-rabbitmq-on-azure-1.jpg
├── create-rabbitmq-on-azure-2.jpg
├── create-rabbitmq-on-azure-4.jpg
├── create-service-binding-using-portal.jpg
├── distributed-tracing.jpg
├── enable-distributed-tracing-using-app-insights.jpg
├── generate-personal-access-token.jpg
├── green-deployment.jpg
├── piggy-metrics-first-page.jpg
├── piggy-metrics-fourth-page.jpg
├── piggy-metrics-running-locally-01.jpg
├── piggy-metrics-running-locally-02.jpg
├── piggy-metrics-running-locally-03.jpg
├── piggy-metrics-second-page.jpg
├── piggy-metrics-third-page.jpg
├── piggymetrics-on-azure.jpg
├── rabbitmq-admin-console.jpg
├── spring-cloud-config-server-running-locally.jpg
├── spring-cloud-registry-running-locally-01.jpg
├── spring-cloud-registry-running-locally-02.jpg
├── view-logs-in-log-analytics-workspace.jpg
└── view-performance-in-app-insights.jpg
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
25 | # Intelli
26 | .idea/*
27 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "piggymetrics"]
2 | path = piggymetrics
3 | url = https://github.com/sqshq/piggymetrics.git
4 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/.scripts/02-deploy-apps-to-spring-cloud.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Deploy gateway app
4 |
5 | echo "az spring-cloud app deploy --name gateway \\
6 | --jar-path \${GATEWAY_JAR} \\
7 | --env CONFIG_SERVER_URI=\${CONFIG_SERVER_URI}"
8 |
9 | az spring-cloud app deploy --name gateway \
10 | --jar-path ${GATEWAY_JAR} \
11 | --env CONFIG_SERVER_URI=${CONFIG_SERVER_URI}
12 |
13 | read -n 1
14 |
15 | Deploy account-service app
16 |
17 | echo "az spring-cloud app deploy --name account-service \\
18 | --jar-path \${ACCOUNT_SERVICE_JAR} \\
19 | --env CONFIG_SERVER_URI=\${CONFIG_SERVER_URI} MONGODB_DATABASE=\${MONGODB_DATABASE} \\
20 | MONGODB_URI=\${MONGODB_URI} \\
21 | RABBITMQ_HOST=\${RABBITMQ_HOST} \\
22 | RABBITMQ_PORT=\${RABBITMQ_PORT} \\
23 | RABBITMQ_USERNAME=\${RABBITMQ_USERNAME} \\
24 | RABBITMQ_PASSWORD=\${RABBITMQ_PASSWORD}"
25 |
26 | az spring-cloud app deploy --name account-service \
27 | --jar-path ${ACCOUNT_SERVICE_JAR} \
28 | --env CONFIG_SERVER_URI=${CONFIG_SERVER_URI} MONGODB_DATABASE=${MONGODB_DATABASE} \
29 | MONGODB_URI=${MONGODB_URI} \
30 | RABBITMQ_HOST=${RABBITMQ_HOST} \
31 | RABBITMQ_PORT=${RABBITMQ_PORT} \
32 | RABBITMQ_USERNAME=${RABBITMQ_USERNAME} \
33 | RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
34 |
35 | read -n 1
36 |
37 | # Deploy auth-service app
38 |
39 | echo "az spring-cloud app deploy --name auth-service \\
40 | --jar-path \${AUTH_SERVICE_JAR} \\
41 | --env CONFIG_SERVER_URI=\${CONFIG_SERVER_URI} MONGODB_DATABASE=\${MONGODB_DATABASE} \\
42 | MONGODB_URI=\${MONGODB_URI}"
43 |
44 | az spring-cloud app deploy --name auth-service \
45 | --jar-path ${AUTH_SERVICE_JAR} \
46 | --env CONFIG_SERVER_URI=${CONFIG_SERVER_URI} MONGODB_DATABASE=${MONGODB_DATABASE} \
47 | MONGODB_URI=${MONGODB_URI}
48 |
49 | read -n 1
--------------------------------------------------------------------------------
/.prep/piggymetrics/.scripts/04-blue-green-deployment.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Create a green deployment
4 | echo "az spring-cloud app deployment create --name green --app gateway \\
5 | --jar-path \${GATEWAY_JAR} \\
6 | --env CONFIG_SERVER_URI=\${CONFIG_SERVER_URI}"
7 |
8 | az asc app deployment create --name green --app gateway \
9 | --jar-path ${GATEWAY_JAR} \
10 | --env CONFIG_SERVER_URI=${CONFIG_SERVER_URI}
11 |
12 | read -n 1
13 |
14 |
15 |
16 | # List deployments - there should be two
17 | echo "az spring-cloud app deployment list --app gateway"
18 | az spring-cloud app deployment list --app gateway
19 |
20 | read -n 1
21 |
22 | # Swap to green deployment
23 | echo "az spring-cloud app set-deployment \\
24 | --deployment green \\
25 | --name gateway"
26 |
27 | az spring-cloud app set-deployment \
28 | --deployment green \
29 | --name gateway
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/.scripts/setup-env-variables-azure.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # ====== Piggy Metrics Azure Coordinates
4 | export RESOURCE_GROUP=INSERT-your-resource-group-name
5 | export REGION=eastus
6 | export SPRING_CLOUD_SERVICE=INSERT-your-spring-cloud-service-name
7 |
8 | # ====== Piggy Metrics Environment Variables
9 | export CONFIG_SERVER_URI=http://config:8888
10 |
11 | # ====== Some fake passwords
12 | export ACCOUNT_SERVICE_PASSWORD=XUoJBrTtqXBonU5zMVzSUtrLPKRQztLUQE4poDoIR1QdcDfGgnGgJO5wbFC7xCEL
13 | export NOTIFICATION_SERVICE_PASSWORD=XUoJBrTtqXBonU5zMVzSUtrLPKRQztLUQE4poDoIR1QdcDfGgnGgJO5wbFC7xCEL
14 | export STATISTICS_SERVICE_PASSWORD=XUoJBrTtqXBonU5zMVzSUtrLPKRQztLUQE4poDoIR1QdcDfGgnGgJO5wbFC7xCEL
15 |
16 | export SMTP_USER=dev-user
17 | export SMTP_PASSWORD=dev-password
18 |
19 | # ====== Piggy Metrics Project JAR coordinates
20 | export ACCOUNT_SERVICE_JAR=account-service/target/account-service.jar
21 | export AUTH_SERVICE_JAR=auth-service/target/auth-service.jar
22 | export GATEWAY_JAR=gateway/target/gateway.jar
23 | export NOTIFICATION_SERVICE_JAR=notification-service/target/notification-service.jar
24 | export STATISTICS_SERVICE_JAR=statistics-service/target/statistics-service.jar
25 | export TURBINE_STREAM_SERVICE_JAR=turbine-stream-service/target/turbine-stream-service.jar
26 | export MONITORING_JAR=monitoring/target/monitoring.jar
27 |
28 | ## ===== Mongo DB
29 | export MONGODB_DATABASE=INSERT-your-mongodb-database-name
30 | export MONGODB_USER=INSERT-your-cosmosdb-account-name
31 | export MONGODB_URI="INSERT-your-mongodb-connection-string"
32 | export MONGODB_RESOURCE_ID=INSERT-your-mongodb-resource-id
33 |
34 | ## ===== Rabbit MQ
35 | export RABBITMQ_RESOURCE_GROUP=INSERT-your-rabbitmq-resource-group-name
36 | export VM_NAME=INSERT-your-rabbitmq-virtual-machine-name
37 | export ADMIN_USERNAME=INSERT-your-rabbitmq-admin-user-name
38 |
39 | # Rabbit MQ
40 | export RABBITMQ_HOST=INSERT-your-rabbitmq-host-public-ip-address
41 | export RABBITMQ_PORT=5672
42 | export RABBITMQ_USERNAME=INSERT-your-rabbitmq-username
43 | export RABBITMQ_PASSWORD=INSERT-your-rabbitmq-password
--------------------------------------------------------------------------------
/.prep/piggymetrics/.scripts/setup-env-variables-development.sh:
--------------------------------------------------------------------------------
1 | # Local development environment
2 | export CONFIG_SERVER_URI=http://localhost:8888
3 | export CONFIG_SERVICE_PASSWORD=some-password
4 | export NOTIFICATION_SERVICE_PASSWORD=some-password
5 | export STATISTICS_SERVICE_PASSWORD=some-password
6 | export SMTP_USER=dev-user
7 | export SMTP_PASSWORD=dev-password
8 |
9 | # MongoDB in Azure
10 | export MONGODB_HOST=INSERT-your-mongodb-host-name
11 | export MONGODB_PORT=10255
12 | export MONGODB_DATABASE=INSERT-your-mongodb-database-name
13 | export MONGODB_USER=INSERT-your-cosmosdb-account-name
14 | export MONGODB_PASSWORD=INSERT-your-mongodb-password
15 | export MONGODB_URI="insert-your-mongodb-connection-string"
16 |
17 | # Auth Service
18 | # Some fake password
19 | export ACCOUNT_SERVICE_PASSWORD=XUoJBrTtqXBonU5zMVzSUtrLPKRQztLUQE4poDoIR1QdcDfGgnGgJO5wbFC7xCEL
20 |
21 | # RabbitMQ in Azure
22 | export RABBITMQ_HOST=INSERT-your-rabbitmq-host-public-ip-address
23 | export RABBITMQ_PORT=5672
24 | export RABBITMQ_USERNAME=INSERT-your-rabbitmq-username
25 | export RABBITMQ_PASSWORD=INSERT-your-rabbitmq-password
--------------------------------------------------------------------------------
/.prep/piggymetrics/account-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | account-service
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | account-service
11 |
12 |
13 | com.piggymetrics
14 | piggymetrics
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 |
20 | org.springframework.cloud
21 | spring-cloud-starter-oauth2
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-security
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-config
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-web
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-openfeign
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-netflix-eureka-client
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-sleuth
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-data-mongodb
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-actuator
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-starter-bus-amqp
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-starter-netflix-hystrix
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-netflix-hystrix-stream
66 |
67 |
68 | org.springframework.boot
69 | spring-boot-starter-test
70 | test
71 |
72 |
73 | de.flapdoodle.embed
74 | de.flapdoodle.embed.mongo
75 | 1.50.3
76 | test
77 |
78 |
79 | com.jayway.jsonpath
80 | json-path
81 | 2.2.0
82 | test
83 |
84 |
85 |
86 |
87 |
88 |
89 | org.springframework.boot
90 | spring-boot-maven-plugin
91 |
92 | account-service
93 |
94 |
95 |
96 | org.jacoco
97 | jacoco-maven-plugin
98 | 0.7.6.201602180812
99 |
100 |
101 |
102 | prepare-agent
103 |
104 |
105 |
106 | report
107 | test
108 |
109 | report
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | dev
121 |
122 |
123 | env
124 | development
125 |
126 |
127 |
128 |
129 |
130 | cloud
131 |
132 |
133 | env
134 | cloud
135 |
136 |
137 |
138 |
139 | org.springframework.cloud
140 | spring-cloud-starter-zipkin
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/account-service/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | main:
3 | allow-bean-definition-overriding: true
--------------------------------------------------------------------------------
/.prep/piggymetrics/account-service/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: account-service
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/.prep/piggymetrics/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | config:
4 | server:
5 | git:
6 | uri: https://github.com/microsoft/piggymetrics-config.git
--------------------------------------------------------------------------------
/.prep/piggymetrics/auth-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | auth-service
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | auth-service
11 |
12 |
13 | com.piggymetrics
14 | piggymetrics
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-data-mongodb
22 |
23 |
24 | org.springframework.cloud
25 | spring-cloud-starter-config
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-security
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-oauth2
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-web
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-netflix-eureka-client
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-sleuth
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-test
50 | test
51 |
52 |
53 | de.flapdoodle.embed
54 | de.flapdoodle.embed.mongo
55 | 1.50.3
56 | test
57 |
58 |
59 | com.jayway.jsonpath
60 | json-path
61 | 2.2.0
62 | test
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.boot
70 | spring-boot-maven-plugin
71 |
72 | auth-service
73 |
74 |
75 |
76 | org.jacoco
77 | jacoco-maven-plugin
78 | 0.7.6.201602180812
79 |
80 |
81 |
82 | prepare-agent
83 |
84 |
85 |
86 | report
87 | test
88 |
89 | report
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | dev
101 |
102 |
103 | env
104 | development
105 |
106 |
107 |
108 |
109 |
110 | cloud
111 |
112 |
113 | env
114 | cloud
115 |
116 |
117 |
118 |
119 | org.springframework.cloud
120 | spring-cloud-starter-zipkin
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/auth-service/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: auth-service
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | config
7 | 1.0.0-SNAPSHOT
8 | jar
9 |
10 | config
11 | Configuration Server
12 |
13 |
14 | com.piggymetrics
15 | piggymetrics
16 | 1.0-SNAPSHOT
17 |
18 |
19 |
20 |
21 | org.springframework.cloud
22 | spring-cloud-config-server
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-security
27 |
28 |
29 |
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-maven-plugin
35 |
36 | config
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | config:
4 | server:
5 | native:
6 | search-locations: classpath:/shared
7 | profiles:
8 | active: native
9 | security:
10 | user:
11 | password: ${CONFIG_SERVICE_PASSWORD}
12 |
13 | server:
14 | port: 8888
15 |
16 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/shared/account-service.yml:
--------------------------------------------------------------------------------
1 | security:
2 | oauth2:
3 | client:
4 | clientId: account-service
5 | clientSecret: ${ACCOUNT_SERVICE_PASSWORD}
6 | accessTokenUri: http://localhost:5000/uaa/oauth/token
7 | grant-type: client_credentials
8 | scope: server
9 |
10 | spring:
11 | data:
12 | mongodb:
13 | database: ${MONGODB_DATABASE}
14 | uri: ${MONGODB_URI}
15 |
16 | server:
17 | servlet:
18 | context-path: /accounts
19 | port: 6000
20 |
21 | feign:
22 | hystrix:
23 | enabled: true
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/shared/application.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | org.springframework.security: INFO
4 |
5 | hystrix:
6 | command:
7 | default:
8 | execution:
9 | isolation:
10 | thread:
11 | timeoutInMilliseconds: 10000
12 |
13 | eureka:
14 | instance:
15 | prefer-ip-address: true
16 | client:
17 | serviceUrl:
18 | defaultZone: http://localhost:8761/eureka/
19 |
20 | security:
21 | oauth2:
22 | resource:
23 | user-info-uri: http://localhost:5000/uaa/users/current
24 |
25 | spring:
26 | rabbitmq:
27 | host: ${RABBITMQ_HOST}
28 | port: ${RABBITMQ_PORT}
29 | username: ${RABBITMQ_USERNAME}
30 | password: ${RABBITMQ_PASSWORD}
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/shared/auth-service.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | data:
3 | mongodb:
4 | database: ${MONGODB_DATABASE}
5 | uri: ${MONGODB_URI}
6 |
7 | server:
8 | servlet:
9 | context-path: /uaa
10 | port: 5000
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/shared/gateway.yml:
--------------------------------------------------------------------------------
1 | hystrix:
2 | command:
3 | default:
4 | execution:
5 | isolation:
6 | thread:
7 | timeoutInMilliseconds: 20000
8 |
9 | ribbon:
10 | ReadTimeout: 20000
11 | ConnectTimeout: 20000
12 |
13 | zuul:
14 | ignoredServices: '*'
15 | host:
16 | connect-timeout-millis: 20000
17 | socket-timeout-millis: 20000
18 |
19 | routes:
20 | auth-service:
21 | path: /uaa/**
22 | url: http://localhost:5000
23 | stripPrefix: false
24 | sensitiveHeaders:
25 |
26 | account-service:
27 | path: /accounts/**
28 | serviceId: account-service
29 | stripPrefix: false
30 | sensitiveHeaders:
31 |
32 | statistics-service:
33 | path: /statistics/**
34 | serviceId: statistics-service
35 | stripPrefix: false
36 | sensitiveHeaders:
37 |
38 | notification-service:
39 | path: /notifications/**
40 | serviceId: notification-service
41 | stripPrefix: false
42 | sensitiveHeaders:
43 |
44 | server:
45 | port: 4000
46 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/shared/notification-service.yml:
--------------------------------------------------------------------------------
1 | security:
2 | oauth2:
3 | client:
4 | clientId: notification-service
5 | clientSecret: ${NOTIFICATION_SERVICE_PASSWORD}
6 | accessTokenUri: http://localhost:5000/uaa/oauth/token
7 | grant-type: client_credentials
8 | scope: server
9 |
10 | server:
11 | servlet:
12 | context-path: /notifications
13 | port: 8000
14 |
15 | remind:
16 | cron: 0 0 0 * * *
17 | email:
18 | text: "Hey, {0}! We''ve missed you here on PiggyMetrics. It''s time to check your budget statistics.\r\n\r\nCheers,\r\nPiggyMetrics team"
19 | subject: PiggyMetrics reminder
20 |
21 | backup:
22 | cron: 0 0 12 * * *
23 | email:
24 | text: "Howdy, {0}. Your account backup is ready.\r\n\r\nCheers,\r\nPiggyMetrics team"
25 | subject: PiggyMetrics account backup
26 | attachment: backup.json
27 |
28 | spring:
29 | data:
30 | mongodb:
31 | database: ${MONGODB_DATABASE}
32 | uri: ${MONGODB_URI}
33 | mail:
34 | host: smtp.gmail.com
35 | port: 465
36 | username: dev-user
37 | password: dev-password
38 | properties:
39 | mail:
40 | smtp:
41 | auth: true
42 | socketFactory:
43 | port: 465
44 | class: javax.net.ssl.SSLSocketFactory
45 | fallback: false
46 | ssl:
47 | enable: true
48 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/config/src/main/resources/shared/statistics-service.yml:
--------------------------------------------------------------------------------
1 | security:
2 | oauth2:
3 | client:
4 | clientId: statistics-service
5 | clientSecret: ${STATISTICS_SERVICE_PASSWORD}
6 | accessTokenUri: http://localhost:5000/uaa/oauth/token
7 | grant-type: client_credentials
8 | scope: server
9 |
10 | spring:
11 | data:
12 | mongodb:
13 | database: ${MONGODB_DATABASE}
14 | uri: ${MONGODB_URI}
15 |
16 | server:
17 | servlet:
18 | context-path: /statistics
19 | port: 7000
20 |
21 | rates:
22 | url: https://api.exchangeratesapi.io
--------------------------------------------------------------------------------
/.prep/piggymetrics/gateway/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | gateway
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | gateway
11 |
12 |
13 | com.piggymetrics
14 | piggymetrics
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 |
20 | org.springframework.cloud
21 | spring-cloud-starter-netflix-zuul
22 |
23 |
24 | org.springframework.cloud
25 | spring-cloud-starter-config
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-netflix-eureka-client
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-sleuth
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-test
42 | test
43 |
44 |
45 |
46 |
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-maven-plugin
51 |
52 | ${project.name}
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | dev
62 |
63 |
64 | env
65 | development
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | cloud
74 |
75 |
76 | env
77 | cloud
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | org.springframework.cloud
86 | spring-cloud-starter-zipkin
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/gateway/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: gateway
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/.prep/piggymetrics/gateway/src/main/resources/static/images/userpic-new.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/.prep/piggymetrics/gateway/src/main/resources/static/images/userpic-new.jpg
--------------------------------------------------------------------------------
/.prep/piggymetrics/monitoring/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: monitoring
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/.prep/piggymetrics/notification-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | notification-service
7 | 1.0.0-SNAPSHOT
8 | jar
9 |
10 | notification-service
11 |
12 |
13 | com.piggymetrics
14 | piggymetrics
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 |
20 | org.springframework.cloud
21 | spring-cloud-starter-oauth2
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-security
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-config
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-web
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-openfeign
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-netflix-eureka-client
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-sleuth
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-data-mongodb
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-actuator
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-starter-bus-amqp
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-netflix-hystrix-stream
62 |
63 |
64 | org.springframework.boot
65 | spring-boot-starter-mail
66 |
67 |
68 |
69 | de.flapdoodle.embed
70 | de.flapdoodle.embed.mongo
71 | 1.50.3
72 | test
73 |
74 |
75 | com.jayway.jsonpath
76 | json-path
77 | 2.2.0
78 | test
79 |
80 |
81 | org.springframework.boot
82 | spring-boot-starter-test
83 | test
84 |
85 |
86 |
87 |
88 |
89 |
90 | org.springframework.boot
91 | spring-boot-maven-plugin
92 |
93 | notification-service
94 |
95 |
96 |
97 | org.jacoco
98 | jacoco-maven-plugin
99 | 0.7.6.201602180812
100 |
101 |
102 |
103 | prepare-agent
104 |
105 |
106 |
107 | report
108 | test
109 |
110 | report
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 | dev
122 |
123 |
124 | env
125 | development
126 |
127 |
128 |
129 |
130 |
131 | cloud
132 |
133 |
134 | env
135 | cloud
136 |
137 |
138 |
139 |
140 | org.springframework.cloud
141 | spring-cloud-starter-zipkin
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/notification-service/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | main:
3 | allow-bean-definition-overriding: true
--------------------------------------------------------------------------------
/.prep/piggymetrics/notification-service/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: notification-service
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/.prep/piggymetrics/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.piggymetrics
6 | piggymetrics
7 | 1.0-SNAPSHOT
8 | pom
9 | piggymetrics
10 |
11 |
12 | org.springframework.boot
13 | spring-boot-starter-parent
14 | 2.1.7.RELEASE
15 |
18 |
19 |
20 |
21 |
22 | UTF-8
23 | Greenwich.SR4
24 | 1.8
25 |
26 |
27 |
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-dependencies
32 | ${spring-cloud.version}
33 | pom
34 | import
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
45 |
46 |
47 | dev
48 |
49 |
50 | env
51 | development
52 |
53 |
54 |
55 |
56 |
57 | cloud
58 |
59 |
60 | env
61 | cloud
62 |
63 |
64 |
65 |
66 | com.microsoft.azure
67 | spring-cloud-starter-azure-spring-cloud-client
68 | 2.1.1
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | config
77 | monitoring
78 | registry
79 | gateway
80 | auth-service
81 | account-service
82 | statistics-service
83 | notification-service
84 | turbine-stream-service
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/registry/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: registry
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 | fail-fast: true
8 | password: ${CONFIG_SERVICE_PASSWORD}
9 | username: user
10 |
11 | eureka:
12 | instance:
13 | prefer-ip-address: true
14 | client:
15 | registerWithEureka: false
16 | fetchRegistry: false
17 | server:
18 | waitTimeInMsWhenSyncEmpty: 0
19 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/statistics-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | statistics-service
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | statistics-service
11 |
12 |
13 | com.piggymetrics
14 | piggymetrics
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-security
22 |
23 |
24 | org.springframework.cloud
25 | spring-cloud-starter-config
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-oauth2
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-web
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-openfeign
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-netflix-eureka-client
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-sleuth
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-data-mongodb
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-actuator
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-starter-bus-amqp
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-netflix-hystrix-stream
62 |
63 |
64 | com.google.guava
65 | guava
66 | 19.0
67 |
68 |
69 |
70 | org.springframework.boot
71 | spring-boot-starter-test
72 | test
73 |
74 |
75 | de.flapdoodle.embed
76 | de.flapdoodle.embed.mongo
77 | 1.50.3
78 | test
79 |
80 |
81 | com.jayway.jsonpath
82 | json-path
83 | 2.2.0
84 | test
85 |
86 |
87 |
88 |
89 |
90 |
91 | org.springframework.boot
92 | spring-boot-maven-plugin
93 |
94 | statistics-service
95 |
96 |
97 |
98 | org.jacoco
99 | jacoco-maven-plugin
100 | 0.7.6.201602180812
101 |
102 |
103 |
104 | prepare-agent
105 |
106 |
107 |
108 | report
109 | test
110 |
111 | report
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | dev
123 |
124 |
125 | env
126 | development
127 |
128 |
129 |
130 |
131 |
132 | cloud
133 |
134 |
135 | env
136 | cloud
137 |
138 |
139 |
140 |
141 | org.springframework.cloud
142 | spring-cloud-starter-zipkin
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/.prep/piggymetrics/statistics-service/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | main:
3 | allow-bean-definition-overriding: true
--------------------------------------------------------------------------------
/.prep/piggymetrics/statistics-service/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: statistics-service
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/.prep/piggymetrics/turbine-stream-service/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: turbine-stream-service
4 | cloud:
5 | config:
6 | uri: ${CONFIG_SERVER_URI}
7 |
8 | ---
9 |
10 | spring:
11 | profiles: development
12 | cloud:
13 | config:
14 | fail-fast: true
15 | password: ${CONFIG_SERVICE_PASSWORD}
16 | username: user
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | page_type: sample
3 | languages:
4 | - java
5 | products:
6 | - Azure Spring Cloud
7 | description: "End-to-end experience for Spring Cloud micro service apps in Azure Spring Cloud"
8 | urlFragment: "azure-spring-cloud"
9 | ---
10 |
11 | # End-to-end experience - Azure Spring Cloud
12 |
13 | This guide walks you through how to deploy and manage Spring Cloud micro services on Azure.
14 |
15 |
34 | 
35 |
36 | ## What will you experience
37 |
38 | You will:
39 | - Build Piggymetrics - build a proof-of-concept application, which demonstrates
40 | micro service architecture pattern using Spring Boot and Spring Cloud
41 | - Create Mongodb and RabbitMQ on Azure
42 | - Run Piggymetrics locally
43 | - Create Azure Spring Cloud
44 | - Deploy Piggymetrics to Azure Spring Cloud
45 | - Bind micro service apps to Azure Cosmos DB - MongoDB
46 | - Troubleshoot micro service apps in Azure Spring Cloud
47 | - Rapidly deploy changes to Azure Spring Cloud without any disruption - blue-green deployments
48 | - Scale out micro service apps in Azure Spring Cloud
49 |
50 | ## What you will need
51 |
52 | In order to deploy a Java Web app to cloud, you need
53 | an Azure subscription. If you do not already have an Azure
54 | subscription, you can activate your
55 | [MSDN subscriber benefits](https://azure.microsoft.com/pricing/member-offers/msdn-benefits-details/)
56 | or sign up for a
57 | [free Azure account]((https://azure.microsoft.com/pricing/free-trial/)).
58 |
59 | In addition, you will need the following:
60 |
61 | | [Azure CLI](http://docs.microsoft.com/cli/azure/overview)
62 | | [Java 8](https://www.azul.com/downloads/azure-only/zulu)
63 | | [Maven 3](http://maven.apache.org/)
64 | | [Git](https://github.com/)
65 | |
66 |
67 | If you have not yet signed up for the Azure Spring Cloud private
68 | preview, please sign up by providing your contact details at:
69 | [https://aka.ms/spring-cloud](https://aka.ms/spring-cloud).
70 |
71 | ## IMPORTANT - Start Here
72 |
73 | Clone this GitHub repo and prep:
74 | ```bash
75 | git clone --recurse-submodules https://github.com/Azure-Samples/azure-spring-cloud.git
76 |
77 | cd azure-spring-cloud
78 |
79 | yes | cp -rf .prep/* .
80 | ```
81 |
82 | ## Build Piggymetrics - Spring Cloud micro service apps
83 |
84 | Build Piggymetrics:
85 | ```bash
86 |
87 | cd piggymetrics
88 |
89 | mvn clean package -DskipTests -Denv=development
90 | ```
91 |
92 | ## Create MongoDB and RabbitMQ
93 |
94 | You can create MongoDB and RabbitMQ on Azure by following steps outlined [here](./docs/create-mongodb-and-rabbitmq.md)
95 | and capture MongoDB and RabbitMQ coordinates and credentials in
96 | `setup-env-variables-development.sh`
97 | and `setup-env-variables-azure.sh`.
98 |
99 | ## Run Piggymetrics locally
100 |
101 | You can use multiple console terminals and start micro service apps - see
102 | [how to run Piggymetrics locally](./docs/run-piggymetrics-locally.md) ...
103 |
104 | ## Create Azure Spring Cloud
105 |
106 | ### Install the Azure Spring Cloud extension
107 |
108 | ```bash
109 | # Login to Azure, if not already logged in
110 | az login
111 |
112 | # Install Azure Spring Cloud CLI extension
113 | az extension add spring-cloud
114 | ```
115 |
116 | ### Create Azure Spring Cloud
117 |
118 | Prep the dev environment by populating environment variables in
119 | `piggymetrics/.scripts/setup-env-variables-azure.sh`
120 | bash script:
121 |
122 | ```bash
123 | # ====== Piggy Metrics Azure Coordinates
124 | export RESOURCE_GROUP=INSERT-your-resource-group-name
125 | export REGION=eastus
126 | export SPRING_CLOUD_SERVICE=INSERT-your-spring-cloud-service-name
127 |
128 | ## ===== Mongo DB
129 | export MONGODB_DATABASE=INSERT-your-mongodb-database-name
130 | export MONGODB_USER=INSERT-your-cosmosdb-account-name
131 | export MONGODB_URI="INSERT-your-mongodb-connection-string"
132 | export MONGODB_RESOURCE_ID=INSERT-your-mongodb-resource-id
133 |
134 | ## ===== Rabbit MQ
135 | export RABBITMQ_RESOURCE_GROUP=INSERT-your-rabbitmq-resource-group-name
136 | export VM_NAME=INSERT-your-rabbitmq-virtual-machine-name
137 | export ADMIN_USERNAME=INSERT-your-rabbitmq-admin-user-name
138 |
139 | # Rabbit MQ
140 | export RABBITMQ_HOST=INSERT-your-rabbitmq-host-public-ip-address
141 | export RABBITMQ_PORT=5672
142 | export RABBITMQ_USERNAME=INSERT-your-rabbitmq-username
143 | export RABBITMQ_PASSWORD=INSERT-your-rabbitmq-password
144 | ```
145 |
146 | Then, export these environment variables from the `
147 | azure-spring-cloud/piggymetrics` directory:
148 |
149 | ```bash
150 | cd piggymetrics
151 |
152 | source .scripts/setup-env-variables-azure.sh
153 | ```
154 |
155 | Create an Azure Spring Cloud service instance using Azure CLI:
156 | ```bash
157 | # Create a Resource Group, if you have not created one
158 | az group create --name ${RESOURCE_GROUP} \
159 | --location ${REGION}
160 |
161 | # Create Azure Spring Cloud
162 | az spring-cloud create --name ${SPRING_CLOUD_SERVICE} \
163 | --resource-group ${RESOURCE_GROUP} \
164 | --location ${REGION}
165 | ```
166 |
167 | ### Configure defaults in your development machine
168 |
169 | You can set defaults so that you do not have to repeatedly mention
170 | resource group, location and service name in your subsequent calls to
171 | Azure Spring Cloud:
172 | ```bash
173 | # Configure defaults
174 | az configure --defaults \
175 | group=${RESOURCE_GROUP} \
176 | location=${REGION} \
177 | spring-cloud=${SPRING_CLOUD_SERVICE}
178 | ```
179 |
180 | ## Deploy Piggymetrics to Azure Spring Cloud
181 |
182 | ### Load Spring Cloud Config Server
183 |
184 | A Piggymetrics config repo is in the Microsoft GitHub Organization.
185 | `application.yml` file in the `Piggymetrics` directory carries coordinates
186 | for this repo.
187 |
188 | ```yaml
189 | # Contents of application.yml
190 | spring:
191 | cloud:
192 | config:
193 | server:
194 | git:
195 | uri: https://github.com/microsoft/piggymetrics-config.git
196 | ```
197 |
198 | You can load config from this GitHub repo:
199 | ```bash
200 | az spring-cloud config-server set \
201 | --config-file application.yml \
202 | --name ${SPRING_CLOUD_SERVICE}
203 | ```
204 |
205 | ### Create first set of apps
206 | You can create apps in the Azure Spring Cloud service instance:
207 | ```bash
208 | # Create the first app
209 | az spring-cloud app create --name gateway --instance-count 1 --is-public true
210 | ```
211 |
212 | Note down the publicly accessible URL for the gateway app. It is the URL for
213 | reaching the Piggymetrics app, for example, see the value of "url" below:
214 | ```json
215 | {
216 | "id": "/subscriptions/685ba005-af8d-4b04-8f16-a7bf38b2eb5a/resourceGroups/spring-cloud-0918/providers/Microsoft.AppPlatform/Spring/piggymetrics-0918/apps/gateway",
217 | "name": "gateway",
218 | "properties": {
219 | "activeDeploymentName": "default",
220 | "createdTime": "2019-09-18T05:33:12.354000+00:00",
221 | "persistentDisk": null,
222 | "provisioningState": "Succeeded",
223 | "public": true,
224 | "temporaryDisk": null,
225 | "url": "https://piggymetrics-0918-gateway.azureapps.io"
226 | },
227 | "resourceGroup": "spring-cloud-0918",
228 | "type": "Microsoft.AppPlatform/Spring/apps"
229 | }
230 | ```
231 |
232 | ```bash
233 | # Create 2 more apps
234 | az spring-cloud app create --name account-service --instance-count 1
235 | az spring-cloud app create --name auth-service --instance-count 1
236 |
237 | # Create another 2 apps
238 | az spring-cloud app create --name statistics-service --instance-count 1
239 | az spring-cloud app create --name notification-service --instance-count 1
240 | ```
241 |
242 | ### Deploy Spring Cloud micro service apps
243 | Build Spring Cloud micro service apps for cloud:
244 | ```bash
245 | mvn clean package -DskipTests -Denv=cloud
246 | ...
247 | ...
248 | [INFO] --- spring-boot-maven-plugin:2.1.7.RELEASE:repackage (repackage) @ turbine-stream-service ---
249 | [INFO] Replacing main artifact with repackaged archive
250 | [INFO] ------------------------------------------------------------------------
251 | [INFO] Reactor Summary:
252 | [INFO]
253 | [INFO] piggymetrics ....................................... SUCCESS [ 0.228 s]
254 | [INFO] config ............................................. SUCCESS [ 4.513 s]
255 | [INFO] monitoring ......................................... SUCCESS [ 0.685 s]
256 | [INFO] registry ........................................... SUCCESS [ 0.543 s]
257 | [INFO] gateway ............................................ SUCCESS [ 1.693 s]
258 | [INFO] auth-service ....................................... SUCCESS [ 2.053 s]
259 | [INFO] account-service .................................... SUCCESS [ 1.814 s]
260 | [INFO] statistics-service ................................. SUCCESS [ 1.769 s]
261 | [INFO] notification-service ............................... SUCCESS [ 1.484 s]
262 | [INFO] turbine-stream-service ............................. SUCCESS [ 1.220 s]
263 | [INFO] ------------------------------------------------------------------------
264 | [INFO] BUILD SUCCESS
265 | [INFO] ------------------------------------------------------------------------
266 | [INFO] Total time: 16.648 s
267 | [INFO] Finished at: 2019-09-18T07:23:01-07:00
268 | [INFO] Final Memory: 103M/777M
269 | [INFO] ------------------------------------------------------------------------
270 |
271 | ```
272 |
273 | You can deploy Spring Cloud micro service apps to Azure:
274 | ```bash
275 | # Deploy gateway app
276 | az spring-cloud app deploy --name gateway \
277 | --jar-path ${GATEWAY_JAR}
278 |
279 | # Deploy account-service app
280 | az spring-cloud app deploy --name account-service \
281 | --jar-path ${ACCOUNT_SERVICE_JAR} \
282 | --env MONGODB_DATABASE=${MONGODB_DATABASE} \
283 | MONGODB_URI=${MONGODB_URI} \
284 | RABBITMQ_HOST=${RABBITMQ_HOST} \
285 | RABBITMQ_PORT=${RABBITMQ_PORT} \
286 | RABBITMQ_USERNAME=${RABBITMQ_USERNAME} \
287 | RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
288 |
289 | # Deploy auth-service app
290 | az spring-cloud app deploy --name auth-service \
291 | --jar-path ${AUTH_SERVICE_JAR} \
292 | --env MONGODB_DATABASE=${MONGODB_DATABASE} \
293 | MONGODB_URI=${MONGODB_URI}
294 |
295 | # Deploy statistics-service app
296 | az spring-cloud app deploy --name statistics-service \
297 | --jar-path ${STATISTICS_SERVICE_JAR} \
298 | --env MONGODB_DATABASE=${MONGODB_DATABASE} \
299 | MONGODB_URI=${MONGODB_URI} \
300 | RABBITMQ_HOST=${RABBITMQ_HOST} \
301 | RABBITMQ_PORT=${RABBITMQ_PORT} \
302 | RABBITMQ_USERNAME=${RABBITMQ_USERNAME} \
303 | RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
304 |
305 | # Deploy notification-service app
306 | az spring-cloud app deploy --name notification-service \
307 | --jar-path ${NOTIFICATION_SERVICE_JAR} \
308 | --env MONGODB_DATABASE=${MONGODB_DATABASE} \
309 | MONGODB_URI=${MONGODB_URI} \
310 | RABBITMQ_HOST=${RABBITMQ_HOST} \
311 | RABBITMQ_PORT=${RABBITMQ_PORT} \
312 | RABBITMQ_USERNAME=${RABBITMQ_USERNAME} \
313 | RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
314 | ```
315 |
316 | Open Azure Portal and you can see the three microservice application deployed:
317 | 
318 |
319 | Open the Piggymetrics landing page by using the `gateway` app public uri,
320 | for example:
321 |
322 | 
323 |
324 | 
325 |
326 | 
327 |
328 | 
329 |
330 | ## Bind micro service apps to Azure Cosmos DB - MongoDB
331 |
332 | You can bind micro service apps to any Azure data, cache, messaging or directory service.
333 | For Piggymetrics, you can bind a micro service app to a Cosmos DB - Mongo DB instance using Azure CLI:
334 | ```bash
335 | az spring-cloud app binding cosmos add \
336 | --app account-service \
337 | --name mongodb \
338 | --api-type mongo \
339 | --resource-id ${MONGODB_RESOURCE_ID} \
340 | --database-name ${MONGODB_DATABASE}
341 | ```
342 |
343 | Also, you can bind micro service apps to any Azure data, cache, messaging or directory service using
344 | the Azure Portal, see:
345 | 
346 |
347 | ## Troubleshooting micro service apps in Azure Spring Cloud
348 |
349 | With out-of-the-box support for aggregating logs, metrics, and
350 | distributed app traces into Azure Monitor, you can easily visualize
351 | how your applications are performing, detect and diagnose issues
352 | across microservice applications and their dependencies, drill
353 | into monitoring data for troubleshooting and gain better
354 | understanding of what end-users do with your apps.
355 |
356 | ### Debug in development machine
357 | You can run Spring Cloud Config, Spring Cloud Service Registry,
358 | Spring Cloud Gateway and other Spring Cloud components on their dev machine.
359 | You can attach debuggers to Spring Cloud micro service apps and step through them. You can
360 | look at logs and metrics. Use Java Flight Recorder, etc.
361 |
362 | ### Stream logs from micro service apps in cloud to development machines
363 | You can stream logs from an app to your development machine using Azure CLI, like:
364 | ```bash
365 | az spring-cloud app logs --name gateway -f
366 | az spring-cloud app logs --name account-service -f
367 | az spring-cloud app logs --name auth-service -f
368 | az spring-cloud app logs --name notification-service -f
369 | az spring-cloud app logs --name statistics-service -f
370 |
371 | ```
372 |
373 | ### Use aggregated logs and metrics in Azure Log Analytics
374 |
375 | You can aggregate logs in Azure Log Analytics and retrieve them
376 | using Kusto queries. If you do not have a Log Analytics Workspace in Azure,
377 | see [how to create a Log Analytics Workspace](./docs/create-log-analytics.md)
378 |
379 | Create a diagnostic setting using the Common Diagnostic Settings page:
380 | 
381 | Configure "Send to Log Analytics" and check for all the available logs
382 | and metrics:
383 | 
384 | Diagnostic Settings should look like this:
385 | 
386 |
387 | You can then view logs using Kusto queires in the logs blade of your Azure Spring Cloud instance:
388 | 
389 |
390 | Here are some sample Kusto queries for viewing logs for each of the micro service apps:
391 | ```sql
392 | AppPlatformLogsforSpring
393 | | where AppName == "gateway"
394 | | limit 500
395 | | order by TimeGenerated asc
396 | | project TimeGenerated, Log
397 |
398 |
399 | AppPlatformLogsforSpring
400 | | where AppName == "account-service"
401 | | limit 500
402 | | order by TimeGenerated asc
403 | | project TimeGenerated, Log
404 |
405 |
406 | AppPlatformLogsforSpring
407 | | where AppName == "auth-service"
408 | | limit 500
409 | | order by TimeGenerated asc
410 | | project TimeGenerated, Log
411 | ```
412 |
413 | ### Use Application Insights to monitor your micro service apps
414 |
415 | You can use Application Insights to monitor your live web application. It will
416 | automatically detect performance anomalies. It includes powerful analytics tools to
417 | help you diagnose issues and to understand what users actually do with your app. It is designed to
418 | help you continuously improve performance and usability.
419 |
420 | If you do not have an instance of Application Insights, see
421 | [how to create Application Insights](./docs/create-application-insights.md).
422 |
423 | Enable distributed tracing for your micro service apps by using the Distributed Tracing blade in
424 | your Azure Spring Cloud instance:
425 | 
426 |
427 | Allow some time, then you can see distributed tracing:
428 | 
429 |
430 | You can also view the performance and call drill downs in the App Insights view:
431 | 
432 |
433 | ## Rapidly deploy changes to Azure Spring Cloud without any disruption - blue-green deployments
434 |
435 | Let's make some visual changes to the app:
436 | ```bash
437 | pushd gateway/src/main/resources/static/images
438 |
439 | # Change the icon
440 | mv userpic.jpg userpic-old.jpg
441 | mv userpic-new.jpg userpic.jpg
442 |
443 | # Move to project directory
444 | popd
445 |
446 | # Rebuild for the cloud in the project directory
447 | mvn clean package -DskipTests -Denv=cloud
448 | ```
449 |
450 | ### Create a green deployment
451 | ```bash
452 | az spring-cloud app deployment create --name green --app gateway \
453 | --jar-path ${GATEWAY_JAR}
454 | ```
455 |
456 | ### List deployments and verify that there are two
457 | ```bash
458 | az spring-cloud app deployment list --app gateway
459 | ```
460 |
461 | ### Swap to green deployment
462 | ```bash
463 | az spring-cloud app set-deployment \
464 | --deployment green \
465 | --name gateway
466 | ```
467 |
468 | Open the Piggymetrics landing page by using the `gateway` app public uri, you should now see the new icon
469 | for example:
470 | 
471 |
472 | In the Azure portal, you can see how the green deployment became effective:
473 | 
474 |
475 | ## Scale out micro service apps in Azure Spring Cloud
476 |
477 | You can easily scale out micro service apps in Azure Spring Cloud:
478 | ```bash
479 | az spring-cloud app scale --name gateway --instance-count 4
480 | ```
481 |
482 | ## Spring Cloud Service Registry and Spring Cloud Config Server Notes
483 |
484 | Service Registry and Config Server apps should not be deployed as Piggymetrics will not work properly if you deploy those apps. Because, there will be serviceId conflict as Azure provides its own fully managed [Spring Cloud Service Registry and Spring Cloud Config Server services](https://docs.microsoft.com/en-us/azure/spring-cloud/spring-cloud-service-registration).
485 |
486 | To use own Eurek Discovery server (including Eureka UI) you should deploy Dockerised app to Azure see
487 | [https://github.com/azure-samples/java-on-aks](https://github.com/azure-samples/java-on-aks).
488 |
489 | ## Congratulations
490 |
491 | Congratulations!!
492 |
493 | You built, deployed, scaled out and setup monitoring for Spring Cloud micro service apps
494 | using Spring Boot and Spring Cloud, Azure Spring Cloud, Azure Monitor, Log Analytics and
495 | Application Insights -- without worrying about provisioning or managing the underlying infrastructure or
496 | app lifecycle or monitoring or troubleshooting or etc.
497 |
498 | ## Resources
499 |
500 | - [Azure Spring Cloud](https://azure.microsoft.com/en-us/services/spring-cloud/)
501 | - [Azure Spring Cloud docs](https://docs.microsoft.com/en-us/azure/java/)
502 | - [Kusto Query Language](https://docs.microsoft.com/en-us/azure/kusto/query/)
503 | - [Triage Microservice Applications using Application Map](https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-map)
504 | - [Azure for Java Cloud Developers](https://docs.microsoft.com/en-us/azure/java/)
505 | - [Spring Cloud Azure](https://cloud.spring.io/spring-cloud-azure/)
506 | - [Spring Cloud](https://spring.io/projects/spring-cloud)
507 | - ...
508 |
509 | ## Contributing
510 |
511 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
512 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
513 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
514 |
515 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide
516 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
517 | provided by the bot. You will only need to do this once across all repos using our CLA.
518 |
519 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
520 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
521 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
522 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | 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/).
6 |
7 | 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.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to the Microsoft Security Response Center at [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://technet.microsoft.com/en-us/security/dn606155).
12 |
13 | 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).
14 |
15 | 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:
16 |
17 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
18 | * Full paths of source file(s) related to the manifestation of the issue
19 | * The location of the affected source code (tag/branch/commit or direct URL)
20 | * Any special configuration required to reproduce the issue
21 | * Step-by-step instructions to reproduce the issue
22 | * Proof-of-concept or exploit code (if possible)
23 | * Impact of the issue, including how an attacker might exploit the issue
24 |
25 | This information will help us triage your report more quickly.
26 |
27 | ## Preferred Languages
28 |
29 | We prefer all communications to be in English.
30 |
31 | ## Policy
32 |
33 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
34 |
35 |
--------------------------------------------------------------------------------
/docs/create-application-insights.md:
--------------------------------------------------------------------------------
1 | # How to create Application Insights
2 |
3 | This guide walks you through how to create an Application Insights
4 | instance in Azure.
5 |
6 | ## Create an Application Insights instance
7 |
8 | Open the Azure Portal and start:
9 |
10 | 
11 |
12 | 
13 |
14 | 
15 |
16 | ## Resources
17 |
18 | - [Create Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource)
19 |
20 | Go back to [how to use the Azure Spring Cloud service end to end?](https://github.com/azure-samples/azure-spring-cloud)
--------------------------------------------------------------------------------
/docs/create-log-analytics.md:
--------------------------------------------------------------------------------
1 | # How to create Log Analytics
2 |
3 | This guide walks you through how to create a Log Analytics workspace
4 | in Azure.
5 |
6 | ## Create a Log Analytics Workspace
7 |
8 | Open the Azure Portal and start:
9 |
10 | 
11 |
12 | 
13 |
14 | ## Resources
15 |
16 | - [Create a Log Analytics Workspace using Azure Portal](https://docs.microsoft.com/en-us/azure/azure-monitor/learn/quick-create-workspace)
17 |
18 | Go back to [how to use the Azure Spring Cloud service end to end?](https://github.com/azure-samples/azure-spring-cloud)
--------------------------------------------------------------------------------
/docs/create-mongodb-and-rabbitmq.md:
--------------------------------------------------------------------------------
1 | # Create MongoDB and RabbitMQ in Azure
2 |
3 | This guide will walk you through HOW to create MongoDB and RabbitMQ in Azure.
4 |
5 | ## Prep the dev environment
6 |
7 | Prep the dev environment by populating environment variables in
8 | `piggymetrics/.scripts/setup-env-variables-azure.sh`
9 | bash script:
10 |
11 | ```bash
12 | # ====== Piggy Metrics Azure Coordinates
13 | export RESOURCE_GROUP=INSERT-your-resource-group-name
14 | export REGION=eastus
15 | export SPRING_CLOUD_SERVICE=INSERT-your-spring-cloud-service-name
16 |
17 | ## ===== Mongo DB
18 | export MONGODB_DATABASE=INSERT-your-mongodb-database-name
19 | export MONGODB_USER=INSERT-your-cosmosdb-account-name
20 |
21 | ## ===== Rabbit MQ
22 | export RABBITMQ_RESOURCE_GROUP=INSERT-your-rabbitmq-resource-group-name
23 | export VM_NAME=INSERT-your-rabbitmq-virtual-machine-name
24 | export ADMIN_USERNAME=INSERT-your-rabbitmq-admin-user-name
25 | ```
26 |
27 | Then export these environment variables from the
28 | `azure-spring-cloud/piggymetrics' directory:
29 |
30 | ```bash
31 | pwd
32 | /Users/selvasingh/GitHub/selvasingh/azure-spring-cloud/piggymetrics
33 |
34 | source .scripts/setup-env-variables-azure.sh
35 | ```
36 |
37 | ## Create MongoDB
38 | Create an instance of MongoDB:
39 | ```bash
40 | # Change directory
41 | cd piggymetrics
42 |
43 | # Login into Azure
44 | az login
45 |
46 | # Create a Resource Group
47 | az group create --name ${RESOURCE_GROUP} \
48 | --location ${REGION}
49 |
50 | # Create a Cosmos DB account
51 | az cosmosdb create --kind MongoDB \
52 | --resource-group ${RESOURCE_GROUP} \
53 | --name ${MONGODB_USER}
54 | ```
55 | Cut and paste the resource `'id'` value from Azure CLI response into `setup-env-variables-development.sh` and
56 | `setup-env-variables-azure.sh`, say for example:
57 |
58 | ```bash
59 | "id": "/subscriptions/685ba005-af8d-4b04-8f16-a7bf38b2eb5a/resourceGroups/spring-cloud-0918/providers/Microsoft.DocumentDB/databaseAccounts/ ...
60 | ```
61 |
62 | ```bash
63 | # Get Cosmos DB connection strings
64 | az cosmosdb list-connection-strings --resource-group ${RESOURCE_GROUP} \
65 | --name ${MONGODB_USER}
66 | ```
67 | Cut and paste the primary connection string as `MONGODB_URI` in `setup-env-variables-azure.sh` bash file.
68 |
69 | ## Create RabbitMQ
70 |
71 | Create an instance of Bitnami RabbitMQ Stack For Microsoft Azure, go to
72 | [https://portal.azure.com/#blade/Microsoft_Azure_Marketplace/MarketplaceOffersBlade/selectedMenuItemId/home/searchQuery/rabbitmq](https://portal.azure.com/#blade/Microsoft_Azure_Marketplace/MarketplaceOffersBlade/selectedMenuItemId/home/searchQuery/rabbitmq)
73 | and start:
74 |
75 | 
76 |
77 | Fill in the form, use the same value as `RABBITMQ_RESOURCE_GROUP`,
78 | `VM_NAME` and `ADMIN_USERNAME`, and choose SSH. Select 'Standard DS3 v2' as
79 | the size:
80 | 
81 |
82 | Accept defaults:
83 | 
84 |
85 | Accept defaults:
86 | 
87 |
88 | Accept defaults in all subsequent screens, and proceed to create:
89 | 
90 |
91 | 
92 |
93 | Open RabbitMQ client and administration ports:
94 | ```bash
95 | # https://docs.bitnami.com/azure/infrastructure/rabbitmq/get-started/understand-default-config/
96 | az vm open-port --port 5672 --name ${VM_NAME} \
97 | --resource-group ${RABBITMQ_RESOURCE_GROUP}
98 | az vm open-port --port 15672 --name ${VM_NAME} \
99 | --resource-group ${RABBITMQ_RESOURCE_GROUP} --priority 1100
100 | ```
101 |
102 | Find the public IP address of the Linux virtual machine where RabbitMQ is running and
103 | and set the `RABBITMQ_HOST` environment variable in
104 | `piggymetrics/.scripts/setup-env-variables-azure.sh`:
105 | ```bash
106 | # Open an SSH connection, say
107 | # First, export the environment variables
108 | source .scripts/setup-env-variables-azure.sh
109 | # Open an SSH connection
110 | ssh selvasingh@${RABBITMQ_HOST}
111 | ```
112 |
113 | You can adjust RabbitMQ to connect with clients from a different machine:
114 | ```bash
115 | # https://docs.bitnami.com/azure/infrastructure/rabbitmq/administration/control-services/
116 | sudo /opt/bitnami/ctlscript.sh status
117 |
118 | # Stop RabbitMQ
119 | sudo /opt/bitnami/ctlscript.sh stop
120 |
121 | # Edit RabbitMQ configurtion file
122 | # https://docs.bitnami.com/azure/infrastructure/rabbitmq/administration/connect-remotely/
123 | # https://github.com/rabbitmq/rabbitmq-server/blob/master/docs/rabbitmq.config.example
124 | sudo nano /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq.config
125 |
126 | # Particularly, change line 4 from
127 | {tcp_listeners, [{"127.0.0.1", 5672}, {"::1", 5672}]},
128 | # TO
129 | {tcp_listeners, [{"0.0.0.0", 5672}, {"::1", 5672}]},
130 |
131 | # Start RabbitMQ
132 | sudo /opt/bitnami/ctlscript.sh start
133 | ```
134 |
135 | You can get your RabbitMQ admin credentials by following the steps in
136 | [https://docs.bitnami.com/azure/faq/get-started/find-credentials/](https://docs.bitnami.com/azure/faq/get-started/find-credentials/).
137 | Particularly, open a file in the SSH terminal
138 |
139 | ```bash
140 | cat ./bitnami_credentials
141 | ```
142 |
143 | Note down the credentials and close the SSH connections. Onto your local
144 | development machine ...
145 |
146 | From the `bitnami_credentials` file, populate the credentials in
147 | the `piggymetrics/.scripts/setup-env-variables-azure.sh` file
148 | and export them to the environment:
149 | ```bash
150 | # Rabbit MQ
151 | export RABBITMQ_USERNAME=INSERT-your-rabbitmq-username
152 | export RABBITMQ_PASSWORD=INSERT-your-rabbitmq-password
153 |
154 | # export them
155 | source .scripts/setup-env-variables-azure.sh
156 | ```
157 |
158 |
159 | You should be able to reach the RabbitMQ admin console at:
160 | ```bash
161 | open http://${RABBITMQ_HOST}:15672
162 | ```
163 |
164 | 
165 |
166 | ## Re-prep the local dev environment
167 |
168 | Re-prep the dev environment by populating environment variables in
169 | `piggymetrics/.scripts/setup-env-variables-azure.sh` and
170 | `piggymetrics/.scripts/setup-env-variables-development.sh`
171 | bash scripts:
172 |
173 | ```bash
174 | # ====== Piggy Metrics Azure Coordinates
175 | export RESOURCE_GROUP=INSERT-your-resource-group-name
176 | export REGION=eastus
177 | export SPRING_CLOUD_SERVICE=INSERT-your-spring-cloud-service-name
178 |
179 | ## ===== Mongo DB
180 | export MONGODB_DATABASE=INSERT-your-mongodb-database-name
181 | export MONGODB_USER=INSERT-your-cosmosdb-account-name
182 | export MONGODB_URI="INSERT-your-mongodb-connection-string"
183 | export MONGODB_RESOURCE_ID=INSERT-your-mongodb-resource-id
184 |
185 | ## ===== Rabbit MQ
186 | export RABBITMQ_RESOURCE_GROUP=INSERT-your-rabbitmq-resource-group-name
187 | export VM_NAME=INSERT-your-rabbitmq-virtual-machine-name
188 | export ADMIN_USERNAME=INSERT-your-rabbitmq-admin-user-name
189 |
190 | # Rabbit MQ
191 | export RABBITMQ_HOST=INSERT-your-rabbitmq-host-public-ip-address
192 | export RABBITMQ_PORT=5672
193 | export RABBITMQ_USERNAME=INSERT-your-rabbitmq-username
194 | export RABBITMQ_PASSWORD=INSERT-your-rabbitmq-password
195 |
196 | ```
197 |
198 | Go back to [how to use the Azure Spring Cloud service end to end?](https://github.com/azure-samples/azure-spring-cloud)
--------------------------------------------------------------------------------
/docs/run-piggymetrics-locally.md:
--------------------------------------------------------------------------------
1 | # How to run Piggymetrics locally
2 |
3 | This guide will walk you through how to run the Piggymetrics microservice apps
4 | locally on a development machine.
5 |
6 | ## Setup the local environment
7 |
8 | ```bash
9 |
10 | cd piggymetrics
11 | source .scripts/setup-env-variables-development.sh
12 |
13 | ```
14 |
15 | ## Build Piggymetrics and for running locally
16 |
17 | Build it using the Maven `development` profile:
18 |
19 | ```bash
20 | mvn clean package -DskipTests -Denv=development
21 | ```
22 |
23 | ## Start Spring Cloud Config Server
24 |
25 | Open a new console and run Spring Cloud Config Server:
26 |
27 | ```bash
28 | # Change directory to the config module
29 | cd piggymetrics/config
30 | # Setup environment variables
31 | source ../.scripts/setup-env-variables-development.sh
32 | # Run
33 | mvn spring-boot:run
34 | ```
35 |
36 | You can validate that a Spring Cloud Config Server is up and running by
37 | invoking its REST API.
38 |
39 | The Spring Cloud Config Server REST API has resources in the following form:
40 |
41 | ```bash
42 | /{application}/{profile}[/{label}]
43 | /{application}-{profile}.yml
44 | /{label}/{application}-{profile}.yml
45 | /{application}-{profile}.properties
46 | /{label}/{application}-{profile}.properties
47 | ```
48 |
49 | Try:
50 | ```bash
51 | open http://localhost:8888/gateway/profile
52 | open http://localhost:8888/account-service/profile
53 | open http://localhost:8888/statistics-service/profile
54 | open http://localhost:8888/notification-service/profile
55 | ...
56 | open http://localhost:8888/notification-service/profile/development
57 | ...
58 |
59 | ```
60 |
61 | 
62 |
63 | You may also try:
64 | ```bash
65 | open http://localhost:8888/auth-service/profile
66 | ```
67 |
68 | ## Start Spring Cloud Service Registry
69 |
70 | Open a new console and run Spring Cloud Service Registry:
71 |
72 | ```bash
73 | # Change directory to the registry module
74 | cd piggymetrics/registry
75 | # Setup environment variables
76 | source ../.scripts/setup-env-variables-development.sh
77 | # Run
78 | mvn spring-boot:run -Dspring.profiles.active=development
79 | ```
80 |
81 | You can validate that a Spring Cloud Service Registry is up and running by
82 | opening the Service Registry Dashboard:
83 |
84 | ```bash
85 | open http://localhost:8761/
86 | ```
87 |
88 | 
89 |
90 | ## Start Spring Cloud Gateway
91 |
92 | Open a new console and run Spring Cloud Service Registry:
93 |
94 | ```bash
95 | # Change directory to the gateway module
96 | cd piggymetrics/gateway
97 | # Setup environment variables
98 | source ../.scripts/setup-env-variables-development.sh
99 | # Run
100 | mvn spring-boot:run -Dspring.profiles.active=development
101 | ```
102 |
103 | ## Start `account-service`
104 |
105 | Open a new console and run `account-service`:
106 |
107 | ```bash
108 | # Change directory to the account-service module
109 | cd piggymetrics/account-service
110 | # Setup environment variables
111 | source ../.scripts/setup-env-variables-development.sh
112 | # Run
113 | mvn spring-boot:run -Dspring.profiles.active=development
114 | ```
115 |
116 | ## Start `auth-service`
117 |
118 | Open a new console and run `auth-service`:
119 |
120 | ```bash
121 | # Change directory to the auth-service module
122 | cd piggymetrics/auth-service
123 | # Setup environment variables
124 | source ../.scripts/setup-env-variables-development.sh
125 | # Run
126 | mvn spring-boot:run -Dspring.profiles.active=development
127 | ```
128 |
129 | ## Start `statistics-service`
130 |
131 | Open a new console and run `statistics-service`:
132 |
133 | ```bash
134 | # Change directory to the statistics-service module
135 | cd piggymetrics/statistics-service
136 | # Setup environment variables
137 | source ../.scripts/setup-env-variables-development.sh
138 | # Run
139 | mvn spring-boot:run -Dspring.profiles.active=development
140 | ```
141 |
142 | ## Start `notification-service`
143 |
144 | Open a new console and run `notification-service`:
145 |
146 | ```bash
147 | # Change directory to the notification-service module
148 | cd piggymetrics/notification-service
149 | # Setup environment variables
150 | source ../.scripts/setup-env-variables-development.sh
151 | # Run
152 | mvn spring-boot:run -Dspring.profiles.active=development
153 | ```
154 |
155 | ## Validate that microservice apps are running
156 |
157 | You can validate that a Spring Cloud Service Registry and multiple
158 | microservice apps are up and running by
159 | opening the Service Registry Dashboard:
160 |
161 | ```bash
162 | open http://localhost:8761/
163 | ```
164 |
165 | 
166 |
167 | Open the Piggymetrics app:
168 |
169 | ```bash
170 | open http://localhost:4000/
171 | ```
172 |
173 | 
174 |
175 | 
176 |
177 | 
178 |
179 | ## Congratulations !!
180 |
181 | Go back to [how to use the Azure Spring Cloud service end to end?](https://github.com/azure-samples/azure-spring-cloud)
182 |
--------------------------------------------------------------------------------
/media/azure-spring-cloud-large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/azure-spring-cloud-large.png
--------------------------------------------------------------------------------
/media/blue-green-deployment.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/blue-green-deployment.jpg
--------------------------------------------------------------------------------
/media/create-application-insights-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-application-insights-01.jpg
--------------------------------------------------------------------------------
/media/create-application-insights-02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-application-insights-02.jpg
--------------------------------------------------------------------------------
/media/create-application-insights-03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-application-insights-03.jpg
--------------------------------------------------------------------------------
/media/create-diagnostic-settings-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-diagnostic-settings-01.jpg
--------------------------------------------------------------------------------
/media/create-diagnostic-settings-02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-diagnostic-settings-02.jpg
--------------------------------------------------------------------------------
/media/create-diagnostic-settings-03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-diagnostic-settings-03.jpg
--------------------------------------------------------------------------------
/media/create-diagnostic-settings-04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-diagnostic-settings-04.jpg
--------------------------------------------------------------------------------
/media/create-log-analytics-workspace-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-log-analytics-workspace-01.jpg
--------------------------------------------------------------------------------
/media/create-log-analytics-workspace-02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-log-analytics-workspace-02.jpg
--------------------------------------------------------------------------------
/media/create-log-analytics-workspace-03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-log-analytics-workspace-03.jpg
--------------------------------------------------------------------------------
/media/create-log-analytics-workspace-04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-log-analytics-workspace-04.jpg
--------------------------------------------------------------------------------
/media/create-log-analytics-workspace-05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-log-analytics-workspace-05.jpg
--------------------------------------------------------------------------------
/media/create-rabbitmq-on-azure-0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-rabbitmq-on-azure-0.jpg
--------------------------------------------------------------------------------
/media/create-rabbitmq-on-azure-1-b.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-rabbitmq-on-azure-1-b.jpg
--------------------------------------------------------------------------------
/media/create-rabbitmq-on-azure-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-rabbitmq-on-azure-1.jpg
--------------------------------------------------------------------------------
/media/create-rabbitmq-on-azure-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-rabbitmq-on-azure-2.jpg
--------------------------------------------------------------------------------
/media/create-rabbitmq-on-azure-4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-rabbitmq-on-azure-4.jpg
--------------------------------------------------------------------------------
/media/create-service-binding-using-portal.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/create-service-binding-using-portal.jpg
--------------------------------------------------------------------------------
/media/distributed-tracing.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/distributed-tracing.jpg
--------------------------------------------------------------------------------
/media/enable-distributed-tracing-using-app-insights.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/enable-distributed-tracing-using-app-insights.jpg
--------------------------------------------------------------------------------
/media/generate-personal-access-token.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/generate-personal-access-token.jpg
--------------------------------------------------------------------------------
/media/green-deployment.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/green-deployment.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-first-page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-first-page.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-fourth-page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-fourth-page.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-running-locally-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-running-locally-01.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-running-locally-02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-running-locally-02.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-running-locally-03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-running-locally-03.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-second-page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-second-page.jpg
--------------------------------------------------------------------------------
/media/piggy-metrics-third-page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggy-metrics-third-page.jpg
--------------------------------------------------------------------------------
/media/piggymetrics-on-azure.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/piggymetrics-on-azure.jpg
--------------------------------------------------------------------------------
/media/rabbitmq-admin-console.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/rabbitmq-admin-console.jpg
--------------------------------------------------------------------------------
/media/spring-cloud-config-server-running-locally.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/spring-cloud-config-server-running-locally.jpg
--------------------------------------------------------------------------------
/media/spring-cloud-registry-running-locally-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/spring-cloud-registry-running-locally-01.jpg
--------------------------------------------------------------------------------
/media/spring-cloud-registry-running-locally-02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/spring-cloud-registry-running-locally-02.jpg
--------------------------------------------------------------------------------
/media/view-logs-in-log-analytics-workspace.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/view-logs-in-log-analytics-workspace.jpg
--------------------------------------------------------------------------------
/media/view-performance-in-app-insights.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/azure-spring-cloud/c5163a8c28adb7bc90e2058ee33054ec7753c4b7/media/view-performance-in-app-insights.jpg
--------------------------------------------------------------------------------