You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -43,16 +42,25 @@ Create a resource group with the [az group create](/cli/azure/group#az-group-cre
43
42
The following example creates a resource group named `myResourceGroup` in the East US Azure region.
44
43
45
44
```azurecli-interactive
46
-
az group create --name myResourceGroup --location eastus
45
+
RESOURCE_GROUP="myResourceGroup"
46
+
LOCATION="eastus"
47
+
48
+
az group create --name $RESOURCE_GROUP --location $LOCATION
47
49
```
48
50
49
-
Create an Azure container registry instance using the [az acr create](/cli/azure/acr#az-acr-create) command. The registry name must be unique within Azure, contain 5-50 alphanumeric characters. All letters must be specified in lower case. In the following example, `mycontainerregistry007` is used. Update this to a unique value.
51
+
Create an Azure container registry instance using the [az acr create](/cli/azure/acr#az-acr-create) command and retrieve its login server using the [az acr show](/cli/azure/acr#az-acr-show) command. The registry name must be unique within Azure and contain 5-50 alphanumeric characters. All letters must be specified in lower case. In the following example, `mycontainerregistry007` is used. Update this to a unique value.
50
52
51
53
```azurecli-interactive
54
+
REGISTRY_NAME=mycontainerregistry007
52
55
az acr create \
53
-
--resource-group myResourceGroup \
54
-
--name mycontainerregistry007 \
56
+
--resource-group $RESOURCE_GROUP \
57
+
--name $REGISTRY_NAME \
55
58
--sku Basic
59
+
60
+
REGISTRY_SERVER=$(az acr show \
61
+
--name $REGISTRY_NAME \
62
+
--query 'loginServer' \
63
+
--output tsv | tr -d '\r')
56
64
```
57
65
58
66
## 3. Clone the sample app and prepare the container image
@@ -72,9 +80,9 @@ cd quarkus-quickstarts/hibernate-orm-panache-quickstart
### Build and push a Docker image to the container registry
147
150
148
151
1. Build the container image.
149
152
150
-
Run the following command to build the Quarkus app image. You must tag it with the fully qualified name of your registry login server. The login server name is in the format *\<registry-name\>.azurecr.io* (must be all lowercase), for example, *mycontainerregistry007.azurecr.io*. Replace the name with your own registry name.
153
+
Run the following command to build the Quarkus app image. You must tag it with the fully qualified name of your registry login server.
Before pushing container images, you must log in to the registry. To do so, use the [az acr login][az-acr-login] command. Specify only the registry resource name when signing in with the Azure CLI. Don't use the fully qualified login server name.
164
+
Before pushing container images, you must log in to the registry. To do so, use the [az acr login][az-acr-login] command.
160
165
161
166
```azurecli-interactive
162
-
az acr login --name <registry-name>
167
+
az acr login --name $REGISTRY_NAME
163
168
```
164
169
165
170
The command returns a `Login Succeeded` message once completed.
166
171
167
172
1. Push the image to the registry.
168
173
169
-
Use [docker push][docker-push] to push the image to the registry instance. Replace `mycontainerregistry007` with the login server name of your registry instance. This example creates the `quarkus-postgres-passwordless-app` repository, containing the `quarkus-postgres-passwordless-app:v1` image.
174
+
Use [docker push][docker-push] to push the image to the registry instance. This example creates the `quarkus-postgres-passwordless-app` repository, containing the `quarkus-postgres-passwordless-app:v1` image.
1. Create a Container Apps instance by running the following command. Make sure you replace the value of the environment variables with the actual name and location you want to use.
178
183
179
184
```azurecli-interactive
180
-
RESOURCE_GROUP="myResourceGroup"
181
-
LOCATION="eastus"
182
185
CONTAINERAPPS_ENVIRONMENT="my-environment"
183
186
184
187
az containerapp env create \
@@ -187,23 +190,24 @@ cd quarkus-quickstarts/hibernate-orm-panache-quickstart
187
190
--location $LOCATION
188
191
```
189
192
190
-
1. Create a container app with your app image by running the following command. Replace the placeholders with your values. To find the container registry admin account details, see [Authenticate with an Azure container registry](/azure/container-registry/container-registry-authentication)
193
+
1. Create a container app with your app image by running the following command:
> The options `--registry-username` and `--registry-password` are still supported but aren't recommended because using the identity system is more secure.
207
211
208
212
## 5. Create and connect a PostgreSQL database with identity connectivity
209
213
@@ -213,65 +217,69 @@ Next, create a PostgreSQL Database and configure your container app to connect t
> The options `--admin-user` and `--admin-password` are still supported but aren't recommended because using the identity system is more secure.
227
233
228
234
The following parameters are used in the above Azure CLI command:
229
235
230
-
**resource-group*→ Use the same resource group name in which you created the web app, for example `msdocs-quarkus-postgres-webapp-rg`.
236
+
**resource-group*→ Use the same resource group name in which you created the web app - for example,`msdocs-quarkus-postgres-webapp-rg`.
231
237
**name*→ The PostgreSQL database server name. This name must be **unique across all Azure** (the server endpoint becomes `https://<name>.postgres.database.azure.com`). Allowed characters are `A`-`Z`, `0`-`9`, and `-`. A good pattern is to use a combination of your company name and server identifier. (`msdocs-quarkus-postgres-webapp-db`)
232
-
**location*→ Use the same location used for the web app.
233
-
**admin-user*→ Username for the administrator account. It can't be `azure_superuser`, `admin`, `administrator`, `root`, `guest`, or `public`. For example, `demoadmin` is okay.
234
-
**admin-password*→ Password of the administrator user. It must contain 8 to 128 characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.
235
-
236
-
> [!IMPORTANT]
237
-
> When creating usernames or passwords **do not** use the `$` character. Later in this tutorial, you will create environment variables with these values where the `$` character has special meaning within the Linux container used to run Java apps.
238
-
238
+
**location*→ Use the same location used for the web app. Change to a different location if it doesn't work.
239
239
**public-access*→`None` which sets the server in public access mode with no firewall rules. Rules will be created in a later step.
240
-
**sku-name*→ The name of the pricing tier and compute configuration, for example `GP_Gen5_2`. For more information, see [Azure Database for PostgreSQL pricing](https://azure.microsoft.com/pricing/details/postgresql/server/).
240
+
**sku-name*→ The name of the pricing tier and compute configuration - for example, `Standard_B1ms`. For more information, see [Azure Database for PostgreSQL pricing](https://azure.microsoft.com/pricing/details/postgresql/server/).
241
+
**tier*→ The compute tier of the server. For more information, see [Azure Database for PostgreSQL pricing](https://azure.microsoft.com/pricing/details/postgresql/server/).
242
+
**active-directory-auth*→`Enabled` to enable Microsoft Entra authentication.
241
243
242
244
1. Create a database named `fruits` within the PostgreSQL service with this command:
243
245
244
246
```azurecli-interactive
247
+
DB_NAME=fruits
245
248
az postgres flexible-server db create \
246
249
--resource-group $RESOURCE_GROUP \
247
250
--server-name $DB_SERVER_NAME \
248
-
--database-name fruits
251
+
--database-name $DB_NAME
249
252
```
250
253
251
254
1. Install the [Service Connector](../service-connector/overview.md) passwordless extension for the Azure CLI:
252
255
253
256
```azurecli-interactive
254
-
az extension add --name serviceconnector-passwordless --upgrade
257
+
az extension add --name serviceconnector-passwordless --upgrade --allow-preview true
255
258
```
256
259
257
260
1. Connect the database to the container app with a system-assigned managed identity, using the connection command.
258
261
259
262
```azurecli-interactive
260
263
az containerapp connection create postgres-flexible \
261
264
--resource-group $RESOURCE_GROUP \
262
-
--name my-container-app \
265
+
--name $APP_NAME \
263
266
--target-resource-group $RESOURCE_GROUP \
264
267
--server $DB_SERVER_NAME \
265
-
--database fruits \
266
-
--managed-identity
268
+
--database $DB_NAME \
269
+
--system-identity \
270
+
--container $APP_NAME
267
271
```
268
272
269
273
## 6. Review your changes
270
274
271
275
You can find the application URL(FQDN) by using the following command:
272
276
273
277
```azurecli-interactive
274
-
az containerapp list --resource-group $RESOURCE_GROUP
278
+
echo https://$(az containerapp show \
279
+
--name $APP_NAME \
280
+
--resource-group $RESOURCE_GROUP \
281
+
--query properties.configuration.ingress.fqdn \
282
+
--output tsv)
275
283
```
276
284
277
285
When the new webpage shows your list of fruits, your app is connecting to the database using the managed identity. You should now be able to edit fruit list as before.
0 commit comments