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
This tutorial shows you how create a Azure App Service Web app with Azure Database for PostgreSQL flexible server inside a [Virtual network](../../virtual-network/virtual-networks-overview.md).
21
+
This tutorial shows you how to create a Azure App Service Web app with Azure Database for PostgreSQL flexible server inside a [Virtual network](../../virtual-network/virtual-networks-overview.md).
22
22
23
-
In this tutorial you will learn how to:
23
+
In this tutorial you'll learn how to:
24
24
>[!div class="checklist"]
25
25
> * Create an Azure Database for PostgreSQL flexible server instance in a virtual network
26
26
> * Create a web app
@@ -30,8 +30,8 @@ In this tutorial you will learn how to:
30
30
## Prerequisites
31
31
32
32
- If you don't have an Azure subscription, create a [free](https://azure.microsoft.com/free/) account before you begin.
33
-
-[Install Azure CLI](/cli/azure/install-azure-cli).version 2.0 or later locally. To see the version installed, run the `az --version` command.
34
-
-Login to your account using the [az login](/cli/azure/authenticate-azure-cli) command. Note the **id** property from the command output for the corresponding subscription name.
33
+
-[Install Azure CLI](/cli/azure/install-azure-cli)version 2.0 or later locally (or use [Azure Cloud Shell](https://azure.microsoft.com/get-started/azure-portal/cloud-shell/) which has CLI preinstalled). To see the version installed, run the `az --version` command.
34
+
-Log in to your account using the [az login](/cli/azure/authenticate-azure-cli) command. Note the **id** property from the command output for the corresponding subscription name.
35
35
36
36
```azurecli
37
37
az login
@@ -53,22 +53,22 @@ This command performs the following actions, which may take a few minutes:
53
53
54
54
- Create the resource group if it doesn't already exist.
55
55
- Generates a server name if it's not provided.
56
-
-Create a new virtual network for your new Azure Database for PostgreSQL flexible server instance and subnet within this virtual network for the Azure Database for PostgreSQL flexible server instance.
57
-
- Creates admin username , password for your server if not provided.
58
-
- Creates an empty database called **postgres**
56
+
-Creates a virtual network and subnet for the Azure Database for PostgreSQL flexible server instance.
57
+
- Creates admin username and password for your server if not provided.
58
+
- Creates an empty database called **postgres**.
59
59
60
-
Here is the sample output.
60
+
Here's the sample output.
61
61
62
62
```json
63
-
Local context is turned on. Its information is saved in working directory /home/jane. You can run `az local-context off` to turn it off.
64
-
Command argument values from local context: --resource-group demoresourcegroup, --location: eastus
65
-
Checking the existence of the resource group ''...
66
-
Creating Resource group 'demoresourcegroup ' ...
67
-
Creating new vnet "demoappvnet" in resource group "demoresourcegroup" ...
68
-
Creating new subnet "Subnet095447391" in resource group "demoresourcegroup " and delegating it to "Microsoft.DBforPostgreSQL/flexibleServers"...
69
-
Creating Azure Database for PostgreSQL flexible server instance 'demoserverpostgres' in group 'demoresourcegroup'...
63
+
Creating Resource Group 'demoresourcegroup'...
64
+
Creating new Vnet "demoappvnet" in resource group "demoresourcegroup"
65
+
Creating new Subnet "Subnetdemoserverpostgres" in resource group "demoresourcegroup"
66
+
Creating a private dns zone demoserverpostgres.private.postgres.database.azure.com in resource group "demoresourcegroup"
67
+
Creating PostgreSQL Server 'demoserverpostgres' in group 'demoresourcegroup'...
70
68
Your server 'demoserverpostgres' is using sku 'Standard_D2s_v3' (Paid Tier). Please refer to https://aka.ms/postgres-pricing for pricing details
71
-
Make a note of your password. If you forget, you have to reset your password with 'az postgres flexible-server update -n demoserverpostgres --resource-group demoresourcegroup -p <new-password>'.
Make a note of your password. If you forget, you would have to reset your password with "az postgres flexible-server update -n demoserverpostgres -g demoresourcegroup -p <new-password>".
71
+
Try using 'az postgres flexible-server connect' command to test out connection.
In this section, you create app host in App Service app, connect this app to the Azure Database for PostgreSQL flexible server database, then deploy your code to that host. Make sure you're in the repository root of your application code in the terminal. Note Basic Plan does not support VNET integration. Please use Standard or Premium.
87
+
In this section, you create app host in App Service app, connect this app to the Azure Database for PostgreSQL flexible server database, then deploy your code to that host. Make sure you're in the repository root of your application code in the terminal. Note Basic Plan doesn't support VNET integration. Use Standard or Premium.
88
88
89
-
Create an App Service app (the host process) with the az webapp up command
89
+
Create an App Service app (the host process) with the az webapp up command.
90
90
91
91
```azurecli
92
92
az webapp up --resource-group demoresourcegroup --location westus2 --plan testappserviceplan --sku P2V2 --name mywebapp
## Configure environment variables to connect the database
127
-
With the code now deployed to App Service, the next step is to connect the app to the Azure Database for PostgreSQL flexible server instance in Azure. The app code expects to find database information in a number of environment variables. To set environment variables in App Service, use [az webapp config appsettings set](/cli/azure/webapp/config/appsettings#az-webapp-config-appsettings-set) command.
127
+
With the code now deployed to App Service, the next step is to connect the app to the Azure Database for PostgreSQL flexible server instance in Azure. The app code expects to find database information in many environment variables. To set environment variables in App Service, use [az webapp config appsettings set](/cli/azure/webapp/config/appsettings#az-webapp-config-appsettings-set) command.
128
128
129
129
130
130
```azurecli
@@ -134,7 +134,7 @@ az webapp config appsettings set --name mywebapp --settings DBHOST="<postgres-s
134
134
- Replace **postgres-server-name**,**username**,**password** for the newly created Azure Database for PostgreSQL flexible server instance command.
135
135
- Replace **\<username\>** and **\<password\>** with the credentials that the command also generated for you.
136
136
- The resource group and app name are drawn from the cached values in the .azure/config file.
137
-
- The command creates settings named **DBHOST**, **DBNAME**, **DBUSER***, and **DBPASS**. If your application code is using different name for the database information then use those names for the app settings as mentioned in the code.
137
+
- The command creates settings named **DBHOST**, **DBNAME**, **DBUSER***, and **DBPASS**. If your application code is using a different name for the database information, then use those names for the app settings as mentioned in the code.
138
138
139
139
Configure the web app to allow all outbound connections from within the virtual network.
0 commit comments