Replace service binding with Service Connector for MySQL, other assorted polishing (#182)
* Numerous fixes across the board in READMEs and code * Minor fixes from workshop * Replaced service binding with Service Connector for MySQL, other cleanup * Update README.md minor readme polishing --------- Co-authored-by: Sandra Ahlgrimm <sandra.kriemann@gmail.com>
This commit is contained in:
Родитель
51cd328102
Коммит
021394fc3c
|
@ -10,12 +10,12 @@ We'll use the reactive programming paradigm to build our microservice in this se
|
|||
|
||||
## Prepare the Azure Cosmos DB database
|
||||
|
||||
From Section 00, you should already have a CosmosDB account named `sclabc-<unique string>`.
|
||||
From Section 00, you should already have a Cosmos DB account named `sclabc-<unique string>`.
|
||||
|
||||
- Click on the "Data Explorer" menu item
|
||||
- Click on the `Data Explorer` menu item
|
||||
- Expand the container named `azure-spring-apps-cosmosdb`.
|
||||
- In that container, expand the container named `City`.
|
||||
- Click on "Items" and use the "New Item" button to create some sample items using the contents below:
|
||||
- Click on `Items` and use the `New Item` button to create some sample items using the contents below:
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -143,12 +143,12 @@ az spring app create -n city-service --runtime-version Java_17
|
|||
|
||||
Azure Spring Apps can automatically connect the Cosmos DB database we created to our microservice.
|
||||
|
||||
- Go to "Apps" in your Azure Spring Apps instance.
|
||||
- Go to `Apps` in your Azure Spring Apps instance.
|
||||
- Select the `city-service` application
|
||||
- Go to `Service Connector`
|
||||
- Click on `+ Create`
|
||||
- Choose `Cosmos DB` as the Service type
|
||||
- Give your Connection a name, for example `cosmos_city`
|
||||
- Give your Connection a name, for example "cosmos_city"
|
||||
- Select the `NoSQL` API type
|
||||
- Select the Cosmos DB account and Database we created in the initial 00 setup step
|
||||
- Verify that the Client type is `SpringBoot`
|
||||
|
@ -184,7 +184,7 @@ cd ..
|
|||
|
||||
## Test the project in the cloud
|
||||
|
||||
- Go to "Apps" in your Azure Spring Apps instance.
|
||||
- Go to `Apps` in your Azure Spring Apps instance.
|
||||
- Verify that `city-service` has a `Registration status` which says `1/1`. This shows that it is correctly registered in Spring Cloud Service Registry.
|
||||
- Select `city-service` to have more information on the microservice.
|
||||
- Copy/paste the "Test Endpoint" that is provided.
|
||||
|
|
Двоичные данные
06-build-a-reactive-spring-boot-microservice-using-cosmosdb/media/.DS_Store
поставляемый
Normal file
Двоичные данные
06-build-a-reactive-spring-boot-microservice-using-cosmosdb/media/.DS_Store
поставляемый
Normal file
Двоичный файл не отображается.
|
@ -58,25 +58,51 @@ echo "Your MySQL username is: ${MYSQL_USERNAME}"
|
|||
|
||||
```
|
||||
|
||||
## Bind the MySQL database to the application
|
||||
## Connect the MySQL database to the application
|
||||
|
||||
As we did for CosmosDB in the previous section, create a service binding for the MySQL database to make it available to Azure Spring Apps microservices.
|
||||
As we did for Cosmos DB in the previous section, create a Service Connector for the MySQL database to make it available to the `weather-service` microservice.
|
||||
In the [Azure Portal](https://portal.azure.com/?WT.mc_id=java-0000-judubois):
|
||||
|
||||
- Navigate to your Azure Spring Apps instance
|
||||
- Click on Apps
|
||||
- Click on `Apps`
|
||||
- Click on `weather-service`.
|
||||
- Click on "Service Bindings" and then on "Create service binding".
|
||||
- Populate the service binding fields as shown.
|
||||
- The username will be displayed in last line of output from the section above.
|
||||
- The password is the one you specified in section 0. The default value is `super$ecr3t`.
|
||||
- Click on `Create` to create the database binding
|
||||
- Click on `Service Connector` and then on `+ Create`.
|
||||
- Populate the Service Connector fields as shown:
|
||||
- For Service type, select `DB for MySQL single server`
|
||||
- Specify a connection name, e.g. "weatherdb"
|
||||
- Verify the correct subscription is shown
|
||||
- Choose the MySQL server created in the preceding steps
|
||||
- Select the MySQL database created earlier
|
||||
- Select `SpringBoot` as the Client type
|
||||
- Click the `Next: Authentication` button
|
||||
|
||||
![MySQL Service Binding](media/01-create-service-binding-mysql.png)
|
||||
![MySQL Service Connector, 1 of 5](media/01-create-service-connector-mysql.png)
|
||||
|
||||
- Verify `Connection string` is selected
|
||||
- Select `Continue with...Database credentials` and fill in Username and Password
|
||||
- The Username was echoed to the terminal as the last command executed earlier
|
||||
- The password is the one you specified in section 0. The default value is `super$ecr3t`.
|
||||
- Expand `Advanced` to visually inspect the injected Spring Data properties (optional)
|
||||
|
||||
![MySQL Service Connector, 2 of 5](media/02-create-service-connector-mysql.png)
|
||||
|
||||
- Review the properties automatically injected by the Service Connector to the `weather-service`
|
||||
- Click `Next: Networking`
|
||||
|
||||
![MySQL Service Connector, 3 of 5](media/03-create-service-connector-mysql.png)
|
||||
|
||||
- Verify that `Configure firewall rules to enable access to target service` is selected
|
||||
- Click on `Next: Review + Create`
|
||||
|
||||
![MySQL Service Connector, 4 of 5](media/04-create-service-connector-mysql.png)
|
||||
|
||||
- After receiving the "Validation passed" message, click the `Create` button to create the Service Connector
|
||||
|
||||
![MySQL Service Connector, 5 of 5](media/05-create-service-connector-mysql.png)
|
||||
|
||||
## Create a Spring Boot microservice
|
||||
|
||||
Now that we've provisioned the Azure Spring Apps instance and configured the service binding, let's get the code for `weather-service` ready. The microservice that we create in this guide is [available here](weather-service/).
|
||||
Now that we've provisioned the Azure Spring Apps instance and configured the Service Connector, let's get the code for `weather-service` ready. The microservice that we create in this guide is [available here](weather-service/).
|
||||
|
||||
To create our microservice, we will invoke the Spring Initalizr service from the command line:
|
||||
|
||||
|
|
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/.DS_Store
поставляемый
Normal file
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/.DS_Store
поставляемый
Normal file
Двоичный файл не отображается.
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 53 KiB |
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/01-create-service-connector-mysql.png
Normal file
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/01-create-service-connector-mysql.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 222 KiB |
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/02-create-service-connector-mysql.png
Normal file
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/02-create-service-connector-mysql.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 247 KiB |
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/03-create-service-connector-mysql.png
Normal file
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/03-create-service-connector-mysql.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 230 KiB |
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/04-create-service-connector-mysql.png
Normal file
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/04-create-service-connector-mysql.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 188 KiB |
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/05-create-service-connector-mysql.png
Normal file
Двоичные данные
07-build-a-spring-boot-microservice-using-mysql/media/05-create-service-connector-mysql.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 198 KiB |
Загрузка…
Ссылка в новой задаче