Skip to content

Commit 8a64e2c

Browse files
authored
Merge pull request #275163 from maud-lv/ml-sc-deprecatedcommands
Update deprecated commands
2 parents 12af492 + 6d6a113 commit 8a64e2c

File tree

2 files changed

+8
-152
lines changed

2 files changed

+8
-152
lines changed

articles/service-connector/tutorial-django-webapp-postgres-cli.md

Lines changed: 5 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,17 @@ author: maud-lv
77
ms.author: malev
88
ms.service: service-connector
99
ms.topic: tutorial
10-
ms.date: 11/22/2023
11-
zone_pivot_groups: postgres-server-options
10+
ms.date: 05/13/2024
1211
---
1312
# Tutorial: Using Service Connector to build a Django app with Postgres on Azure App Service
1413

1514
> [!NOTE]
16-
> You are using Service Connector that makes it easier to connect your web app to database service in this tutorial. The tutorial here is a modification of the [App Service tutorial](../app-service/tutorial-python-postgresql-app.md) to use this feature so you will see similarities. Look into section [Configure environment variables to connect the database](#configure-environment-variables-to-connect-the-database) in this tutorial to see where Service Connector comes into play and simplifies the connection process given in the App Service tutorial.
15+
> In this tutorial, you use Service Connector that simplifies the process of connecting a web app to a database service. This tutorial is a modification of the [App Service tutorial](../app-service/tutorial-python-postgresql-app.md), so you may see some similarities. Look into section [Configure environment variables to connect the database](#configure-environment-variables-to-connect-the-database) to see where Service Connector comes into play and simplifies the connection process given in the App Service tutorial.
1716
18-
::: zone pivot="postgres-single-server"
19-
20-
This tutorial shows how to deploy a data-driven Python [Django](https://www.djangoproject.com/) web app to [Azure App Service](overview.md) and connect it to an Azure Database for a Postgres database. You can also try the PostgreSQL Flexible Server by selecting the option above. Flexible Server provides a simpler deployment mechanism and lower ongoing costs.
17+
This tutorial shows how to deploy a data-driven Python [Django](https://www.djangoproject.com/) web app to [Azure App Service](overview.md) and connect it to an [Azure Database for PostgreSQL Flexible server](../postgresql/flexible-server/index.yml) database.
2118

2219
In this tutorial, you use the Azure CLI to complete the following tasks:
2320

24-
> [!div class="checklist"]
25-
> * Set up your initial environment with Python and the Azure CLI
26-
> * Create an Azure Database for PostgreSQL database
27-
> * Deploy code to Azure App Service and connect to PostgreSQL
28-
> * Update your code and redeploy
29-
> * View diagnostic logs
30-
> * Manage the web app in the Azure portal
31-
32-
:::zone-end
33-
34-
::: zone pivot="postgres-flexible-server"
35-
36-
This tutorial shows how to deploy a data-driven Python [Django](https://www.djangoproject.com/) web app to [Azure App Service](overview.md) and connect it to an [Azure Database for PostgreSQL Flexible server](../postgresql/flexible-server/index.yml) database. If you can't use PostgreSQL Flexible server, then select the Single Server option above.
37-
38-
In this tutorial, you'll use the Azure CLI to complete the following tasks:
39-
4021
> [!div class="checklist"]
4122
> * Set up your initial environment with Python and the Azure CLI
4223
> * Create an Azure Database for PostgreSQL Flexible server database
@@ -45,12 +26,6 @@ In this tutorial, you'll use the Azure CLI to complete the following tasks:
4526
> * View diagnostic logs
4627
> * Manage the web app in the Azure portal
4728
48-
:::zone-end
49-
50-
## Prerequisites
51-
52-
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/).
53-
5429
## Set up your initial environment
5530

5631
1. Install [Python 3.8 or higher](https://www.python.org/downloads/). To check if your Python version is 3.8 or higher, run the following code in a terminal window:
@@ -95,26 +70,18 @@ Navigate into the following folder:
9570
cd serviceconnector-webapp-postgresql-django
9671
```
9772

98-
::: zone pivot="postgres-flexible-server"
99-
10073
Use the flexible-server branch of the sample, which contains a few necessary changes, such as how the database server URL is set and adding `'OPTIONS': {'sslmode': 'require'}` to the Django database configuration as required by Azure PostgreSQL Flexible server.
10174

10275
```terminal
10376
git checkout flexible-server
10477
```
10578

106-
::: zone-end
107-
10879
### [Download](#tab/download)
10980

11081
Visit [https://github.com/Azure-Samples/djangoapp](https://github.com/Azure-Samples/djangoapp).
11182

112-
::: zone pivot="postgres-flexible-server"
113-
11483
For Flexible server, select the branches control that says "master" and then select the **flexible-server** branch.
11584

116-
::: zone-end
117-
11885
Select **Code**, and then select **Download ZIP**.
11986

12087
Unpack the ZIP file into a folder named *djangoapp*.
@@ -136,64 +103,6 @@ Having issues? [Let us know](https://aka.ms/DjangoCLITutorialHelp).
136103
137104
## Create Postgres database in Azure
138105
139-
::: zone pivot="postgres-single-server"
140-
141-
<!-- > [!NOTE]
142-
> Before you create an Azure Database for PostgreSQL server, check which [compute generation](../postgresql/concepts-pricing-tiers.md#compute-generations-and-vcores) is available in your region. -->
143-
144-
1. Enable parameters caching with the Azure CLI so you don't need to provide those parameters with every command. (Cached values are saved in the *.azure* folder.)
145-
146-
```azurecli
147-
az config param-persist on
148-
```
149-
150-
1. Install the `db-up` extension for the Azure CLI:
151-
152-
```azurecli
153-
az extension add --name db-up
154-
```
155-
156-
If the `az` command isn't recognized, be sure you have the Azure CLI installed as described in [Set up your initial environment](#set-up-your-initial-environment).
157-
158-
1. Create the Postgres database in Azure with the [`az postgres up`](/cli/azure/postgres#az-postgres-up) command:
159-
160-
```azurecli
161-
az postgres up --resource-group ServiceConnector-tutorial-rg --location eastus --sku-name B_Gen5_1 --server-name <postgres-server-name> --database-name pollsdb --admin-user <admin-username> --admin-password <admin-password> --ssl-enforcement Enabled
162-
```
163-
164-
Replace the following placeholder texts with your own data:
165-
166-
* **Replace** *`<postgres-server-name>`* with a name that's **unique across all Azure** (the server endpoint becomes `https://<postgres-server-name>.postgres.database.azure.com`). A good pattern is to use a combination of your company name and another unique value.
167-
168-
* For *`<admin-username>`* and *`<admin-password>`*, specify credentials to create an administrator user for this Postgres server. The admin username can't be *azure_superuser*, *azure_pg_admin*, *admin*, *administrator*, *root*, *guest*, or *public*. It can't start with *pg_*. The password must contain **8 to 128 characters** from three of the following categories: English uppercase letters, English lowercase letters, numbers (0 through 9), and non-alphanumeric characters (for example, *!*, *#*, *%*). The password can't contain a username.
169-
* Don't use the `$` character in the username or password. You'll later create environment variables with these values where the `$` character has special meaning within the Linux container used to run Python apps.
170-
* The `*B_Gen5_1*` (Basic, Gen5, 1 core) [pricing tier](../postgresql/concepts-pricing-tiers.md) used here is the least expensive. For production databases, omit the `--sku-name` argument to use the GP_Gen5_2 (General Purpose, Gen 5, 2 cores) tier instead.
171-
172-
This command performs the following actions, which may take a few minutes:
173-
174-
* Create a [resource group](../azure-resource-manager/management/overview.md#terminology) called `ServiceConnector-tutorial-rg`, if it doesn't already exist.
175-
* Create a Postgres server named by the `--server-name` argument.
176-
* Create an administrator account using the `--admin-user` and `--admin-password` arguments. You can omit these arguments to allow the command to generate unique credentials for you.
177-
* Create a `pollsdb` database as named by the `--database-name` argument.
178-
* Enable access from your local IP address.
179-
* Enable access from Azure services.
180-
* Create a database user with access to the `pollsdb` database.
181-
182-
You can do all the steps separately with other `az postgres` and `psql` commands, but `az postgres up` does all the steps together.
183-
184-
When the command completes, it outputs a JSON object that contains different connection strings for the database along with the server URL, a generated user name (such as "joyfulKoala@msdocs-djangodb-12345"), and a GUID password.
185-
186-
> [!IMPORTANT]
187-
> Copy the user name and password to a temporary text file as you will need them later in this tutorial.
188-
189-
<!-- not all locations support az postgres up -->
190-
> [!TIP]
191-
> `-l <location-name>` can be set to any [Azure regions](https://azure.microsoft.com/global-infrastructure/regions/). You can get the regions available to your subscription with the [`az account list-locations`](/cli/azure/account#az-account-list-locations) command. For production apps, put your database and your app in the same location.
192-
193-
::: zone-end
194-
195-
::: zone pivot="postgres-flexible-server"
196-
197106
1. Enable parameters caching with the Azure CLI so you don't need to provide those parameters with every command. (Cached values are saved in the *.azure* folder.)
198107

199108
```azurecli
@@ -227,8 +136,6 @@ Having issues? [Let us know](https://aka.ms/DjangoCLITutorialHelp).
227136

228137
1. When the command completes, **copy the command's JSON output to a file** as you need values from the output later in this tutorial, specifically the host, username, and password, along with the database name.
229138
230-
::: zone-end
231-
232139
Having issues? [Let us know](https://aka.ms/DjangoCLITutorialHelp).
233140
234141
## Deploy the code to Azure App Service
@@ -237,36 +144,6 @@ In this section, you create app host in App Service app, connect this app to the
237144
238145
### Create the App Service app
239146
240-
::: zone pivot="postgres-single-server"
241-
242-
1. In the terminal, make sure you're in the *djangoapp* repository folder that contains the app code.
243-
244-
1. Create an App Service app (the host process) with the [`az webapp up`](/cli/azure/webapp#az-webapp-up) command:
245-
246-
```azurecli
247-
az webapp up --resource-group ServiceConnector-tutorial-rg --location eastus --plan ServiceConnector-tutorial-plan --sku B1 --name <app-name>
248-
```
249-
<!-- without --sku creates PremiumV2 plan -->
250-
251-
* For the `--location` argument, make sure you use the location that [Service Connector supports](concept-region-support.md).
252-
* **Replace** *\<app-name>* with a unique name across all Azure (the server endpoint is `https://<app-name>.azurewebsites.net`). Allowed characters for *\<app-name>* are `A`-`Z`, `0`-`9`, and `-`. A good pattern is to use a combination of your company name and an app identifier.
253-
254-
This command performs the following actions, which may take a few minutes:
255-
256-
<!-- - Create the resource group if it doesn't exist. `--resource-group` is optional. -->
257-
<!-- No it doesn't. az webapp up doesn't respect --resource-group -->
258-
259-
* Create the [resource group](../azure-resource-manager/management/overview.md#terminology) if it doesn't already exist. (In this command you use the same resource group in which you created the database earlier.)
260-
* Create the [App Service plan](../app-service/overview-hosting-plans.md) *DjangoPostgres-tutorial-plan* in the Basic pricing tier (B1), if it doesn't exist. `--plan` and `--sku` are optional.
261-
* Create the App Service app if it doesn't exist.
262-
* Enable default logging for the app, if not already enabled.
263-
* Upload the repository using ZIP deployment with build automation enabled.
264-
* Cache common parameters, such as the name of the resource group and App Service plan, into the file *.azure/config*. As a result, you don't need to specify all the same parameter with later commands. For example, to redeploy the app after making changes, you can just run `az webapp up` again without any parameters. Commands that come from CLI extensions, such as `az postgres up`, however, do not at present use the cache, which is why you needed to specify the resource group and location here with the initial use of `az webapp up`.
265-
266-
::: zone-end
267-
268-
::: zone pivot="postgres-flexible-server"
269-
270147
1. In the terminal, make sure you're in the *djangoapp* repository folder that contains the app code.
271148

272149
1. Switch to the sample app's `flexible-server` branch. This branch contains specific configuration needed for PostgreSQL Flexible server:
@@ -291,8 +168,6 @@ In this section, you create app host in App Service app, connect this app to the
291168
* Enable default logging for the app.
292169
* Upload the repository using ZIP deployment with build automation enabled.
293170

294-
::: zone-end
295-
296171
Upon successful deployment, the command generates JSON output like the following example:
297172

298173
:::image type="content" source="../app-service/media/tutorial-python-postgresql-app/az-webapp-up-output.png" alt-text="Screenshot of the terminal, showing an example output for the az webapp up command." :::
@@ -307,21 +182,6 @@ The app code expects to find database information in four environment variables
307182

308183
To set environment variables in App Service, create "app settings" with the following `az connection create` command.
309184

310-
::: zone pivot="postgres-single-server"
311-
312-
```azurecli
313-
az webapp connection create postgres --client-type django
314-
```
315-
316-
The resource group, app name, db name are drawn from the cached values. You need to provide admin password of your postgres database during the execution of this command.
317-
318-
* The command creates settings named "AZURE_POSTGRESQL_HOST", "AZURE_POSTGRESQL_NAME", "AZURE_POSTGRESQL_USER", "AZURE_POSTGRESQL_PASS" as expected by the app code.
319-
* If you forgot your admin credentials, the command would guide you to reset it.
320-
321-
::: zone-end
322-
323-
::: zone pivot="postgres-flexible-server"
324-
325185
```azurecli
326186
az webapp connection create postgres-flexible --client-type django
327187
```
@@ -331,8 +191,6 @@ The resource group, app name, db name are drawn from the cached values. You need
331191
* The command creates settings named "AZURE_POSTGRESQL_HOST", "AZURE_POSTGRESQL_NAME", "AZURE_POSTGRESQL_USER", "AZURE_POSTGRESQL_PASS" as expected by the app code.
332192
* If you forgot your admin credentials, the command would guide you to reset it.
333193

334-
::: zone-end
335-
336194
> [!NOTE]
337195
> If you see the error message "The subscription is not registered to use Microsoft.ServiceLinker", please run `az provider register -n Microsoft.ServiceLinker` to register the Service Connector resource provider and run the connection command again.
338196

@@ -391,7 +249,7 @@ Having issues? Refer first to the [Troubleshooting guide](../app-service/configu
391249
392250
## Clean up resources
393251
394-
If you'd like to keep the app or continue to additional tutorials, skip ahead to [Next steps](#next-steps). Otherwise, to avoid incurring ongoing charges, delete the resource group created for this tutorial:
252+
If you'd like to keep the app or continue to more tutorials, skip ahead to [Next steps](#next-step). Otherwise, to avoid incurring ongoing charges, delete the resource group created for this tutorial:
395253

396254
```azurecli
397255
az group delete --name ServiceConnector-tutorial-rg --no-wait
@@ -403,9 +261,7 @@ Deleting all the resources can take some time. The `--no-wait` argument allows t
403261

404262
Having issues? [Let us know](https://aka.ms/DjangoCLITutorialHelp).
405263

406-
## Next steps
407-
408-
Follow the tutorials listed below to learn more about Service Connector.
264+
## Next step
409265

410266
> [!div class="nextstepaction"]
411267
> [Learn about Service Connector concepts](./concept-service-connector-internals.md)

articles/service-connector/tutorial-java-spring-confluent-kafka.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Create an instance of Azure Spring Apps by following [the Azure Spring Apps quic
9898
1. Create the app with a public endpoint assigned. If you selected Java version 11 when generating the Spring Cloud project, include the `--runtime-version=Java_11` switch.
9999

100100
```azurecli
101-
az spring-cloud app create -n hellospring -s <service-instance-name> -g <your-resource-group-name> --assign-endpoint true
101+
az spring app create -n hellospring -s <service-instance-name> -g <your-resource-group-name> --assign-endpoint true
102102
```
103103

104104
## Create a service connection using Service Connector
@@ -108,7 +108,7 @@ Create an instance of Azure Spring Apps by following [the Azure Spring Apps quic
108108
Run the following command to connect your Apache Kafka on Confluent Cloud to your spring cloud app.
109109

110110
```azurecli
111-
az spring-cloud connection create confluent-cloud -g <your-spring-cloud-resource-group> --service <your-spring-cloud-service> --app <your-spring-cloud-app> --deployment <your-spring-cloud-deployment> --bootstrap-server <kafka-bootstrap-server-url> --kafka-key <cluster-api-key> --kafka-secret <cluster-api-secret> --schema-registry <kafka-schema-registry-endpoint> --schema-key <registry-api-key> --schema-secret <registry-api-secret>
111+
az spring connection create confluent-cloud -g <your-spring-cloud-resource-group> --service <your-spring-cloud-service> --app <your-spring-cloud-app> --deployment <your-spring-cloud-deployment> --bootstrap-server <kafka-bootstrap-server-url> --kafka-key <cluster-api-key> --kafka-secret <cluster-api-secret> --schema-registry <kafka-schema-registry-endpoint> --schema-key <registry-api-key> --schema-secret <registry-api-secret>
112112
```
113113

114114
Replace the following placeholder texts with your own data:
@@ -147,7 +147,7 @@ Select **Review + Create** to review the connection settings. Then select **Crea
147147
Run the following command to upload the JAR file (`build/libs/java-springboot-0.0.1-SNAPSHOT.jar`) to your Spring Cloud app.
148148
149149
```azurecli
150-
az spring-cloud app deploy -n hellospring -s <service-instance-name> -g <your-resource-group-name> --artifact-path build/libs/java-springboot-0.0.1-SNAPSHOT.jar
150+
az spring app deploy -n hellospring -s <service-instance-name> -g <your-resource-group-name> --artifact-path build/libs/java-springboot-0.0.1-SNAPSHOT.jar
151151
```
152152
153153
## Validate the Kafka data ingestion

0 commit comments

Comments
 (0)