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, 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,22 +190,20 @@ 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 following parameters are used in the above Azure CLI command:
229
229
230
230
**resource-group*→ Use the same resource group name in which you created the web app, for example `msdocs-quarkus-postgres-webapp-rg`.
231
231
**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
-
232
+
**location*→ Use the same location used for the web app. Change to a different location if it doesn't work.
239
233
**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/).
234
+
**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/).
235
+
**tier*→ The compute tier of the server. For more information, see [Azure Database for PostgreSQL pricing](https://azure.microsoft.com/pricing/details/postgresql/server/).
236
+
**active-directory-auth*→`Enabled` to enable Microsoft Entra authentication.
241
237
242
238
1. Create a database named `fruits` within the PostgreSQL service with this command:
243
239
244
240
```azurecli-interactive
241
+
DB_NAME=fruits
245
242
az postgres flexible-server db create \
246
243
--resource-group $RESOURCE_GROUP \
247
244
--server-name $DB_SERVER_NAME \
248
-
--database-name fruits
245
+
--database-name $DB_NAME
249
246
```
250
247
251
248
1. Install the [Service Connector](../service-connector/overview.md) passwordless extension for the Azure CLI:
252
249
253
250
```azurecli-interactive
254
-
az extension add --name serviceconnector-passwordless --upgrade
251
+
az extension add --name serviceconnector-passwordless --upgrade --allow-preview true
255
252
```
256
253
257
254
1. Connect the database to the container app with a system-assigned managed identity, using the connection command.
258
255
259
256
```azurecli-interactive
260
257
az containerapp connection create postgres-flexible \
261
258
--resource-group $RESOURCE_GROUP \
262
-
--name my-container-app \
259
+
--name $APP_NAME \
263
260
--target-resource-group $RESOURCE_GROUP \
264
261
--server $DB_SERVER_NAME \
265
-
--database fruits \
266
-
--managed-identity
262
+
--database $DB_NAME \
263
+
--system-identity \
264
+
--container $APP_NAME
267
265
```
268
266
269
267
## 6. Review your changes
270
268
271
269
You can find the application URL(FQDN) by using the following command:
272
270
273
271
```azurecli-interactive
274
-
az containerapp list --resource-group $RESOURCE_GROUP
272
+
echo https://$(az containerapp show \
273
+
--name $APP_NAME \
274
+
--resource-group $RESOURCE_GROUP \
275
+
--query properties.configuration.ingress.fqdn \
276
+
-o tsv)
275
277
```
276
278
277
279
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