Skip to content

Commit f5b9583

Browse files
committed
update tab name
1 parent 1af84c5 commit f5b9583

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

articles/spring-apps/how-to-bind-postgres.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ms.custom: passwordless-java, devx-track-java
2020

2121
With Azure Spring Apps, you can bind select Azure services to your applications automatically, instead of having to configure your Spring Boot application manually. This article shows you how to bind your application to your Azure Database for PostgreSQL instance.
2222

23+
::: zone pivot="mysql-passwordless-flexible-server"
24+
2325
## Prerequisites
2426

2527
* An application deployed to Azure Spring Apps. For more information, see [Quickstart: Deploy your first application to Azure Spring Apps](./quickstart.md).
@@ -49,7 +51,7 @@ Use the following steps to prepare your project.
4951

5052
## Bind your app to the Azure Database for PostgreSQL instance
5153

52-
### [Service Connector for flexible server](#tab/Passwordlessflex)
54+
### [Passwordless](#tab/Passwordlessflex)
5355

5456
1. Install the [Service Connector](../service-connector/overview.md) passwordless extension for the Azure CLI:
5557

@@ -71,7 +73,64 @@ Use the following steps to prepare your project.
7173
--system-identity
7274
```
7375

74-
### [Service Connector for single server](#tab/Passwordlesssingle)
76+
### [Password](#tab/Secretsflex)
77+
78+
Use the following steps to bind your app using a secret.
79+
80+
1. Note the admin username and password of your Azure Database for PostgreSQL account.
81+
82+
1. Connect to the server, create a database named **testdb** from a PostgreSQL client, and then create a new non-admin account.
83+
84+
1. Run the following command to connect to the database with admin username and password.
85+
86+
```azurecli
87+
az spring connection create postgres-flexible \
88+
--resource-group $AZ_SPRING_APPS_RESOURCE_GROUP \
89+
--service $AZ_SPRING_APPS_SERVICE_INSTANCE_NAME \
90+
--app $APP_NAME \
91+
--deployment $DEPLOYMENT_NAME \
92+
--target-resource-group $POSTGRES_RESOURCE_GROUP \
93+
--server $POSTGRES_SERVER_NAME \
94+
--database $DATABASE_NAME \
95+
--secret name=$USERNAME secret=$PASSWORD
96+
```
97+
98+
---
99+
100+
::: zone-end
101+
102+
::: zone pivot="mysql-passwordless-single-server"
103+
104+
## Prerequisites
105+
106+
* An application deployed to Azure Spring Apps. For more information, see [Quickstart: Deploy your first application to Azure Spring Apps](./quickstart.md).
107+
* An Azure Database for PostgreSQL Single Server instance.
108+
* [Azure CLI](/cli/azure/install-azure-cli) version 2.45.0 or higher.
109+
110+
## Prepare your Java project
111+
112+
Use the following steps to prepare your project.
113+
114+
1. In your project's *pom.xml* file, add the following dependency:
115+
116+
```xml
117+
<dependency>
118+
<groupId>org.springframework.boot</groupId>
119+
<artifactId>spring-boot-starter-data-jpa</artifactId>
120+
</dependency>
121+
<dependency>
122+
<groupId>com.azure.spring</groupId>
123+
<artifactId>spring-cloud-azure-starter-jdbc-postgresql</artifactId>
124+
</dependency>
125+
```
126+
127+
1. In the *application.properties* file, remove any `spring.datasource.*` properties.
128+
129+
1. Update the current app by running `az spring app deploy`, or create a new deployment for this change by running `az spring app deployment create`.
130+
131+
## Bind your app to the Azure Database for PostgreSQL instance
132+
133+
### [Passwordless](#tab/PasswordlessSingle)
75134

76135
1. Install the [Service Connector](../service-connector/overview.md) passwordless extension for the Azure CLI:
77136

@@ -93,7 +152,7 @@ Use the following steps to prepare your project.
93152
--system-identity
94153
```
95154

96-
### [Service Connector with password](#tab/Secrets)
155+
### [Password](#tab/SecretsSingle)
97156

98157
Use the following steps to bind your app using a secret.
99158

@@ -117,6 +176,8 @@ Use the following steps to bind your app using a secret.
117176

118177
---
119178

179+
::: zone-end
180+
120181
## Next steps
121182

122183
In this article, you learned how to bind an application in Azure Spring Apps to an Azure Database for PostgreSQL instance. To learn more about binding services to an application, see [Bind an Azure Cosmos DB database to an application in Azure Spring Apps](./how-to-bind-cosmos.md).

0 commit comments

Comments
 (0)